Agentic.Loop.Stages.ContextGuard
(agentic v0.2.2)
Copy Markdown
Checks context window usage and triggers compaction if needed.
Runs before LLMCall. Estimates the current context size from messages and tool schemas. When usage exceeds the configured threshold (default 80%), compacts older messages by summarizing them with a deterministic summary, then replaces them with a compact handoff message.
Also enforces a per-session cost limit as a safety rail.