You give a Strands agent a Stash mount by passing `StrandsStash` as its memory manager. The manager does for a Strands agent what `stash attach` does for a coding agent: it puts the steering and a digest of the mount in the system prompt, gives the agent the mount’s tools, and writes each turn back.

## Before you start

-   A current Stash release on `PATH`.
-   A ready mount. The manager doesn’t start one.
-   Python 3.11 or later, or Node.js 22 or later.

## 1\. Write the mount config

Use the normal Stash config. Strands needs no `harnesses` list. To write turns back, give a memory source `write.trajectory`, and scope it to the same actor:

```toml
version = 1
mount_point = "/tmp/ops-context"

[sources.incidents]
kind = "agentcore-memory"
arn = "arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/ops-memory-0123456789"
auth = { sigv4 = {} }
write.trajectory.actor = "ops-agent"
namespaces = ["/actor/ops-agent/*"]

[extraction]
enabled = true
```

The actor and the actor part of the namespace must agree. With no `namespaces`, the agent can read the whole memory.

## 2\. Create the mount

```bash
stash create ops --config stash.toml
stash status ops   # wait for state: ready
```

The mount and the agent process must use the same `HOME`, or the same `STASH_DATA_ROOT`. Otherwise they reach different daemons.

## 3\. Install the package

### Python

```bash
pip install strands-stash-memory-manager
```

### TypeScript

```bash
npm install @strands-agents/stash-memory-manager
```

Pin the package version in your application dependency file.

## 4\. Build the agent

The manager supplies Stash search and source tools. Register a file-reading tool so the agent can open the files that a search returns.

### Python

```python
from stash_strands import StrandsStash
from strands import Agent
from strands.vended_tools import read

agent = Agent(
    system_prompt="You are an on-call agent for the checkout service.",
    tools=[read],
    memory_manager=StrandsStash(
        config_path="stash.toml",
        session_id="inc-4412",
        mount_name="ops",
    ),
)

try:
    result = agent("Have we seen checkout latency like INC-4412 before?")
    print(result)
finally:
    agent.cleanup()
```

The synchronous Python call flushes pending memory writes before it returns. `agent.cleanup()` closes the Stash MCP client.

### TypeScript

```typescript
import { Agent } from '@strands-agents/sdk'
import { read } from '@strands-agents/sdk/vended-tools/read'
import { StrandsStash } from '@strands-agents/stash-memory-manager'

const memory = new StrandsStash({
  configPath: 'stash.toml',
  sessionId: 'inc-4412',
  mountName: 'ops',
})

const agent = new Agent({
  systemPrompt: 'You are an on-call agent for the checkout service.',
  tools: [read],
  memoryManager: memory,
})

try {
  // Proves the mount before the first ask.
  await agent.initialize()
  const result = await agent.invoke(
    'Have we seen checkout latency like INC-4412 before?',
  )
  console.log(result)
} finally {
  // Flush the last turns before the MCP client closes.
  try {
    await agent.shutdown()
  } finally {
    await memory.disconnect()
  }
}
```

`session_id` names the session of your application. It starts with a letter or a digit, has only letters, digits, `-`, and `_`, and has at most 100 characters.

## What the manager does

-   **Puts the session context in the system prompt.** The text is the steering block and the digest of the mount. It goes in the cached part of the prompt, because it doesn’t change while the agent runs.
-   **Proves the mount.** A mount that isn’t ready, or a daemon that doesn’t answer, fails the start of the agent: `Agent(...)` in Python, `agent.initialize()` in TypeScript.
-   **Gives the agent the tools of `stash mcp`:** `search`, `status`, `save_note` with `[extraction]`, and `SOURCE__TOOL` for each source tool. It runs no search on each turn. The agent searches when it needs to.
-   **Writes each turn back** through the memory store, to each source with `write.trajectory`. Strands batches five asynchronous invocations by default. A synchronous Python invocation or agent shutdown flushes the remaining turns.
-   **Asks the agent for a note** when `[extraction]` makes one due, at the end of the next prompt.

The `read` tool opens the files that a search names. The agent process must be able to read the mount point.

## Optional settings

These are all optional constructor settings:

| Python | TypeScript | Default | Use it to |
| --- | --- | --- | --- |
| `mcp` | `mcp` | `True` | Turn off the MCP tools. The agent then needs a shell. See [Attachment modes](/docs/user-guide/stash/guides/attachment-modes/index.md). |
| `command` | `command` | `stash` | Run a `stash` that isn’t on `PATH`. |
| `max_search_results` | `maxSearchResults` | `5` | Limit results from `memory.store.search(...)`. |
| `max_content_bytes` | `maxContentBytes` | 64 KiB | Limit the content read for each result from `memory.store.search(...)`. |
| `timeout_seconds` | `timeoutMs` | 15 seconds | Allow more time for a Stash command to return. |
| `run_id` | `runId` | a random UUID | Keep write-back event IDs stable when the application retries one run. |
| `exclude_tool_blocks` | `excludeToolBlocks` | `False` | Write back only the words of each turn, with no tool calls. |

The manager refuses `stores`, `injection`, `add_tool_config` (`addToolConfig`), and `search_tool_config` (`searchToolConfig`). A Stash mount needs the values that the manager sets.

An application tool named `search`, `status`, `save_note`, or the name of a source tool, fails the start of the agent. Use `mcp=False` for such an application.

## Use the Strands Harness

The Strands Harness takes the same manager. Keep the harness defaults, and don’t pass `memory=False`:

### Python

Install the harness package in the same project:

```bash
pip install strands-harness
```

```python
from stash_strands import StrandsStash
from strands_harness import create_harness

memory = StrandsStash(
    config_path="stash.toml",
    session_id="inc-4412",
    mount_name="ops",
)
agent = create_harness(
    memory_manager=memory,
)

try:
    result = agent("Have we seen checkout latency like INC-4412 before?")
    print(result)
finally:
    agent.cleanup()
```

### TypeScript

Install the harness package in the same project:

```bash
npm install @strands-agents/harness
```

```typescript
import { createHarness } from '@strands-agents/harness'
import { StrandsStash } from '@strands-agents/stash-memory-manager'

const memory = new StrandsStash({
  configPath: 'stash.toml',
  sessionId: 'inc-4412',
  mountName: 'ops',
})
const agent = await createHarness({
  memoryManager: memory,
})

try {
  const result = await agent.invoke(
    'Have we seen checkout latency like INC-4412 before?',
  )
  console.log(result)
} finally {
  try {
    await agent.shutdown()
  } finally {
    await memory.disconnect()
  }
}
```

The tools of `stash mcp` replace the harness `search_memory` tool. The built-in tools stay, so the agent can `read` each file that a search names. The `subagent` delegate gets no mount. Give it what it needs in the words of the task.

## Check the write-back

The store returns when the local queue accepts a batch. The daemon sends it to AgentCore Memory in the background. List the events of the session:

```bash
aws bedrock-agentcore list-events \
  --memory-id ops-memory-0123456789 \
  --actor-id ops-agent \
  --session-id inc-4412 \
  --include-payloads
```

Each turn shows as `USER`, `ASSISTANT`, and `TOOL` events. If none show yet, wait a few seconds and list them again.

## Next steps

-   [Deploy on AgentCore Runtime](/docs/user-guide/stash/integrations/agentcore-runtime/index.md): run the agent and its mount in a Runtime session.
-   [Feedback loops](/docs/user-guide/stash/capabilities/feedback-loops/index.md): how turns become memory for the next session.