Skip to content

SessionManager

Defined in: src/session/session-manager.ts:57

Manages session persistence for agents, enabling conversation state to be saved and restored across invocations using pluggable storage backends.

import { SessionManager, FileStorage } from '@strands-agents/sdk'
const session = new SessionManager({
sessionId: 'my-session',
storage: { snapshot: new FileStorage() },
})
const agent = new Agent({ sessionManager: session })
new SessionManager(config): SessionManager;

Defined in: src/session/session-manager.ts:70

ParameterType
configSessionManagerConfig

SessionManager

get name(): string;

Defined in: src/session/session-manager.ts:66

Unique identifier for this plugin.

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

Plugin.name

initAgent(agent): void;

Defined in: src/session/session-manager.ts:78

Initializes the plugin by registering lifecycle hook callbacks.

ParameterType
agentAgentData

void

Plugin.initAgent


saveSnapshot(params): Promise<void>;

Defined in: src/session/session-manager.ts:101

ParameterType
params{ target: Agent; isLatest: boolean; }
params.targetAgent
params.isLatestboolean

Promise<void>


deleteSession(): Promise<void>;

Defined in: src/session/session-manager.ts:113

Deletes all snapshots and manifests for this session from storage.

Promise<void>


restoreSnapshot(params): Promise<boolean>;

Defined in: src/session/session-manager.ts:118

Loads a snapshot from storage and restores it into the target agent. Returns false if no snapshot exists.

ParameterType
params{ target: Agent; snapshotId?: string; }
params.targetAgent
params.snapshotId?string

Promise<boolean>