Skip to main content

ContextManager

Defined in the manager module.
AI Agent Unified facade for context management. Orchestrates budgeting, composition, optimization, and monitoring. Provides hooks for exact LLM boundary snapshots. Tracks optimization history for debugging.

Constructor

str
default:"'gpt-4o-mini'"
No description available.
Optional[ManagerConfig]
No description available.
str
default:"''"
No description available.
str
default:"''"
No description available.
Optional[SessionDeduplicationCache]
No description available.
Optional[Callable]
No description available.

Methods

process()

Process messages through the context pipeline.

capture_llm_boundary()

Capture exact state at LLM call boundary.

register_snapshot_callback()

Register a callback for LLM boundary snapshots.

get_last_snapshot_hook()

Get the last LLM boundary snapshot.

estimate_tokens()

Estimate tokens with optional validation.

get_tool_budget()

Get token budget for a specific tool.

set_tool_budget()

Set token budget for a specific tool.

truncate_tool_output()

Truncate tool output according to its budget.

get_history()

Get optimization history.

get_stats()

Get current context statistics.

emergency_truncate()

Emergency truncation when optimization isn’t enough.

get_resolved_config()

Get the fully resolved configuration with source info.

reset()

Reset manager state.

Usage

Source

View on GitHub

praisonaiagents/context/manager.py at line 225

Context Concept

Context Management

Context Strategies