Autonomous Trajectory Context Eviction (ATCE): Halving Agent Token Costs
Autonomous AI coding agents (such as Claude Code, OpenHands, AutoGen, and Grok 2) generate thousands of context tokens on every single interaction. As an agent inspects git logs, runs test suites, and lints codebases, the intermediate outputs from early turns remain frozen in the conversational trajectory, inflating model context quadratically.
The Mechanics of Quadratic Token Waste
In a standard 10-turn coding task, Turn 1 might execute git log -n 50, adding 2,000 tokens of raw commit history. On Turn 2, Turn 3, and all subsequent turns through Turn 10, those exact same 2,000 tokens are resent to the model over and over again, despite the fact that the agent has already extracted the commit hash and moved on.
Total Tokens Billed = N * System_Prompt + Sum_{i=1}^N (N - i + 1) * Tool_Output_i
For an agent running 10 turns with 1,500 tokens of intermediate tool output per turn, the developer is billed for over 82,500 cumulative tokens instead of the necessary 15,000 tokens.
How Autonomous Trajectory Context Eviction (ATCE) Solves It
Bartholomew ATCE operates as an in-flight transparent tollbooth proxy between the agent and the LLM provider (OpenAI, Anthropic, or xAI Grok). Rather than requiring developers to rewrite agent frameworks, the proxy evaluates the conversational messages in RAM:
- Preserves System Invariants: The root system instructions and repository rules are kept 100% intact.
- Sliding-Window Recency: The most recent 2 tool execution turns remain uncompressed so the model has immediate local context.
- AST Compaction of Stale Turns: Older tool dumps (from turns 1 through N-2) are atomically folded into structured AST summaries indicating the command executed, the exit code, and key extracted symbols.
Empirical Benchmark Results
In rigorous multi-turn benchmark suites across realistic coding tasks, ATCE demonstrated:
- 51.2% Net Reduction in Token Burn: Slashing simulated 8-turn trajectories from 656 tokens down to 321 tokens.
- Sub-20 Microsecond RAM Overhead: Invariant evaluation and AST compaction complete in 14.75 microseconds.
- Zero Degradation in Benchmark Accuracy: Because exit codes and key AST nodes are preserved, agents complete complex multi-turn refactors with identical pass rates.