Skip to content

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.

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.md

The 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.

[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"
KeyDefaultWhat it does
arnrequiredThe memory. The region comes from it.
authnonesigv4, bearer, or none. A direct call to the Memory API needs sigv4.
namespaces["/*"]One to five namespaces that the source exposes and searches.
prefetchthe last 7 days, up to 25 records for each namespaceWhat the mount loads when it starts.
write.trajectory.actornoneSend each turn to the memory, as this actor.
write.notes.namespacenoneKeep a copy of each note in this namespace.
endpointthe AWS SDK endpointAnother URL for each call, such as a VPC endpoint or a Gateway target.

The configuration reference has every key and its rules.

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 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 = 5
where = [{ field = "createdAt", op = "gt", value = "now-30d" }]

prefetch = [] turns off the configured selectors. Stash still runs its built-in profile queries. See Memory prefetch.

Terminal window
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.

With write.trajectory, the daemon sends each turn as AgentCore Memory events:

  • each user prompt as a USER event;
  • each reply as an ASSISTANT event;
  • each tool request and each tool result as a TOOL event, 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.

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.

ActionIAM permission
Browse and searchbedrock-agentcore:ListMemoryRecords, GetMemoryRecord, RetrieveMemoryRecords
write.trajectorybedrock-agentcore:CreateEvent
write.notesbedrock-agentcore:BatchCreateMemoryRecords, BatchUpdateMemoryRecords

The daemon takes its credentials from the shell that starts it. See AWS credentials.