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.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ContextManager(config?): ContextManager;Defined in: src/context-manager/context-manager.ts:101
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
config? | ContextManagerConfig | The strategies and archive to use; the default pipeline when omitted |
Returns
Section titled “Returns”ContextManager
Throws
Section titled “Throws”Error when the strategies hold more than one Offload.defer strategy, the deferredToolLoading preset
included
Properties
Section titled “Properties”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:.
Implementation of
Section titled “Implementation of”Accessors
Section titled “Accessors”archive
Section titled “archive”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”Archive
The archive, or undefined if archive is disabled or initAgent has not run
archiveIsDurable
Section titled “archiveIsDurable”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”boolean
true if the archive storage is not ephemeral
Get Signature
Section titled “Get Signature”get stash(): Archive;Defined in: src/context-manager/context-manager.ts:242
Deprecated
Section titled “Deprecated”Renamed to ContextManager.archive. Removed in the next minor.
Returns
Section titled “Returns”Archive
The archive, or undefined if archive is disabled or initAgent has not run
stashIsDurable
Section titled “stashIsDurable”Get Signature
Section titled “Get Signature”get stashIsDurable(): boolean;Defined in: src/context-manager/context-manager.ts:250
Deprecated
Section titled “Deprecated”Renamed to ContextManager.archiveIsDurable. Removed in the next minor.
Returns
Section titled “Returns”boolean
true if the archive storage is not ephemeral
Methods
Section titled “Methods”from()
Section titled “from()”static from(strategy): ContextManager;Defined in: src/context-manager/context-manager.ts:120
Resolves a ContextManagerStrategy value into a ContextManager instance.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
strategy | ContextManagerStrategy | A preset string, config object, ContextManager instance, false, or undefined |
Returns
Section titled “Returns”ContextManager
The instance as-is; a new ContextManager for preset strings and configs; undefined for false/undefined
getTools()
Section titled “getTools()”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.
Returns
Section titled “Returns”Tool[]
Array of tools to register with the agent
Implementation of
Section titled “Implementation of”initAgent()
Section titled “initAgent()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
agent | LocalAgent | The agent instance this plugin is being attached to |
Returns
Section titled “Returns”Promise<void>