SessionManager
Defined in: src/session/session-manager.ts:81
Manages session persistence for agents, enabling conversation state to be saved and restored across invocations using pluggable storage backends.
Also supports multi-agent orchestrators (Graph, Swarm) via the MultiAgentPlugin interface. Scope is auto-detected based on whether initAgent or initMultiAgent is called.
Example
Section titled “Example”import { SessionManager, FileStorage } from '@strands-agents/sdk'
const session = new SessionManager({ sessionId: 'my-session', storage: { snapshot: new FileStorage() },})const agent = new Agent({ sessionManager: session })Implements
Section titled “Implements”PluginMultiAgentPlugin
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SessionManager(config): SessionManager;Defined in: src/session/session-manager.ts:96
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | SessionManagerConfig |
Returns
Section titled “Returns”SessionManager
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get name(): string;Defined in: src/session/session-manager.ts:92
Unique identifier for this plugin.
Returns
Section titled “Returns”string
A stable string identifier for the plugin. Used for logging, duplicate detection, and plugin management.
For strands-vended plugins, names should be prefixed with strands:.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”initAgent()
Section titled “initAgent()”initAgent(agent): void;Defined in: src/session/session-manager.ts:105
Initializes the plugin by registering lifecycle hook callbacks.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
agent | LocalAgent |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”saveSnapshot()
Section titled “saveSnapshot()”Call Signature
Section titled “Call Signature”saveSnapshot(params): Promise<void>;Defined in: src/session/session-manager.ts:129
Saves a snapshot of the target’s current state.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { target: LocalAgent; isLatest: boolean; } |
params.target | LocalAgent |
params.isLatest | boolean |
Returns
Section titled “Returns”Promise<void>
Call Signature
Section titled “Call Signature”saveSnapshot(params): Promise<void>;Defined in: src/session/session-manager.ts:130
Saves a snapshot of the target’s current state.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { target: Graph | Swarm; state?: MultiAgentState; isLatest: boolean; } |
params.target | Graph | Swarm |
params.state? | MultiAgentState |
params.isLatest | boolean |
Returns
Section titled “Returns”Promise<void>
deleteSession()
Section titled “deleteSession()”deleteSession(): Promise<void>;Defined in: src/session/session-manager.ts:148
Deletes all snapshots and manifests for this session from storage.
Returns
Section titled “Returns”Promise<void>
restoreSnapshot()
Section titled “restoreSnapshot()”Call Signature
Section titled “Call Signature”restoreSnapshot(params): Promise<boolean>;Defined in: src/session/session-manager.ts:153
Loads a snapshot from storage and restores it into the target. Returns false if no snapshot exists.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { target: LocalAgent; snapshotId?: string; } |
params.target | LocalAgent |
params.snapshotId? | string |
Returns
Section titled “Returns”Promise<boolean>
Call Signature
Section titled “Call Signature”restoreSnapshot(params): Promise<boolean>;Defined in: src/session/session-manager.ts:154
Loads a snapshot from storage and restores it into the target. Returns false if no snapshot exists.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { target: Graph | Swarm; state?: MultiAgentState; snapshotId?: string; } |
params.target | Graph | Swarm |
params.state? | MultiAgentState |
params.snapshotId? | string |
Returns
Section titled “Returns”Promise<boolean>
initMultiAgent()
Section titled “initMultiAgent()”initMultiAgent(orchestrator): void;Defined in: src/session/session-manager.ts:241
Initializes the multi-agent plugin by registering orchestrator lifecycle hooks.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
orchestrator | MultiAgent |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”MultiAgentPlugin.initMultiAgent