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

![How Strands Stash fits together. Where your agent runs, on a laptop, in a container, or in an AgentCore Runtime session, are the agent (Claude Code, Codex, Kiro, or a Strands agent), the mount, and the Stash daemon. 1, the agent reads the mount with ls, grep, cat, and jq; a read never calls a source. 2, the agent asks the daemon to search, call a tool, or save a note. 3, the daemon returns a preview to the agent and writes the full results to the mount as files. 4, each turn goes to the daemon through hooks, and the daemon can write it back to AgentCore Memory. The sources keep the data: AgentCore Memory, AgentCore Gateway with Amazon Bedrock Knowledge Bases, web search, and AWS Context, MCP servers, and other stores through plugins.](https://raw.githubusercontent.com/strands-agents/stash/833198a2b91f6490291149d06b4daac8de0727c8/docs/user/images/stash-how-it-fits.svg)

| 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

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

The lifecycle has eight steps.

1.  **Create.** `stash create ops --config stash.toml` starts 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 the `stash` MCP server into the harness.
2.  **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](/docs/user-guide/stash/capabilities/hydration/index.md).
3.  **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.
4.  **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](/docs/user-guide/stash/capabilities/progressive-disclosure/index.md).
5.  **Notes.** With `[extraction]`, Stash asks the agent for a note after enough new work. The note lands in `local/memories/` and outlasts a compaction of the window. See [Local memory](/docs/user-guide/stash/capabilities/local-memory/index.md).
6.  **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.
7.  **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](/docs/user-guide/stash/capabilities/feedback-loops/index.md).
8.  **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

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](/docs/user-guide/stash/integrations/box/index.md).

## What lasts and what doesn’t

-   `stash daemon stop` ends 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 next `stash daemon start` restores each mount.
-   `stash delete ops` forgets the mount and removes its steering, hook, and MCP entries from each workspace. It keeps the files and the data, so `stash create` with the same config brings the mount back. Add `--remove-data` to 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](/docs/user-guide/stash/capabilities/managed-workspace/index.md).

## Next steps

-   [One interface](/docs/user-guide/stash/capabilities/one-interface/index.md): the tree and the `_sources/` pages.
-   [Attachment modes](/docs/user-guide/stash/guides/attachment-modes/index.md): MCP tools or the shell.
-   [Command reference](/docs/user-guide/stash/reference/cli/index.md): every command, flag, and exit code.