feat(memory): add memory manager#2544
Conversation
ce8787d to
97a0c1d
Compare
97a0c1d to
3be7426
Compare
mkmeral
left a comment
There was a problem hiding this comment.
also my agent will post stuff soon, but mostly aligned with this i guess
|
Did an API review pass on this (read the shipped code + tests, not just the description). Really clean, well-scoped work — fail-fast constructor validation, TL;DR
(Batch-vs-single on the 1. Write-to-all-writable-stores by default — duplicate-write footgunWhen } else {
writableStores = this._addStores // ALL writable stores
}With two writable stores (say Options: require explicit targeting when >1 writable store exists, or support a designated default-write store. (Single-writable-store setups are unaffected either way.) 2. Partial write success is reported as success
if (failures.length === writableStores.length) {
throw new AggregateError(...)
}
// otherwise: logs a warning, resolves successfullySo writing to 2 stores where 1 throws → This ties into the await/observability thread on this PR — since the manager already 3. Naming — options types vs the module conventionEverything in the module is
The main one: export interface SearchOptions { maxSearchResults?: number }
export interface SearchMemoryOptions { maxSearchResults?: number; stores?: string[] } // dupThis is the same drift export interface SearchOptions { // store primitive
maxSearchResults?: number
}
export interface MemorySearchOptions extends SearchOptions { // manager adds routing
stores?: string[]
}Suggested scheme: keep (There's no store-level Tiny extra: Happy to open inline suggestions or a small follow-up if any of these are useful — your call on what's in scope for this PR vs. the injection follow-up. |
8609b93 to
711a9c3
Compare
711a9c3 to
8eb9b50
Compare
Description
Adds the
MemoryManagerprimitive: a construct that manages one or more memory storebackends and exposes
search_memory/add_memorytools for agent-driven recall andpersistence, plus programmatic
search()/add()methods.What's included
MemoryManager(implementsPlugin): registers its tools viagetTools(), andaggregates any tools a store exposes via
MemoryStore.getTools().MemoryStoreinterface: every store is searchable; a requiredwritableflag declareswhether it accepts writes.
search_memorytargets all stores;add_memorytargets onlywritable stores. The constructor fails fast if a store is
writable: truewithoutadd().MemoryStoreConfig: shared base config that concrete store implementations extend.are dropped (with a warning), or an actionable error is thrown if all requested names
are out of scope. Omitted/empty
storestargets all in-scope stores.AgentConfig.memoryManagerfield accepting aMemoryManagerinstance or a
MemoryManagerConfigobject (auto-wrapped).Scope (intentionally minimal)
This PR ships the
MemoryManagerandMemoryStoreinterface only, to unblock downstreamconsumers (e.g. AgentCore memory) from building against a stable interface. Two pieces are
deferred to dedicated follow-up PRs:
built on the upcoming middleware system (sdk-typescript#1068) rather than lifecycle hooks,
which avoids mutating durable session history.
BedrockKnowledgeBaseStore— a concrete store implementation, tracked separately(needs its own tests + optional AWS peer-dependency wiring).
initAgentis currently a no-op; tools auto-register through thePluginRegistryviagetTools(). Will be populated when adding injection and extraction.Related Issues
#2393
Documentation PR
No new docs in this PR. A documentation PR will accompany the injection follow-up once the
full feature surface (injection + a shipped store backend) is finalized.
Type of Change
New feature
Public API
AgentConfig.memoryManagerMemoryManagerMemoryStore&MemoryStoreConfigSupporting types
Usage
Testing
Comprehensive unit tests in
strands-ts/src/memory/__tests__/memory-manager.test.ts(50tests) cover: constructor validation (empty stores, duplicate names, writable-without-add,
add-tool enablement), tool registration, store-tool scoping (in-scope/out-of-scope/partial,
omit-vs-empty),
search()/add()fan-out and partial-failure handling, store-providedtool aggregation, and
AgentConfigauto-wrapping.hatch run prepare(N/A — TypeScript package; rannpm test/type-check/lint/format:checkinstead)Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.