Skip to content
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
40932f6
docs(session): add migration guide from message-log managers to Snaps…
Oct 1, 2026
765b2d3
docs(session): emphasize why to migrate and what to watch when portin…
Oct 2, 2026
8bc5666
docs(session): drop the Looking ahead note from the migration guide
Oct 2, 2026
e828392
docs(session): reframe the constructor swap as a valid choice, not a …
Oct 2, 2026
4f0dbd6
docs(session): make the before/after swap snippet parallel
Oct 2, 2026
b2d513c
docs(session): tighten the migration guide to reference-doc register
Oct 2, 2026
b5c83ba
docs(session): fold verify/cut-over into the running-the-migration list
Oct 2, 2026
92955a4
docs(session): add the why-migrate rationale and clarify the snapshot…
Oct 2, 2026
02f8286
docs: reframe session manager guidance to recommend SnapshotSessionMa…
Oct 2, 2026
8af9e08
docs: flag the migration reference script as a minimal, extend-for-co…
Oct 2, 2026
a4cf4ef
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 2, 2026
6b66a79
docs: clarify multi-agent migration limitations
Oct 5, 2026
63724bd
Apply suggestion from @strandly-the-agent
nicolas-m-romero Oct 5, 2026
8513a67
docs: clarify legacy migration source mutations
Oct 5, 2026
62e8856
docs: separate prompt and model migration guidance
Oct 5, 2026
0f1df60
docs: document Bidi restart snapshots
Oct 5, 2026
09a9059
Update site/src/content/docs/user-guide/sdk/agents/session-management…
nicolas-m-romero Oct 5, 2026
cfb79d9
docs: define migration prompt placeholder
Oct 5, 2026
54a4911
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 5, 2026
69472f9
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 6, 2026
7630259
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 7, 2026
72d16cc
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 13, 2026
ba12ce3
docs: remove em dashes from session migration guide
Oct 13, 2026
44fcbe4
docs: align migration section on repository-based terminology
Oct 13, 2026
84d7d0d
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 13, 2026
8b352b7
docs(session): separate repository migration guide
Oct 20, 2026
a6a3473
feat(session): deprecate repository-based managers
Oct 20, 2026
46d6bf5
docs(session): retain deprecated manager guidance
Oct 21, 2026
908293a
Merge remote-tracking branch 'origin/main' into agent-tasks/3663-sess…
Oct 21, 2026
9bed83f
fix(session): avoid deprecation warning on subclassing
Oct 27, 2026
b83cb01
feat(session): deprecate session repository interface
Oct 27, 2026
c14ac88
docs(session): use sdk deprecation docstring style
Oct 27, 2026
c94325f
docs(session): link migration guide from api docs
Oct 27, 2026
b38544d
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 28, 2026
ccf0cea
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 28, 2026
d4d5ea3
Merge remote-tracking branch 'origin/main' into agent-tasks/3663-sess…
Oct 29, 2026
901bd78
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Oct 30, 2026
e3ae8b6
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Nov 2, 2026
ee7c40b
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Nov 2, 2026
27afc23
docs(session): accept stateful-model sessions in migration guard
Nov 2, 2026
08a641e
docs: steer remaining examples to SnapshotSessionManager
Nov 2, 2026
a8a2785
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Nov 3, 2026
fcd85ab
docs(session): check migrated data through take_snapshot in guard
Nov 4, 2026
b4b5e69
test(site): expect migration guide in Sessions sidebar group
Nov 4, 2026
d8787c1
docs(session): scope the migration script to one session at a time
Nov 4, 2026
a9e7178
test(session): ignore deprecation warning in storage nudge test
Nov 5, 2026
a15da16
docs(session): clarify what the already-migrated error means
Nov 5, 2026
71d5edf
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Nov 5, 2026
2b5fe1e
docs(session): keep agents stopped until cutover and clarify step 2
Nov 5, 2026
7811ffd
Merge branch 'main' into agent-tasks/3663-session-migration-guide
nicolas-m-romero Nov 5, 2026
7b9ced7
docs: fix LangGraph highlights, course notice, and SessionManager note
Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions site/src/config/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ sidebar:
items:
- label: "Persist state across sessions"
slug: docs/user-guide/sdk/agents/session-management
- label: "Migrate repository-based sessions"
Comment thread
nicolas-m-romero marked this conversation as resolved.
Resolved
slug: docs/user-guide/sdk/agents/migrate-repository-sessions
- label: Memory
items:
- label: "Overview"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
---
title: Migrate repository-based sessions
description: "Migrate Python sessions from RepositorySessionManager,
FileSessionManager, or S3SessionManager to SnapshotSessionManager before v2.0.0."
languages: [python]
tags: [session-management, snapshots, state]
sourceLinks:
- path: strands-py/src/strands/session/repository_session_manager.py
- path: strands-py/src/strands/session/file_session_manager.py
- path: strands-py/src/strands/session/s3_session_manager.py
- path: strands-py/src/strands/session/snapshot_session_manager.py
- path: strands-py/src/strands/types/session.py
---

The repository-based session managers are deprecated and will be removed in v2.0.0.
Use this guide to preserve existing session data when moving `RepositorySessionManager`,
`FileSessionManager`, or `S3SessionManager` sessions to `SnapshotSessionManager`.

For an overview of session persistence and snapshot behavior, see
[Session management](./session-management.mdx).

## Decide whether to migrate

`SnapshotSessionManager` cannot read repository-format records. Reusing the same session
and agent IDs starts an empty snapshot session and leaves the source records unchanged.

If you do not need the existing data, start a new snapshot-backed session. To preserve the
data, restore each repository-format session through a live agent, then save the restored
state with `SnapshotSessionManager`.

## Customize the procedure

Match the migrating agent to the production agent before restoring its state:

- **Storage**: Configure the repository-based source and snapshot target. The example
reads local records with `FileSessionManager` and writes to `LocalFileStorage`. For an
S3 source, use `S3SessionManager` and `S3Storage`. For a custom source, construct the
same `SessionRepository` implementation used by the application.
- **Identifiers**: Use the same `session_id` and `agent_id` for the source and target.
Migrate each agent ID in a session separately.
- **Conversation manager**: Use the same type and settings so the restored message offset
and compaction behavior match the production agent.
- **System prompt**: Pass the production system prompt. Repository-based managers do not
restore it, but the new snapshot records it.
- **Model and tools**: Recreate the production model, tools, and custom components that
affect agent initialization or restored behavior.

## Review what restoration preserves

Attaching the repository-based manager to the temporary agent restores the persisted data
before the snapshot is created. This includes application state, conversation-manager
state, interrupt state, model state, and message history.

The restore also applies saved redactions and repairs incomplete tool-use pairs in the
history. A trailing orphan is repaired when the agent receives its next prompt. For a
stateful model, the manager restores model state instead of local messages because the
model provider manages conversation history server-side.

## Protect existing data

Complete these checks before constructing a repository-based manager or writing a
snapshot:

- Validate every source `session_id` and `agent_id`. Repository-based managers create
empty records for unknown identifiers, so a typo changes the source store.
- Run the migration offline against a copy of the session store first. Do not race a live
agent that uses the same session.
- Stop if the target snapshot already exists. Keep the source records until you verify
that the snapshot restores correctly.

## Migrate one local session

Attach the repository-based manager to a temporary agent, then capture the restored agent
with the snapshot manager.

:::caution
The script can complete even when its configuration does not match the production agent.
Complete the customization and data-protection checks above before running it.
:::

```python
import asyncio

from strands import Agent
from strands.session import FileSessionManager, SnapshotSessionManager
from strands.storage import LocalFileStorage

SYSTEM_PROMPT = "<your production system prompt>"


async def migrate_session(session_id: str, *, agent_id: str = "default") -> None:
"""Migrate one repository-format session without overwriting the target."""
snapshot = SnapshotSessionManager(
session_id=session_id,
storage=LocalFileStorage("./snapshot-sessions"),
)

# Stop rather than overwrite an existing target snapshot.
if await snapshot.restore_snapshot(Agent(agent_id=agent_id)):
raise RuntimeError(
f"session={session_id!r} agent={agent_id!r} already migrated"
)
Comment thread
nicolas-m-romero marked this conversation as resolved.
Resolved

# Restore conversation-manager state, redactions, and message-history repairs.
source = FileSessionManager(
session_id=session_id,
storage_dir="./repository-sessions",
)
agent = Agent(
agent_id=agent_id,
system_prompt=SYSTEM_PROMPT,
session_manager=source,
)

if not agent.messages and not agent.state.get():
Comment thread
nicolas-m-romero marked this conversation as resolved.
Resolved
raise ValueError(
f"no source data found for session={session_id!r} agent={agent_id!r}"
)

# Write the snapshot restored during agent initialization.
await snapshot.save_snapshot(agent, is_latest=True)


asyncio.run(migrate_session("user-123"))
```

Save the script as `migrate_repository_session.py`, update its configuration, then run:

```bash
python migrate_repository_session.py
```

## Migrate and verify each session

- **Get the source session ID** from the existing agent or session manager. See
[Reading the session ID](./session-management.mdx#reading-the-session-id).
- **Migrate many sessions** by calling `migrate_session` per session and per `agent_id`.
Keep each call independent and idempotent so an interrupted run can resume.
- **Verify, then cut over:**
1. Dry-run against a copy of the session store.
2. Attach `SnapshotSessionManager` to a fresh agent with the same `session_id` and
`agent_id`. Compare `agent.messages`, `agent.state.get()`, `agent.system_prompt`, and
the conversation-manager state.
3. Cut application code over to `SnapshotSessionManager`.
4. Delete the source records only after verifying that the snapshot restores correctly.

## Adapt unsupported session types

The single-agent `migrate_session()` example does not work for Graph or Swarm sessions.
It passes an `Agent` to `save_snapshot()`, while Graph and Swarm persistence captures the
orchestrator through its lifecycle hooks. There is no public one-shot conversion API.
Start a new snapshot-backed multi-agent session before v2.0.0. If you must preserve an
in-progress orchestrator state, remain on v1 and its repository-based manager until a
dedicated migration path is available.

`BidiAgent` requires a separate adaptation. Construct the equivalent stopped `BidiAgent`
and preserve its streaming configuration before calling `save_snapshot()`. After cutover,
`SnapshotSessionManager` saves Bidi state after each message by default, when the agent
stops, and before a connection restart. Configure this behavior with
`bidi_agent_save_latest_on`.
Loading
Loading