managed-memory: search-first recall via the new entries:search tool - #248
Open
kevinyan122 wants to merge 6 commits into
Open
managed-memory: search-first recall via the new entries:search tool#248kevinyan122 wants to merge 6 commits into
kevinyan122 wants to merge 6 commits into
Conversation
Add search_memory as the sixth tool and make it the primary recall path, replacing list_memories -> get_memory. The tool prompt documents the lexical (BM25) query contract (question or keywords, words expected to appear in the memory itself, top_k default 10 / max 50) and that results inline full contents. get_memory and list_memories are demoted to fallbacks; save dedup now searches first. MEMORY_INSTRUCTIONS rewritten to match. Document unbounded scores, the write->searchable index lag, and a fallback for workspaces where entries:search hasn't rolled out. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…contents Agents were packing every fact into ever-growing descriptions and leaving contents empty. Make the split explicit: description is one short, specific line (not a vague category); contents holds the memory once there's a second fact, date, or structure. update_memory now says new facts extend contents rather than the description, MEMORY_INSTRUCTIONS gets the matching rule, and _save/_update return a corrective nudge when a long description arrives with no contents. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ssion-scoped facts
Persona testing surfaced two recall/save gaps. (1) Situated or task-framed
prompts ('I'm at a Thai restaurant, what should I order?', 'draft a standup
update') skipped search entirely and answered generically — even asking the
user for facts already in the store. The skip rule now keys on output type:
any recommendation, plan, or draft for the user searches first, and being
about to ask the user about themselves is itself a search trigger. (2)
Facts marked 'for this conversation only' were saved anyway (annotated as
temporary); session-scoped input is now an explicit hard no-save. Also:
update_memory refreshes stale descriptions after contents edits and skips
no-op rewrites, and the long-description nudge now also fires (at a higher
threshold) when contents are populated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rim prompt duplication list_memories now requests page_size=200 and, when the API returns a next_page_token, tells the model it can continue with page_token if it needs the rest (the API paginates via page_size/page_token; max_results is silently ignored). MEMORY_INSTRUCTIONS drops the how-to-call details the search_memory docstring already carries (query composition, ranked full-contents results, empty-result semantics) and keeps only when-to-search policy; the one rule that lived nowhere else — don't re-search a topic already seen this turn — moves into the search_memory docstring. Recall wording tightened: don't ask the user anything about themselves without searching first. Limits section updated now that list has a real pagination signal. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… anti-recall line The nudge never fired in persona testing — the save/update docstring rules alone kept descriptions one-line — so remove the backstop rather than ship dead branching. Also drop "NOT for recall — use search_memory for that" from list_memories: the search-first routing already lives in the system prompt and search_memory's own description. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kevinyan122
marked this pull request as ready for review
July 23, 2026 21:18
…ist page get_memory's docstring said it was only for [has_contents] entries from list_memories, contradicting update_memory's 'get_memory first so a contents edit matches' — and search results can lag recent writes, so the pre-edit read matters. Also prefix the first paginated list page with 'first' so its count isn't mistaken for the total. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Adds
search_memoryas a sixth tool to the managed-memory skill and makes it the primary recall path, replacing the previouslist_memories→get_memoryflow (which was documented as a stopgap until search shipped). Synced to all 5 templates that carry the skill.entries:searchAPI: a natural-language question or keywords both work, phrased with the words you'd expect to appear in the memory itself;top_kdefault 10, max 50; results come back ranked with full contents inlined, so recall is a single call with noget_memoryfollow-up.get_memory/list_memoriesdemoted to fallbacks (exact-path reads of[has_contents]entries; full-inventory asks like "what do you remember about me?").MEMORY_INSTRUCTIONSrewritten to match: search-first recall, empty-result semantics (nothing matched those words ≠ nothing stored), raisetop_kor fall back tolist_memoriesfor very broad questions.list/getsee them immediately); fallback guidance for workspaces whereentries:searchhasn't rolled out yet.Testing
Dogfooded on
agent-langgraph-advancedagainst a staging workspace (storekevinyan.default.kevin_test), locally and deployed to Databricks Apps with OBO scope resolution:list_memoriesfor inventory asks.🤖 Generated with Claude Code
cc @jennsun — requesting your review