AgentCore Memory source
An agentcore-memory source mounts the records of an
Amazon Bedrock AgentCore Memory
as files. Your agent browses them, searches them, and, when you turn it on, writes its
sessions back so the memory learns from each one.
It’s the only source kind that does all four: browse, search, hydrate from the workspace, and write back. For the write path, see Feedback loops.
What the agent sees
Section titled “What the agent sees”Each namespace is one folder under agentcore-memory/NAME/. Each record is one Markdown
file, named after its date and its title:
/tmp/ops-context/agentcore-memory/incidents/ summaries/2026-11-20__checkout-latency-after-deploy.md facts/2026-11-18__payments-db-failover-takes-90s.mdThe file holds the record as text, with its metadata in a block at the end. A summary, an episode, a preference, and a reflection each have their own layout, so the agent reads the part it needs. A search previews each kind in its own way: one line for each topic of a summary, the intent of an episode, and the whole text of a fact.
Configure it
Section titled “Configure it”[sources.incidents]kind = "agentcore-memory"description = "Summaries and facts from past incidents"arn = "arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/ops-memory-0123456789"auth = { sigv4 = {} }namespaces = ["/summaries/*", "/facts/*"]write.trajectory.actor = "ops-agent"| Key | Default | What it does |
|---|---|---|
arn | required | The memory. The region comes from it. |
auth | none | sigv4, bearer, or none. A direct call to the Memory API needs sigv4. |
namespaces | ["/*"] | One to five namespaces that the source exposes and searches. |
prefetch | the last 7 days, up to 25 records for each namespace | What the mount loads when it starts. |
write.trajectory.actor | none | Send each turn to the memory, as this actor. |
write.notes.namespace | none | Keep a copy of each note in this namespace. |
endpoint | the AWS SDK endpoint | Another URL for each call, such as a VPC endpoint or a Gateway target. |
The configuration reference has every key and its rules.
Namespaces
Section titled “Namespaces”A namespace that ends in /* selects a subtree. One with no /* selects one exact
namespace. Entries must not overlap: /actor/alice/* and /actor/alice/facts/* are
refused together. A template variable fits here, so one config serves many users:
namespaces = ["/support/${actorId}/*"]Prefetch
Section titled “Prefetch”prefetch chooses the records that are on disk before the first turn. A selector with
no query lists records. A selector with a query runs a semantic search:
[[sources.incidents.prefetch]]from = "/summaries/*"query = "checkout latency"limit = 5where = [{ field = "createdAt", op = "gt", value = "now-30d" }]prefetch = [] turns off the configured selectors. Stash still runs its built-in
profile queries. See Memory prefetch.
Search
Section titled “Search”stash search ops "payment timeouts" --path '/agentcore-memory/incidents/summaries/*'The path is the folder of the source, then the namespace. A path outside each configured namespace fails, and the error names the namespaces. A search of the source folder searches each namespace and merges the hits by score.
After an attach, Stash also searches each memory source with the text of up to six
prose files (.md, .markdown, .txt, .text) at the root of the workspace, README
first. That warm-up runs only for memory kinds,
so the text of your workspace never goes to a web search.
Write back
Section titled “Write back”With write.trajectory, the daemon sends each turn as AgentCore Memory events:
- each user prompt as a
USERevent; - each reply as an
ASSISTANTevent; - each tool request and each tool result as a
TOOLevent, as one JSON object.
The strategies of the memory then make long-term records. The next session finds them in the mount. A tool result holds the whole text the tool returned, so write back only to a memory that may hold your files and command output.
With write.notes, each note the agent saves is also one record in the namespace you
name. Each new save of the note updates that record.
Through a Gateway
Section titled “Through a Gateway”A memory behind an AgentCore Gateway connector target takes the Gateway URL, then the
target name, as its endpoint:
[sources.org-memory]kind = "agentcore-memory"arn = "arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/org-memory-9876543210"endpoint = "https://example.gateway.bedrock-agentcore.us-east-1.amazonaws.com/mcp/org-memory"auth = { bearer = { env = "STASH_GATEWAY_TOKEN" } }The source shows at agentcore-memory/org-memory/, like a direct memory.
Permissions
Section titled “Permissions”| Action | IAM permission |
|---|---|
| Browse and search | bedrock-agentcore:ListMemoryRecords, GetMemoryRecord, RetrieveMemoryRecords |
write.trajectory | bedrock-agentcore:CreateEvent |
write.notes | bedrock-agentcore:BatchCreateMemoryRecords, BatchUpdateMemoryRecords |
The daemon takes its credentials from the shell that starts it. See AWS credentials.