Uh oh!
There was an error while loading. Please reload this page.
feat(memory): recall category breadcrumbs + drill-down tool - #95
Merged
Conversation
memU categories are rolled-up topic documents (5-20KB each). recall() dumped them verbatim, so a few category hits ballooned past the harness tool-output limit (~55KB -> persisted to file) and bloated every session's pre-recall system prompt. They also duplicate the items recall already returns. Categories now surface as one-line breadcrumbs (curated description, or first content line of the summary, capped + [ref:] stripped), with items returned full and each tier capped independently. New memory_expand_category tool drills a cat:<id> into its constituent items via the membership table (recency-ordered, keyword-filterable, bounded). A hard byte budget on the recall handler guarantees the output can never trip the persister again. On real data the 5 fattest categories drop from ~81KB to ~384B (99.5%).
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 freeto 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.
Summary
memU is hierarchical: an item is one atomic fact, a category is a rolled-up topic document (5–20KB) that indexes many items.
recall()returned category hits with their full summary inlined, so a handful of category hits ballooned the tool output past the harness's inline-output limit — it got silently persisted to a file (Output too large (54.9KB)) instead of reaching the model. The same fat summaries also bloated every new session's pre-recall system prompt (engine.py), and duplicated the itemsrecall()already returns.This reframes a category as an index entry, not a payload: recall surfaces it as a one-line breadcrumb you can drill into on demand.
What changed
recall()now returns items first (atomic, full content) followed by category breadcrumbs — the curateddescription(or first content line of the summary, with[ref:]markers stripped), capped to 200 chars. Items and categories are capped independently (limit,category_limit).memory_expand_categorytool drills acat:<id>breadcrumb into its constituent items via thememu_category_itemsmembership table — most-recent-first, optional keyword filter, bounded._clip_to_budget) on the recall handler output, so it can never trip the persister again regardless of content.recall()consumers (recall tool,session_context, engine pre-recall) benefit automatically — the fix is at the bridge layer.Impact (measured on real data)
The 5 fattest categories dumped verbatim = 80,964 bytes. As breadcrumbs = 384 bytes — a 99.5% reduction. Verified live: the query that previously returned
Output too large (54.9KB)now returns5 memories + 5 related topics, andmemory_expand_categorydrills a category of 858 items down to a bounded, filtered list.Test plan
tests/test_recall_breadcrumbs.py— 14 tests: breadcrumb extraction (description / summary fallback / truncation), byte-budget clipping, recall item/category split + caps,expand_categoryrecency ordering / keyword filter / unknown-id, both handlers.844 passed.