How Stash works
This page explains the parts of Stash and what happens in one session, from the first
stash create to the next session that starts from what this one learned. Read it when
you want to know where a file came from, or why the agent sees what it sees.
The three layers
Section titled “The three layers”| Layer | Examples | What it owns |
|---|---|---|
| Harness | Claude Code, Codex, Kiro, or a Strands agent | The model context, steering, and session hooks |
| Local Stash daemon | The ops mount at /tmp/ops-context | Mounted files, search, tool calls, hydration, cache policy, and write-back |
| Sources | Amazon Bedrock AgentCore Memory and Gateway, MCP servers, and plugins | Source data, access control, retention, and deletion |
The harness owns the context window. Stash gives it a steering block that explains the mount, plus hook output at session start, after a tool call, and at turn end. The harness decides how that text enters the model context.
The daemon runs next to the agent. One local daemon can own several mounts. It writes
the files, keeps an index of which file holds each record, and answers stash search,
stash tool call, and stash mcp. It also keeps a queue on disk for each write to a
source.
The sources keep the data. The mount is a view. Retention, deletion, and access stay with each source, and Stash reads with the credentials that you give it.
Why files
Section titled “Why files”We chose files as the interface because models already know how to use them. An agent
reads a file with cat, finds a line with grep, and pulls a field out of JSON with
jq. None of that needs a tool schema in the window, and the same tree works for every
harness.
A file is also a place to keep a result without sending all of it in every model request. When a tool-result file fits the result and cache limits, Stash writes it to disk and shows the agent a compact view. The agent reads more only when the next step needs it.
Files have limits. Stash writes ordinary files, so it fits records, results, and pages better than one huge or fast-changing collection.
The life of a session
Section titled “The life of a session”The lifecycle has eight steps.
- Create.
stash create ops --config stash.tomlstarts the daemon if it isn’t running, stores a copy of the config, and starts the mount. With--attach, it also installs the steering block, the hooks, and thestashMCP server into the harness. - Hydrate. Each source runs its hydration plan. A memory source lists recent records and runs its configured prefetch searches. A source that only answers queries, such as web search, stays empty until the agent searches it. See Hydration.
- Session start. The integration gives the harness a digest of what each source holds now. The harness adds it to the agent’s context after the steering block.
- Work. The agent reads the
_sources/pages, browses the tree, and searches. A search hit or tool-result file is written before the answer prints when it fits the mount limits. A file that does not fit gets only a preview. See Progressive disclosure. - Notes. With
[extraction], Stash asks the agent for a note after enough new work. The note lands inlocal/memories/and outlasts a compaction of the window. See Local memory. - Turn end. The integration saves the turn to the queue on disk. The daemon also reads the tool calls of the turn to learn which files the agent read, which keeps them in the cache.
- Write-back. For each source with
write.trajectory, the daemon sends the turns as events. AgentCore Memory makes long-term records from them with its strategies. See Feedback loops. - Next session. Records that the source has created can show in the mount at the next hydration, for this agent and for each agent that reads the same memory.
Stash beside the other parts of an agent
Section titled “Stash beside the other parts of an agent”Stash is one part of an agent’s context. It doesn’t replace the others:
| You need | Use | What it manages |
|---|---|---|
| A bounded conversation history | A conversation manager | The messages that go to the model |
| To resume one conversation | Session management | The saved state of that conversation |
| Long-term knowledge across sessions | A memory, such as AgentCore Memory | Records that outlive a session |
| Shared source context as files | Stash | The files of each source, search, and write-back |
| An isolated place to run | Strands Box | Where the agent’s commands run |
Give each result one path into the model’s context. If Stash keeps a tool’s full result
on disk, don’t also pass the same result through a conversation manager that stores it.
In a Strands Box sandbox, the daemon stays outside the sandbox with the credentials, and
the agent runs the stash command. See
Run an agent in a box.
What lasts and what doesn’t
Section titled “What lasts and what doesn’t”stash daemon stopends each mount. Each unsent turn stays queued on disk, and the next start sends it. The configs, files, and unsent writes stay on disk. The nextstash daemon startrestores each mount.stash delete opsforgets the mount and removes its steering, hook, and MCP entries from each workspace. It keeps the files and the data, sostash createwith the same config brings the mount back. Add--remove-datato remove them too.- The cache has a byte budget. When it’s full, the least recently used files leave the mount. The agent can search for a record again when its source supports search. A list-only source can load it again at the next hydration when its plan selects it. The agent must repeat a tool call to get a new tool result. See Managed workspace.
Next steps
Section titled “Next steps”- One interface: the tree and the
_sources/pages. - Attachment modes: MCP tools or the shell.
- Command reference: every command, flag, and exit code.