SessionManager
Defined in: src/session/session-manager.ts:56
Manages session persistence for agents, enabling conversation state to be saved and restored across invocations using pluggable storage backends.
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”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SessionManager(config): SessionManager;Defined in: src/session/session-manager.ts:62
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | SessionManagerConfig |
Returns
Section titled “Returns”SessionManager
Methods
Section titled “Methods”registerCallbacks()
Section titled “registerCallbacks()”registerCallbacks(registry): void;Defined in: src/session/session-manager.ts:70
Registers lifecycle hook callbacks on the provided registry.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
registry | HookRegistry |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”HookProvider.registerCallbacks
saveSnapshot()
Section titled “saveSnapshot()”saveSnapshot(params): Promise<void>;Defined in: src/session/session-manager.ts:88
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { target: Agent; isLatest: boolean; } |
params.target | Agent |
params.isLatest | boolean |
Returns
Section titled “Returns”Promise<void>
restoreSnapshot()
Section titled “restoreSnapshot()”restoreSnapshot(params): Promise<boolean>;Defined in: src/session/session-manager.ts:100
Loads a snapshot from storage and restores it into the target agent. Returns false if no snapshot exists.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { target: Agent; snapshotId?: string; } |
params.target | Agent |
params.snapshotId? | string |
Returns
Section titled “Returns”Promise<boolean>