Skip to content

design: add long term memory design#844

Draft
opieter-aws wants to merge 3 commits into
strands-agents:mainfrom
opieter-aws:opieter-aws/push-local-commits
Draft

design: add long term memory design#844
opieter-aws wants to merge 3 commits into
strands-agents:mainfrom
opieter-aws:opieter-aws/push-local-commits

Conversation

@opieter-aws
Copy link
Copy Markdown
Contributor

Description

Related Issues

Type of Change

  • New content
  • Content update/revision
  • Structure/organization improvement
  • Typo/formatting fix
  • Bug fix
  • Other (please describe):

Checklist

  • I have read the CONTRIBUTING document
  • My changes follow the project's documentation style
  • I have tested the documentation locally using npm run dev
  • Links in the documentation are valid and working

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@opieter-aws opieter-aws force-pushed the opieter-aws/push-local-commits branch from f280dba to c0bfdb5 Compare May 19, 2026 16:37
Comment thread designs/0011-knowledge-bases.md Outdated

#### Context Injection

Context injection guarantees that relevant knowledge is always present, at the cost of paying for retrieval every turn. This is useful when baseline context is more important than token efficiency, or when the model can't reliably judge when to search.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we decide on a system prompt vs a distinct message?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent takes system prompt injection with higher priority than a message. We can run additional benchmarking here, but that's what research shows

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol I have the same mental model of keeping system prompt for instructions only, but the industry tends to dump the data to system prompt. That keeps conversational flow normal (sequential), and it makes system prompt into this dynamic component.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq, given that we keep appending xml to system prompt (skills, memory, etc), should we make it more configurable? should we improve our system prompt handling? 🤔

Comment thread designs/0011-knowledge-bases.md Outdated
Comment thread designs/0011-knowledge-bases.md Outdated
Comment thread designs/0011-knowledge-bases.md
Comment thread designs/0011-knowledge-bases.md Outdated
Comment thread designs/0011-knowledge-bases.md

### Knowledge Ingestion

Knowledge can enter the system in two ways: the agent explicitly writes it (via a `store_memory` tool registered by MemoryManager), or MemoryManager automatically extracts it from conversation messages using an extractor (a component that distills messages into discrete facts via a model call).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should store/search memory be separate tools? can't we do dynamic tooling instead? just have a memory tool with search and store as actions? 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we split the tools more, it'll cause pain/annoyance (on toolspec and token side + tool shortlisting side [lke manage tools])

that said if it performs better on evals, sure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they can be registered separately, we can consider that. We shouldn't couple them in case of a readOnly store.

Comment thread designs/0011-knowledge-bases.md Outdated
model,
memoryManager: new MemoryManager({
stores: [{ store, namespace: 'user-123' }],
tools: true, // Agent gets search_memory tool.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would workshop the config UX more. tools: true is surprising to me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe like retrieveTools and writeTools could be more granular/clear

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+, do we want to allow users to provide their tools?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/strands-agents/docs/pull/844/changes#diff-bbb536e8ceda86b8e7bbc8a665ee8f4eca2ac0d5ead2259f6c043ded15e54d1fR305 . AFAIK we're using the same setup for context offloading. It's a situation of boolean | defaults

Comment thread designs/0011-knowledge-bases.md
Comment thread designs/0011-knowledge-bases.md
})
```

## Alternatives Considered
Copy link
Copy Markdown
Member

@zastrowm zastrowm May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we consider thinking about memories as files instead of in-memory representations?

Comment thread designs/0011-knowledge-bases.md
### What Becomes Harder or Requires Attention

- **Eventual consistency**: writes are async; a fact may not be searchable in the next turn.
- **Extraction cost**: `perTurn` triggers a model call every turn. We need sensible defaults and good documentation for users to navigate this.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this compare generally to what other frameworks use? And/or how do most services handle this? Are they mostly doing this server side anyways?


When no extractor is configured, messages are serialized as plain text and passed directly to the store's `add()` method. This is the correct setup for managed backends that handle extraction internally.

## Developer Experience
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the defaults? you enabled both direct ingestion and tools with a param, so we do we need customers to enable one or the other?


### Context injection lifecycle

When injection is enabled, MemoryManager hooks into `BeforeInvocationEvent` (once per turn). The lifecycle:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side-topic, but we should push for a better way to do this IMHO; the whole "modify the system-prompt on every term" seems like a non-ideal hack at this point


### Migration

No breaking changes. `memoryManager` is a new optional parameter on `AgentConfig`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this relate to conversation manager, session manager, snapshots?

Comment thread designs/0011-knowledge-bases.md Outdated
Comment thread designs/0011-knowledge-bases.md Outdated
Comment thread designs/0011-knowledge-bases.md
Comment thread designs/0011-knowledge-bases.md Outdated
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.

8 participants