- The paper introduces a novel observation compression method that preserves next-action fidelity while reducing cumulative token consumption.
- It employs a candidate generation and reward filtering pipeline to balance token reduction and action preservation, leading to improved task success.
- Experimental results demonstrate a 33% token reduction and enhanced pass@1 rates compared to prior techniques, validating the method's efficiency-effectiveness trade-off.
CoACT: Action-Preserving Observation Compression for Coding Agents
Introduction and Problem Context
LLM-based coding agents have demonstrated robust performance across software engineering tasks via iterative interaction with development environments. At each interaction step, the agent emits an action and observes some feedback from the environment. Prior work shows that, over long horizons, the accumulation of token-heavy observations becomes the principal contributor to inference cost, largely constraining scalability for real-world deployments. Existing observation compression protocols, while alleviating some token consumption, typically fail to maintain a satisfactory balance between computational efficiency and downstream task effectiveness. This is principally due to the absence of an explicit mechanism for ensuring that compressed observations do not perturb agent behavior in a way that degrades ultimate task success.
CoACT Methodology
The paper introduces CoACT, a method for observation compression that explicitly enforces an action-preserving constraint. The core proposition is that the next action an agent predicts following an observation is a strong, tractable proxy for downstream effectiveness. CoACT's central technical contribution is the design and deployment of a compression pipeline that systematically produces compressed observation candidates and filters them to retain only those that leave the agent's immediate next action invariant with high probability—a property termed Next-Action Preservation (NAP).
Figure 1: CoACT pipeline overview, encompassing candidate generation, action-preservation filtering, and reward-guided compressor training. The approach integrates offline bootstrap and online alignment phases for compressor optimization.
CoACT models the efficiency–effectiveness trade-off as a constrained optimization problem: minimizing cumulative token count subjected to a strict action-equivalence constraint at each interaction. Practically, this is realized as follows:
- Candidate Generation: For each raw observation, a teacher model generates a diverse set of compression candidates.
- Action-Preservation Reward Filtering: Each candidate replaces the original observation, and the agent’s subsequent action prediction is compared to that under the uncompressed observation. Candidates are retained if their induced action is sufficiently similar (as defined by a robust action-similarity function) to the baseline action, thresholded to capture only operationally equivalent decisions.
- Length-Reduction Reward: Among action-preserving candidates, preference is given to those that offer maximal token savings.
- Compressor Training: These filtered, high-reward candidates are then used as supervision for supervised fine-tuning of a lightweight observation compressor. Training proceeds via offline bootstrap (from uncompressed agent trajectories) and online alignment (from compressed trajectories), enabling adaptation to the real distribution observed during agent deployment.
Experimental Setup and Evaluation
Extensive experiments are conducted on the SWE-bench Verified benchmark using three strong agentic models: Qwen3.5-35B-A3B, Deepseek-v4-Pro, and Gemini3-Flash. CoACT compressors are initialized with Qwen3.5-4B, and agent interactions are scaffolded with mini-swe-agent, ensuring a uniform interface of bash command actions and shell output observations.
Key evaluation metrics include:
- Total Token Consumption: Aggregated over cached/uncached inputs and outputs.
- Task Success (\texttt{pass@1}): Fraction of benchmarks solved.
- Steps & Solved-Steps: Interaction efficiency.
Further analyses evaluate the impact on observation length distributions and stepwise token usage.
Figure 2: Distributional shift in observation token counts before and after CoACT. Rightward truncation demonstrates the selective compression of lengthy observations by CoACT.
Figure 3: Per-trajectory step counts (task horizon) are not increased by CoACT compression, indicating no recovery penalty for aggressive context shortening.
Results
Efficiency-Effectiveness Trade-off
CoACT achieves a 33% reduction in total token usage across agentic models (Qwen3.5-35B-A3B: 3.795M→2.428M; Deepseek-v4-Pro: 1.068M→0.868M; Gemini3-Flash: 0.685M→0.422M) while maintaining or even surpassing baseline \texttt{pass@1} values (e.g., an increase from 57.0%→60.5% for Qwen3.5-35B-A3B), with no significant increase in agent interaction steps.
Baseline Comparison
CoACT consistently dominates prior observation compression techniques (LLMLingua-2, LongCodeZip, SWE-Pruner), delivering the best observed token–effectiveness Pareto frontier. Competing methods either:
- Aggressively compress (LLMLingua-2) at the cost of substantial effectiveness decline,
- Fail to fully exploit compressibility (LongCodeZip),
- Or induce unnecessary recovery steps (SWE-Pruner).
CoACT optimizes both dimensions, reducing token cost without triggering agent recovery loops or reruns, as evidenced by similar or improved step distributions compared to uncompressed baselines.
Integration with Trajectory Compression
When paired with trajectory-level context compressors (e.g., AgentDiet, Sliding Window), CoACT is orthogonal and complementary. The combined stack further trims token budgets and operational cost (e.g., 45.65→25.88 USD per task for AgentDiet+CoACT), with no effectiveness loss, highlighting the practical utility of pre-context observation filtering prior to bulk trajectory trimming.
Ablation and Reward Study
Ablations confirm that both the action-preservation reward (NAP constraint) and the length-reduction reward are crucial: removing either yields compressors that either hurt agent performance (lose next-action fidelity) or under-exploit compressibility (retain redundant tokens).
Generalization
- Teacher Model Dependence: Compressors trained via different teacher models exhibit robust cross-model transfer, with only moderate sensitivity to teacher choice.
- Agent Model Transfer: Compressors trained on one agent model's trajectories generalize effectively to others, reducing the need for expensive model-specific data collection.
Theoretical and Practical Implications
Theoretically, CoACT provides a tractable, step-wise proxy (NAP) for constraining downstream agent effectiveness—a solution to the sparsity and computational expense inherent in optimizing end-to-end task metrics over long agent horizons. This reframes observation compression as not only a text distillation problem but a functional policy-preserving transformation.
Practically, CoACT's action-preserving compressors can be integrated into emergent agent stacks for code automation, autonomously maximizing inference performance without requiring hand-tuned rules or expensive rollout-based validation. The pipeline preserves architectural modularity: the agent’s policy, environmental interface, and tool set are left untouched.
Looking forward, the NAP-reward-guided approach can be extended to other LLM agents beyond code (e.g., general autonomous agents operating in complex toolchains), and the teacher–student framework can incorporate multi-teacher or self-distillation variants for broader robustness. Further work may examine theoretical guarantees of NAP's sufficiency for more general long-horizon tasks or richer policy spaces.
Conclusion
CoACT demonstrates that principled, reward-guided observation compression with explicit next-action preservation enables a fundamentally better efficiency–effectiveness trade-off than prior heuristic or general-purpose approaches. The approach substantially reduces inference demands for LLM-based coding agents, maintains or improves task-solving ability, and can be deployed orthogonally with existing trajectory compression schemes. As agent applications continue to scale, such action-preserving context management will be essential for practical, cost-effective long-horizon agent deployments.