Self-GC: Self-Governing Context for Long-Horizon LLM Agents
06:00 · July 2, 2026 · arXiv cs.AI RSS

Long-horizon LLM agents accumulate tool results, files, plans, and user constraints that are too structured to be treated as a disposable text suffix. Current systems mostly rely on in-run heuristics such as chronological pruning and tool-output masking, or on final self-summary near a context limit. Heuristics are cheap but blind to future dependencies; summaries preserve narrative state but often hide exact evidence, locators, and editable artifacts. We present Self-GC, where GC denotes self-governing context while deliberately echoing garbage collection: the system does not merely reclaim unused tokens, but governs the lifecycle of agent context objects. Self-GC turns user turns, tool spans, and skill state into indexed objects; asks a side-channel planner to propose fold, mask, and prune actions; and lets the harness enforce recoverable sidecars, safe commit boundaries, and cache-aware commit. On a 33-session Hard Set, Self-GC prunes 43.95% of prefix tokens while leaving 84.85% of future continuations unaffected, compared with no-impact rates of 54.55% to 69.70% for heuristic baselines. On a 332-session production-derived suite, three planner backbones reach no-impact rates of 91.27% to 94.58%, while baselines remain at 77.71% to 87.46%. In production, an online account-level split reduces daytime average input tokens by 10% to 15%, with peak reductions near 20%. These results point to context management as runtime lifecycle control over indexed, recoverable objects rather than post hoc text cleanup.
Summary
Self-GC reframes context management for long-horizon LLM agents by treating accumulated elements—user turns, tool outputs, files, plans, and skill state—as indexed runtime objects rather than a linear token buffer. Unlike conventional heuristics that prune by age or length, or late-stage summarization that collapses evidence into non-recoverable prose, the system maps these elements to stable identifiers and delegates decisions about their future utility to a side-channel planner. The planner proposes fold, mask, or prune operations, while a lightweight harness validates targets, maintains safe commit boundaries, stores folded payloads in recoverable sidecars, and avoids commits that would disrupt prefix caching.
Evaluations on a 33-session Hard Set show the approach pruning 43.95 percent of prefix tokens while leaving 84.85 percent of future continuations unaffected, outperforming heuristic baselines whose no-impact rates range from 54.55 to 69.70 percent. On a larger 332-session production-derived suite, three different planner backbones achieve no-impact rates between 91.27 and 94.58 percent, compared with 77.71 to 87.46 percent for the same baselines. In live deployment, an account-level rollout reduced daytime average input tokens by 10 to 15 percent, with peaks near 20 percent on covered traffic.
The design deliberately echoes garbage collection: rather than simple reclamation, Self-GC governs object lifecycles through explicit recoverability and dependency awareness. This separation lets the model supply semantic judgment while the harness preserves protocol invariants, offering a portable layer that integrates with existing agent harnesses via a modest context-engine hook.
Why it matters
This research provides a highly technical and novel solution to context window limitations and token costs in LLM agents. For Dutch AI researchers and enterprises, implementing such lifecycle control mechanisms can significantly optimize the scalability and cost-efficiency of autonomous AI deployments.




