Skip to content

ContextManager

Defined in: src/context-manager/context-manager.ts:86

Manages context reduction for an agent’s conversation.

On context overflow, runs the strategy pipeline (offload, summarize, emergency truncate). The emergency truncation is always appended as the final strategy — it fires only if the window is still overflowing after the user strategies have run.

Configured through the Agent’s contextManager parameter — pass a preset string ('auto', or the experimental 'agentic'), a ContextManagerConfig, or a ContextManager instance; the Agent registers the manager. When present, it owns overflow recovery and proactive compression — no separate ConversationManager is needed.

new ContextManager(config?): ContextManager;

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

ParameterTypeDescription
config?ContextManagerConfigThe strategies and archive to use; the default pipeline when omitted

ContextManager

Error when the strategies hold more than one Offload.defer strategy, the deferredToolLoading preset included

readonly name: "strands:context-manager" = 'strands:context-manager';

Defined in: src/context-manager/context-manager.ts:87

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

get archive(): Archive;

Defined in: src/context-manager/context-manager.ts:224

The L1 archive instance, if archive is enabled and the agent has been initialized.

Archive

The archive, or undefined if archive is disabled or initAgent has not run


get archiveIsDurable(): boolean;

Defined in: src/context-manager/context-manager.ts:234

Whether the archive is backed by durable storage that survives process restarts. When true, archive data does not need to be embedded in session snapshots.

boolean

true if the archive storage is not ephemeral


get stash(): Archive;

Defined in: src/context-manager/context-manager.ts:242

Renamed to ContextManager.archive. Removed in the next minor.

Archive

The archive, or undefined if archive is disabled or initAgent has not run


get stashIsDurable(): boolean;

Defined in: src/context-manager/context-manager.ts:250

Renamed to ContextManager.archiveIsDurable. Removed in the next minor.

boolean

true if the archive storage is not ephemeral

static from(strategy): ContextManager;

Defined in: src/context-manager/context-manager.ts:120

Resolves a ContextManagerStrategy value into a ContextManager instance.

ParameterTypeDescription
strategyContextManagerStrategyA preset string, config object, ContextManager instance, false, or undefined

ContextManager

The instance as-is; a new ContextManager for preset strings and configs; undefined for false/undefined


getTools(): Tool[];

Defined in: src/context-manager/context-manager.ts:134

Returns tools provided by this plugin for auto-registration. Called after initAgent resolves; may depend on state set there.

Tool[]

Array of tools to register with the agent

Plugin.getTools


initAgent(agent): Promise<void>;

Defined in: src/context-manager/context-manager.ts:156

Initialize the plugin with the agent instance.

Implement this method to register hooks and perform custom initialization. Tool registration from getTools is handled automatically by the PluginRegistry.

ParameterTypeDescription
agentLocalAgentThe agent instance this plugin is being attached to

Promise<void>

Plugin.initAgent