CAPYBALA: Context-Aware Pruning for Yielding and Backtrack-Aligned Loop Avoidance in Autonomous Software Engineering Agents

Abstract Autonomous software engineering agents frequently become entrapped in catastrophic error loops and cognitive deadlocks, burning millions of tokens while executing repetitive failing tool invocations. Existing self-reflection frameworks exacerbate token exhaustion by appending redundant verbal history to the context window, while naive context truncation routinely violates protocol invariants between tool calls and execution responses. We introduce CAPYBALA (Context-Aware Pruning for Yielding and Backtrack-Aligned Loop Avoidance), an in-memory runtime supervisor that tracks agent trajectory dynamics via a signed feature-hashed phase-space manifold (O(1) space complexity, sub-millisecond execution latency) and performs atomic context pruning with formal protocol pairing guarantees (N_tool_call = N_tool_response). Evaluated across an offline trajectory replay benchmark of 200 real-world SWE-bench agent runs and 3,209 execution turns from the open Nebius SWE-agent trajectory corpus, alongside live head-to-head coding duels on active commercial foundation models, CAPYBALA captures deadlocks with 86.00% to 97.86% recall, 95.56% to 98.56% precision (with 96.00% to 96.67% clean specificity), eliminates an aggregate 42.8% of wasted tokens (1,017,250 tokens across 200 trajectories, saving 59.74% of non-productive turns across stuck trajectories and 40.3% to 47.1% in live coding duels), and maintains a sub-millisecond mean decision latency (0.641 ms mean supervisor turn, p50 = 0.546 ms; 53 μs raw feature extraction, p50 = 38 μs; p99 = 5.84 ms tail) without requiring model fine-tuning or secondary embedding inference.

Authors

Publication Details

Journal
Research Square
Published
2026-11-03
DOI
https://doi.org/10.21203/rs.3.rs-11597011/v1
Primary Topic
Software Engineering Research
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
preprint

CAPYBALA: Context-Aware Pruning for Yielding and Backtrack-Aligned Loop Avoidance in Autonomous Software Engineering Agents

Khairan Noor Fadhlillah
Research Square
Software Engineering Research
preprint

CAPYBALA: Context-Aware Pruning for Yielding and Backtrack-Aligned Loop Avoidance in Autonomous Software Engineering Agents

Khairan Noor Fadhlillah
preprint en

Abstract

Abstract Autonomous software engineering agents frequently become entrapped in catastrophic error loops and cognitive deadlocks, burning millions of tokens while executing repetitive failing tool invocations. Existing self-reflection frameworks exacerbate token exhaustion by appending redundant verbal history to the context window, while naive context truncation routinely violates protocol invariants between tool calls and execution responses. We introduce CAPYBALA (Context-Aware Pruning for Yielding and Backtrack-Aligned Loop Avoidance), an in-memory runtime supervisor that tracks agent trajectory dynamics via a signed feature-hashed phase-space manifold (O(1) space complexity, sub-millisecond execution latency) and performs atomic context pruning with formal protocol pairing guarantees (N_tool_call = N_tool_response). Evaluated across an offline trajectory replay benchmark of 200 real-world SWE-bench agent runs and 3,209 execution turns from the open Nebius SWE-agent trajectory corpus, alongside live head-to-head coding duels on active commercial foundation models, CAPYBALA captures deadlocks with 86.00% to 97.86% recall, 95.56% to 98.56% precision (with 96.00% to 96.67% clean specificity), eliminates an aggregate 42.8% of wasted tokens (1,017,250 tokens across 200 trajectories, saving 59.74% of non-productive turns across stuck trajectories and 40.3% to 47.1% in live coding duels), and maintains a sub-millisecond mean decision latency (0.641 ms mean supervisor turn, p50 = 0.546 ms; 53 μs raw feature extraction, p50 = 38 μs; p99 = 5.84 ms tail) without requiring model fine-tuning or secondary embedding inference.

Research Square
Software Engineering Research
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon