Context Window Discipline & KV-Cache Optimization
Preventing transcript token compounding in autonomous agent tool loops.
1. The Token Multiplier Law
Every tool call in an agentic loop re-sends the entire preceding transcript. A session with 60 tool calls and an average output size of 15 KB does not consume 900 KB of input tokens — it consumes over 5.4 Million input tokens due to compounding history accumulation.
2. Bounded Output Piping (`cap-tool`)
Never allow raw commands to print unbounded output directly into stdout. Pipe all heavy commands through bounded head wrappers that save full logs to disk while returning only high-signal summary lines to the context window.
3. Subagent Task Isolation
Delegate deep exploratory tasks to dedicated subagents. The subagent processes thousands of tokens in its own isolated context and returns only a compact 5-line summary to the main coordinator.
Upgrade Your Agent Architecture
Deploy our Relational Prompt & Agent Memory OS directly to Notion.
Get Instant 1-Click Notion Duplicate ($29)