Repository navigation
Add a select hook: a plugin may narrow a read, once, after the read policy - #21
Merged
Merged
Conversation
…olicy retrieve.search takes an optional select(question, context, memories, client). It runs once per read, after the read policy, on the relevant servable memories best first. It may only narrow: memories it was not offered are ignored, the core's order and the limit stay, None leaves the read unchanged. Restricted and archived memories never reach it. personakit serve passes the name the assistant connected with (MCP clientInfo), or "" when unknown. Hooks.select defaults to None. PLUGINS, ARCHITECTURE, PRIVACY, CHANGELOG and the review log updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014dGcvUc3LqzKojYnqVGCjK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Yanir · project thread
What changed
A third extension point,
select. Once per read, after the read policy, a plugin may narrow the relevant servable memories to fewer.retrieve.search(..., select=None, client=""):select(question, context, memories, client)sees the relevant memories that may be served, best first. It returns the ones to serve, orNoneto leave the read unchanged.morecounts after it.personakit servepasses the name the assistant connected with (MCPclientInfo.name), or""when unknown.Hooks.selectdefaults toNone. A non-callable value is refused at load.selectplugin receives memory text), CHANGELOG (Unreleased) and the review log.Why
A relevance score can only order memories, and with a
contextit is called twice per read. A plugin that decides which of the candidates actually answer the question needs one call per read, with the question and the context together. It also needs to know which assistant is asking.How to verify
New tests:
SelectTestintests/test_retrieve.py: only servable memories are offered, once;Nonechanges nothing; it cannot widen; the order stays the core's; an empty selection serves nothing.tests/test_plugins.py: the hook loads, and a broken one is refused.tests/test_mcp_server.py: the client name arrives through a real in-memory MCP session.Locally with mcp 1.30: 190 tests, coverage 97%, ruff clean, hygiene passed.
Checklist
git commit -s), see CONTRIBUTING.md: not signed off. DCO sign-off is the maintainer's to give.docs/ARCHITECTURE.mdGenerated by Claude Code