Repository navigation
Let a plugin read memories by id with getMemories - #46
Merged
Merged
Conversation
A derived-index plugin that re-summarizes a cluster needs its members' current text and embeddings. Reading them by id beside scanMemories keeps memory content in one place, where withdrawal, the content flag and rescoping already apply. Dispatch-Task: agent-memory-get-memories Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… older-runtime paths Dispatch-Task: agent-memory-get-memories Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…op narrating comments Dispatch-Task: agent-memory-get-memories Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 13, 2026
kriszyp
marked this pull request as ready for review
November 13, 2026 06:03
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.
⊙ Problem
A plugin that builds data from memories, such as cluster summaries, must re-read specific memories' current text and vectors.
scanMemoriesonly walks every memory in creation order. Without a by-id read, the plugin would copy text and vectors into its own table, and withdrawal, the content flag and rescoping would have to clear that copy too (#36).💡 Solution
getMemories(ids)returns the rows for those ids, in the order asked. Unknown ids are left out.scanMemoriesrows, embedding included, in every status. The caller decides eligibility.scanMemoriesdoes.🤔 One search per 100 ids, not one get per id
Reviewers suggested
Memory.getfor each id. I kept the search: the repo already uses anorsearch over ids for sets. It uses a get only for a single id (src/provenance.ts). The brief asked for batched reads. Nothing here measures either way, and the PR claims no speedup. Switch if a benchmark favors gets.⚖️ Alternatives
scanMemoriesand filter by id — walks every row; a missing id forces a full walk.Planning verdict
better-alternative-exists(a get per id) was overruled as above.🔧 Changes
src/search.tsandsrc/index.ts: the read, the public export, and the forward to the running plugin.src/runtime.ts: the runtime gains an optionalgetMemories, so older runtimes stay valid.DESIGN.md,CLAUDE.md,README.mdandCHANGELOG.md: contract, the unguarded-read exception, an example, the entry.test/extensions.test.js,test/cross-copy.test.js,cross-app.test.tsand its fixture: unit, cross-copy and real-Harper cross-app tests.✅ Verification
npm test: 477 of 477 pass on Node 26.2 (new: order, omitted ids, every status, batching, failure, bad input, cross-app forwarding, older-runtime fallback). CI runs Node 22 and 24.npm run test:integration: 75 of 75 pass on a real Harper, including a second app that callsgetMemoriesunder both module loaders.🤖 Generated by Claude Sonnet 5.5 via Claude Code; posted via @kriszyp.
Related PRs: #45 independent (merged; this adds getMemories beside its scanMemories)
Complexity: medium
Deferred findings
6219ce1cd1048a2cminor reliability —src/index.ts— Runtime with scanMemories but no getMemories silently runs getMemories locally; warnIfOldRuntime keys on scanMemories only — filed Warn when the running plugin lacks getMemories but has scanMemories #48a40a87232fbb15b8nit performance —src/search.ts— Batched by-id read uses an OR search plus Map reorder instead of Memory.get per id — filed Compare a get per id with an or search in getMemories for small id lists #47Origin — the dispatch brief this PR was written from
Add
getMemories(ids)to agent-memory: a trusted, in-process read of Memory rows by id for derived-index plugins, beside thescanMemoriesadded in PR #45 (Let another plugin scan memories and add bootstrap sections and search annotations). Export it from the package index and publish it on the runtime registry exactly asscanMemoriesis (additive MemoryRuntime member; a copy of the package in another app forwards to the running plugin). Update DESIGN.md Extension points and CHANGELOG [Unreleased]. Do not cut the release; 0.1.5 is released right after this merges.Acceptance
Unit tests: returns found rows in input order with embedding and scopes, omits unknown ids, returns withdrawn/superseded rows; cross-app test (same pattern as the scanMemories cross-copy test) shows a second package copy forwarding to the running plugin. DESIGN.md and CHANGELOG updated. CI green on Node 22 and 24. Do not bump the version or release.
Dispatch: task
agent-memory-get-memories· queued by kris-session · ran by claude/sonnet/high · worker kzyp-xps-1Ready-For-Promotion: fa429d7 urgency=normal late=none
Review-Coverage: authored=claude; ran=cursor-composer,gemini,codex; adjudicated=domain; declined=cursor-grok,muse; rounds=3; full=3 @ fa429d7
Review-Attention: read ~3m (decisions: do-less-alternative, requirement-shift, missing-id-omitted, all-statuses-by-default, size-limit-advisory, all-status-read, missing-ids-dropped, array-not-iterable, or-search-batching) @ fa429d7