Skip to content

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.

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

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:

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.

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

Terminal window
pip install strands-stash-memory-manager
Terminal window
npm install @strands-agents/stash-memory-manager

Pin the package version in your application dependency file.

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

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.

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.

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

These are all optional constructor settings:

PythonTypeScriptDefaultUse it to
mcpmcpTrueTurn off the MCP tools. The agent then needs a shell. See Attachment modes.
commandcommandstashRun a stash that isn’t on PATH.
max_search_resultsmaxSearchResults5Limit results from memory.store.search(...).
max_content_bytesmaxContentBytes64 KiBLimit the content read for each result from memory.store.search(...).
timeout_secondstimeoutMs15 secondsAllow more time for a Stash command to return.
run_idrunIda random UUIDKeep write-back event IDs stable when the application retries one run.
exclude_tool_blocksexcludeToolBlocksFalseWrite 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.

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

Install the harness package in the same project:

Terminal window
pip install strands-harness
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()

Install the harness package in the same project:

Terminal window
npm install @strands-agents/harness
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.

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:

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