Skip to content

feat(memory-islands): LLM-driven folder-scoped fact extraction (v0.2.0) - #15

Open
skorphil wants to merge 10 commits into
trunkfrom
feat/memory-islands-v020-rewrite
Open

feat(memory-islands): LLM-driven folder-scoped fact extraction (v0.2.0)#15
skorphil wants to merge 10 commits into
trunkfrom
feat/memory-islands-v020-rewrite

Conversation

@skorphil

Copy link
Copy Markdown
Member

Summary

Rewrites the Memory Islands Filter plugin per the v0.2.0 spec: replaces custom folder guidelines and brittle English-prefix fact learning with LLM-driven, folder-scoped fact extraction.

Changes

  • Schema v2: memories table now stores facts + updated_at; legacy v1 tables (with guidelines column) are detected and recreated automatically.
  • New valves: EXTRACTION_MODEL (model id for background extraction; empty = reuse chat model) and EXTRACTION_INTERVAL (extract every N exchanges, default 1).
  • LLM extraction: resilient import of generate_chat_completion (open_webui.utils.chat -> open_webui.apps.webui.utils.chat -> None), strict JSON array contract with <NONE>/json fence/partial-JSON handling, 60s timeout, background task via asyncio.create_task, full error handling per docs/llm_and_error_handling.md.
  • Removed: custom folder guidelines and all /island-* slash commands (CommandsMixin and src/_commands.py deleted).
  • Tests: rewrote unit tests (fact CRUD, extraction parsing, LLM extraction, extraction model resolution, interval gating) and extended the valves integration spec; 64 unit tests pass, integration auto-skips.
  • Docs: added CHANGELOG.md following Keep a Changelog.

Verification

  • uv run ruff check plugins/memory-islands — All checks passed
  • uv run ruff format plugins/memory-islands — 10 files formatted / unchanged
  • uv run python build.py — 64 passed, 1 skipped (integration deselected automatically)

Notes

  • plugin.py is gitignored (built artifact regenerated via build.py).
  • Version bump to 0.2.0 is intentionally deferred (meta/pyproject still 0.1.0 per spec).

…regression tests

OWUI's /api/chat/completions handler pops folder_id and chat_id out of the
top-level form_data and re-injects them into body['metadata'] (keys
metadata.folder_id, metadata.chat_id, metadata.user_id). The filter inlet
therefore never sees top-level folder_id/chat_id, so _resolve_folder always
returned None and chats inside a folder were wrongly treated as Global
Workspace (e.g. /island-guidelines emitted the 'outside folder' guidance).

Read folder_id/chat_id from body['metadata'] first, falling back to legacy
top-level keys and the Chats model. Verified against a running OWUI 0.11.0
container: Chats.get_chat_folder_id is async.

Tests now use the real payload shape (metadata carries the IDs; top-level is
absent) and lock the resolution behavior: metadata folder_id wins, Chats-model
fallback uses metadata.chat_id, and global workspace returns None so the
command handler only emits the outside-folder guidance in that case.
…se OWUI version floor

The outlet body carries a top-level chat_id but no metadata/folder_id, so
auto-learning could not resolve the folder for chats inside a folder. The
outlet now declares the __user__ reserved arg (passed by OWUI's
outlet_filter_handler when declared) and forwards the user id into
_resolve_folder, which resolves the folder via the Chats model.

Also:
- Add async Chats.get_chat_folder_id regression test (the method is async in
  OWUI v0.10+, so _resolve_folder must await the coroutine) and a Chats=None
  import-failure test asserting graceful None without raising.
- Raise required_open_webui_version from >=0.3.0 to >=0.10.0: metadata.folder_id
  and Chats.get_chat_folder_id only exist from v0.10, older versions silently
  no-op folder resolution.
- Add icon_url placeholder for meta template parity.
Replace guidelines and prefix-scan learning with background LLM fact
extraction per the 0.2.0 spec:
- schema v2 (facts + updated_at; legacy v1 tables recreated)
- EXTRACTION_MODEL / EXTRACTION_INTERVAL valves
- resilient generate_chat_completion import + strict JSON parsing
- remove custom folder guidelines and all /island-* slash commands
- rewrite unit tests and extend valves integration spec
- add CHANGELOG.md with [Unreleased] entries
- Remove all /island-* slash commands and the custom guidelines mechanism
  (native folder System Prompt replaces it).
- Document LLM-driven automatic fact extraction via the internal OWUI
  generation engine (generate_chat_completion) with EXTRACTION_MODEL /
  EXTRACTION_INTERVAL valves; language-agnostic.
- Document all six Filter valves, schema v2 (folder_id PK, facts,
  updated_at) with legacy v1 recreated (no migration), the companion
  Manager Action install, the disable-native-Memories step, and the
  reserved @memory prefix caveat.
- Changelog: add the reserved @memory prefix note under [Unreleased].
…guide

- Fix releases links to the actual remote (toolfab-ai/owui-plugins) in
  docs/plugin_readme_template.md.
- Rename docs/plugin_meta_template to docs/plugin_meta_template.md and
  update the stale AGENTS.md link.
- Add docs/llm_and_error_handling.md (consolidated LLM-call & error-handling
  pattern) and reference it from docs/plugin_development.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant