Skip to content

managed-memory: search-first recall via the new entries:search tool - #248

Open
kevinyan122 wants to merge 6 commits into
databricks:mainfrom
kevinyan122:feat/managed-memory-search-first
Open

managed-memory: search-first recall via the new entries:search tool#248
kevinyan122 wants to merge 6 commits into
databricks:mainfrom
kevinyan122:feat/managed-memory-search-first

Conversation

@kevinyan122

@kevinyan122 kevinyan122 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What

Adds search_memory as a sixth tool to the managed-memory skill and makes it the primary recall path, replacing the previous list_memoriesget_memory flow (which was documented as a stopgap until search shipped). Synced to all 5 templates that carry the skill.

  • New tool prompt documents the query contract for the lexical (BM25) entries:search API: a natural-language question or keywords both work, phrased with the words you'd expect to appear in the memory itself; top_k default 10, max 50; results come back ranked with full contents inlined, so recall is a single call with no get_memory follow-up.
  • get_memory / list_memories demoted to fallbacks (exact-path reads of [has_contents] entries; full-inventory asks like "what do you remember about me?").
  • Save dedup now searches first instead of listing.
  • MEMORY_INSTRUCTIONS rewritten to match: search-first recall, empty-result semantics (nothing matched those words ≠ nothing stored), raise top_k or fall back to list_memories for very broad questions.
  • Limits/troubleshooting: BM25 scores are unbounded (ranking only); newly written entries take a few seconds to become searchable (list/get see them immediately); fallback guidance for workspaces where entries:search hasn't rolled out yet.

Testing

Dogfooded on agent-langgraph-advanced against a staging workspace (store kevinyan.default.kevin_test), locally and deployed to Databricks Apps with OBO scope resolution:

  • 19-conversation eval in a fresh scope: all 7 save-side cases clean (dedup, update-in-place on contradiction, no saving of transient chatter); recall probes confirmed single-call search recall, honest misses on unstored facts, list_memories for inventory asks.
  • Verified the write→searchable index lag and the unbounded-score behavior documented here.

🤖 Generated with Claude Code

cc @jennsun — requesting your review

Kevin Yan and others added 5 commits July 17, 2026 17:35
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
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>
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