Repository navigation
The inspector's Last recalled counts every agent read that served a memory - #311
Merged
Merged
Conversation
…emory recall_count holds only the recall credit, which a memory.search from a reader that closes the loop writes. A context pack, a memory.ask, a procedure match or an uncredited search returned the key and wrote nothing, so the dashboard said "Never recalled" for memories agents had been shown. Those reads now write a `served` usage event, which nothing ranks on. memory.get with include_recall_breakdown answers served_count and last_served_at over the user's live rows of the key (an event lands on the newest copy only), and memory.health counts a key served either way as not silent. The fold skips the loom.memory UPDATE when a bump changes none of its counters. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The totals view bumps a memory on every event, `served` included, and the fold anchored the reinforcement decay on that bump: a memory a context pack returns every turn would never decay. The identity read now takes the anchor from the last event other than `served`. A `served` event is written only for the ops that return memory to an agent, once per key per request, never for a worker's search or a bench-labelled calling agent. memory.health reads `served` events of the last silent_after_days only, and an imported count with no time shows as the count alone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…er request record_usage_for_keys puts an event on the newest copy of the key in the namespace, whichever user wrote it, so a reader filtered by user missed reads of its own copy. memory.get counts every live row of the key, and a reader narrowed to one user or session counts its own row only; memory.health counts per key. The one-event-per-key-per-request mark lives on the request tail, which the server opens per request, instead of the caller's request id, and carries the org. The by_type description says what is counted. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A search pass wrote `served` for its final hits, but context.pack and search.query trim what the pass found before answering (transcript rows, items past a section budget, flagged hits), so rows no agent was shown counted as recalled. The five agent read ops (memory.search, search.query, context.pack, memory.ask, procedure.match) now record from their own answer, through a wrapper where the op is declared: a handler another op calls directly records nothing, so the per-request mark goes. A sentinel agent with no named consumer is a measurement read and records nothing, as for the credit. The narrowed reader's scope and the health window are tested on clickhouse-local. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…d figures memory.ask with reinforce: false is an evaluation read and now records no `served` event, as memory.search with auto_touch: false does. The inspector's re-reads after an expiry change or a saved edit ask for the served figures, so Last recalled keeps its count. The extractors are tested on each op's real output model. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… on its own row A context pack's memory stack section cites `stack:<layer>/<key>`, which the pack's extractor skipped, so pinned and recent rows shown at every session start stayed "No agent read recorded"; those layers are read from the request's namespace, and memory.stack itself now records what it returns. The key funnel puts an event on the newest copy of the key inside the reading request's scope, and the served read counts the key's rows inside the same scope, so a token narrowed to one user records on and reads its own copy, never another user's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The `served` event type in loom.memory_usage_events bumped the totals view, so an N-1 usage fold anchored the reinforcement decay on it during a rollout, and a new value is only written once the previous build tolerates it. Served reads now go to loom.memory_served_daily (migration 084), a SummingMergeTree per memory, agent and day that nothing ranks on and the fold never reads; the fold changes are reverted. Every agent read op records what it returned, credited or not, so a narrowed reader whose credit lands on another user's copy still sees its read. The pack notes each cited row's key where it makes the citation, so a key with `#` is never cut at a resource suffix. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The stack, decisions and procedures sections handed their full citation list on while the section trim, or the pack's own, cut their lines, so a row past the cut counted as served. Each section now names the stored row behind each item line, and since a trim keeps a prefix, the rows whose lines the rendered pack still holds are the ones recorded (context_layout.served_rows). The stack's row layers are one constant. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A chunk hit's memory_key is `chunk:<session>:<n>`; the stored row is its parent_memory_key, so a served chunk resolved to no row and its fact stayed "No agent read recorded". The search, ask and search.query extractors and the pack's memories section record the parent. The pack's served rows are described as what its rendered answer still holds. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… runs the pack The answer carries every kept line in `sections` and `blocks`, not only in `rendered`, which the pack's own budget cuts; a caller reading the blocks was shown those rows, so the served rows are counted against the section bodies. A key holding `#` is tested through handle_context_pack instead of a hand-set list. records_served's input is typed by what it reads (org, agent). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ncluded MCP and the plugins read context.pack's `rendered` alone, which the pack cuts to its token budget, so a row whose section the answer still carries in `sections` but `rendered` dropped was never shown to those agents; the plugin's session-start pack drops its memories section that way. The served rows are counted over `rendered` again, with a test whose budget cuts the memories section off. The silent_after_days description says what `silent` counts. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The answer marks an abstaining memories section as no answer, and the prompt-recall hook drops such a pack, so its memories and decisions rows no longer count as served; the stack beside them still does. The docs and served_rows say a row counts where the answer shows it, and what a client discards is its own. The repeated comment on the six wrapped ops goes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
memory.for_file is how the plugin's pre-edit hook shows an agent the decisions and constraints naming a file, so it now records the rows its rendered block prints (render_block reports them). A key lookup (memory.get, bulk_get, list) is the agent naming a key it knows, not a recall; the docs, the tooltip and the test of wrapped ops say so. _pack_decisions_from_hits takes `abstained` with no default. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…cutoffs are UTC dates memory.for_file's input names no agent, so its read now records the named consumer as the reader, and nothing when none is named, as for a sentinel agent. The served rows' 30-day and silent_after_days cutoffs are bound as UTC dates instead of the ClickHouse server's today(). One helper maps a hit to its stored row (a chunk to its parent) for the pack and the extractors, and one extractor reads the rows a pack or file block noted it rendered. Migration 084's comment names memory.for_file. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… names its consumer A served row lands on the newest live copy of the key, which can be one memory.health leaves out of its active rows (a rejected or duplicate copy written later), so health now sums the served rows per key over every live copy. A read sent as `*` or `-` behind a named consumer records the consumer as its reader, so "Recalled by" can name it. The migration and wire comments are reflowed, the pack calls hit_row directly, and served_reads imports at the top. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…rd a chunk's parent The health query's key lookup read every live row of the namespace a second time; it now reads only the rows served inside the window. The pack's decisions section maps a hit to its stored row with hit_row like the memories section, and memory.for_file drops a fallback its hits never need. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…le is on the ClickHouse page memory.health reads recall credits on the active rows, as before, and served rows on every live copy; the docstring, the field comment and the usage doc say so. The ClickHouse architecture page lists memory_served_daily with the counters and says why it takes no view. recall_by_agent drops a sentinel-agent filter its rows can no longer hit, and the usage paragraph's "neither" reads "not counted either". Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The memory stack's procedure layer matches across the caller's namespaces, but
its entries named none, so memory.stack and the pack's stack section recorded a
procedure under the request's namespace: a same-key row there got the read, or
it was dropped. A stack entry now carries `namespace` when its row lives
elsewhere ("" = the request's). hit_row lives with the search-hit helpers and
reads a wire hit dict too, so search.query's extractor uses it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ads "Not available" A stack procedure carries `namespace` only when it lives outside the request's, as the field says. The inspector shows "Not available" when the served figures are missing (an older server, or a failed lookup) and no credit is known, instead of claiming no agent read it. newest_key_ids uses the module's own client import. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ch extractor memory.health had pooled recall credits across a key's copies, so an uncredited copy of a credited key stopped being silent; a credit counts for its own row again, and served rows count per key over every live copy. The test of the wrapped ops checks the extractor each op records with, which the wrapper now exposes. The usage doc names the code plane's annotating reads as not counted. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…fit the reference The wrapper calls its handler through `__wrapped__`, so a test stands in each registered op's answer and checks the key the real wrapper records, instead of an attribute naming the extractor. served_count and recalled_ever lead with the sentence a caller needs, which the reference table shows whole; the op list stays in the usage doc. "As ever" goes from the health docstrings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/recall-label
branch
from
November 7, 2026 09:17
8b15999 to
85f1596
Compare
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
The memory inspector's Last recalled now counts every agent read that recalled the memory (searches, context packs and the memory stack,
memory.ask, procedure matches, the pre-edit file read), so a memory an agent was shown no longer reads "Never recalled". The ranking credit is shown beside it as Recall credit, andmemory.getwithinclude_recall_breakdownanswersserved_countandlast_served_at.Why
The inspector printed "Never recalled" whenever
recall_countwas 0.recall_countis the recall credit: only amemory.searchfrom a reader that closes the loop writes one (server/memory/app/recall_credit.py). A context pack andmemory.askrun their search withauto_touchoff, and a refused search writes nothing, so memories served every session read as never recalled.On a deployment with real traffic, joining the last 30 days of the exposure ledger to the live rows found keys that were served and still had
recall_count = 0:recall_count = 0context.pack(*and the plugin agents)search.querymemory.searchmemory.askRuled out: the fold is complete (no live row whose totals exceed its folded
recall_count), count and timestamp never disagree, and keys whose totals point at a gonememory_idwere deleted and written again (a reset is correct there). A second, smaller pattern: a credit lands on the newest live copy of a key in the namespace (record_usage_for_keys), whichever user or session wrote it, so the other copies of the same key read 0 (770 keys).The fix keeps "was an agent shown this?" apart from the ranking credit:
loom.memory_served_daily(migration 084) records agent reads: aSummingMergeTreeper (org, namespace, memory_id, agent, day) with a count and the last time. Nothing ranks on it and the usage fold never reads it.server/memory/app/served_reads.py):memory.search,search.query,context.pack,memory.stack,memory.ask,procedure.matchandmemory.for_file(the rows the pre-edit block prints). The op's handler is wrapped where the op is declared, so a hit the op trims (a transcript row a pack drops, an item past a section budget, a flaggedsearch.queryhit) is not counted, and a handler another op calls directly records nothing. A context pack records the rows whose item lines itsrenderedanswer still holds after every section and pack trim: MCP's lean pack carriesrenderedalone, and the plugin's session-start pack cuts its memories section off that way. A pack whose memories search abstained records none of that section's (or its decisions') rows: the answer marks them as no answer, and the prompt-recall hook drops such a pack. What a client discards from an answer otherwise (the hook skipping citations it showed earlier in the session) is not tracked by the server. Each section names the stored row behind each line, and a trim keeps a prefix (context_layout.served_rows), so it never parses citation strings. A chunk hit (chunk:<session>:<n>) records its parent fact, the stored row.memory.get,memory.bulk_get,memory.list: the agent names the key it reads, which is no recall), amemory.searchsent withauto_touch: falseor amemory.askwithreinforce: false(evaluation reads), a read by the dashboard or the assistant, a measurement read (a bench label, or*/-with no named consumer, as for the credit), ops that search for their own use (decision.precedents,memory.apply, workers), and the code plane's reads that annotate code with the memories naming it (code.review_brief, lesson notes on code results).usage.newest_key_ids, factored out of the credit funnel): for a token narrowed to one user, a row of its own.memory.getwithinclude_recall_breakdownreads the key's live rows inside the same scope and answersserved_count/last_served_at, never belowrecall_count(a bulk import seeds it with no reads behind it).recall_by_agentreads the served rows.memory.healthcounts a row as recalled, not silent, on its own recall credit (as before) or a served row in the lastsilent_after_dayson any live copy of its key (the window bounds the served rows read, and only those are mapped to their keys), summed per key, since a read can land on a copy health does not list (a rejected or duplicate copy written later).*/-read (the SDK's and MCP's cross-agent read, a pack) or an input with no agent (memory.for_file), the named consumer behind it, so "Recalled by" can name it.recall_count. Every inspector re-read asks for the breakdown, so an edit keeps the figure.A per-key read of the exposure ledger was the other candidate source; measured on the largest namespace it read 120 MB and used 126 MB per inspector open, against about 1 MB and 5 MB for a keyed read. An earlier revision of this PR wrote a
servedevent type intoloom.memory_usage_events; the totals view bumps a memory on every event there, so build N-1's fold would have moved the reinforcement decay anchor during a rollout. A table of its own leaves the fold and ranking untouched.Scope and risk
loom.memorykey lookup (usage.newest_key_ids), in a background task per request like the existing recall credit; the table collapses to one row per memory, agent and day. Measured on the largest namespace of a deployment with real traffic, the lookup for 10 keys read 2,432 rows and 170 KB with 5 MB of memory in about 20 ms. A creditedmemory.searchruns it twice, once for the credit and once for the served row.(org, namespace)and the request's read scope: a token narrowed to one user records on, and reads, its own copies only. Recall credits keep their namespace-wide funnel, unchanged.NO_MEMORY_CONTENT.Compatibility, rollout and rollback
memory.getaddsserved_countandlast_served_at(null unlessinclude_recall_breakdown). Amemory.stackentry addsnamespace, set when its row lives in another of the caller's namespaces (a matched procedure; "" = the request's), so the read records where the row lives.recall_by_agentnow counts agent reads fromloom.memory_served_daily(credited or not) instead of recall credits.memory.health'srecalled_ever,silent,silent_olderandby_type[].recalledalso count served rows of the lastsilent_after_days.084_memory_served_daily.sql, additive. Build N-1 never reads or writes the table.served_countand falls back to the credit figures, reading "Not available" when there is no credit either.Tests
test_served_reads.py(each extractor on its op's real output model, a chunk hit recording its parent; a search records what it returned credited or not;auto_touch: false,reinforce: false, the dashboard, the assistant, bench labels and a sentinel agent with no consumer record nothing; each of the seven registered ops, its answer stood in, records the key that answer returned, and the key lookups,decision.precedentsandmemory.applyare not wrapped; an input with noagent(memory.for_file) records its named consumer, and nothing with none named; a narrowed reader records under its own scope),test_context_pack_served_rows.py(a stack section cut to its budget records only the rows it kept;served_rowsacross a section cut and a pack cut; a pack whose budget cuts off its memories section records none of them; an abstaining pack records its stack rows only; a served chunk records its parent; a key holding#recorded whole),test_served_reads_sql.pyon clickhouse-local (health counts a read that landed on a rejected copy; a read lands on the newest copy inside the reader's scope; a key counts every live row and a narrowed reader only its own agent's reads; the health window),test_memory_health.py,test_served_totals.py,test_recall_breakdown_keyed.py.tests/integration/test_served_reads.py(a context pack makesserved_count≥ 1 on both session copies of the key, and on two users' copies, withrecall_countstill 0), against a local server and ClickHouse.test_memory_for_file.py: the rowsmemory.for_filerecords are the ones its rendered block prints, not a row its budget left out.MemoryInspector.sections.test.tsx(served without credit reads "2× · …" and "Recall credit: None"; nothing served reads "No agent read recorded"; an imported count with no time reads "9×"; a saved edit re-reads the served figures and keeps the count; no served figures and no credit read "Not available"); build and bundle budget.make lint,make typecheck,tests/unit(the fourtest_the_delimiter_is_sniffed_in_bounded_timecases exceed their CPU-time bound on this machine on untouched code too; they pass in CI onmain).AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code; the evidence queries, the failing tests, the integration run and the dashboard check were run as described above.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no merged migration is edited.docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s).🤖 Generated with Claude Code