Manuscript Offprint

arXiv:2611.12122

System Optimizations for Cost-Efficient Agent Harnesses

Jongseok Park, Jiaxiang Yu, Eric Zhou, Tony Hong, Sunga Kim, Yusuf Afifi, Ian Wong, Ion Stoica, Alvin Cheung

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

AI agent harnesses play the critical role of providing LLMs with an interface to a computing environment. Recent studies show that AI agents' task-execution accuracy depends mostly on the LLM used, while harness-side variances such as system prompts or tools have minimal impact. Rather, such harness-side variances show a larger impact on the cost of agent executions, achieving cost reductions up to 2.6× on the same model and task. To further explore these harness-side cost optimization opportunities, we analyze the cost accumulation patterns across various agent traces and identify system opportunities to reduce token use and LLM calls without modifying the model or affecting task accuracy. Based on this analysis, we design Agency, a harness interposition platform that provides a unified abstraction and allows easy and portable implementation of harness-side system optimizations on existing off-the-shelf harnesses such as Claude Code or OpenAI Codex. Using Agency, we implement proof-of-concept optimization techniques based on our analysis and achieve cost reductions up to 35% across various real-world benchmarks on existing harnesses without compromising accuracy.

1 INTRODUCTION

Agentic harnesses provide Large Language Models (LLMs) with an interface to a computing environment, enabling them to execute long-horizon agentic tasks such as fixing bugs, operating terminals, and searching documents (Jimenez et al., 2024; Merrill et al., 2026; Opsahl-Ong et al., 2026). Off-the-shelf harnesses such as Claude Code (Anthropic, 2025) or OpenAI Codex (OpenAI, 2025) are now widely used to assist software development and research.

Harnesses are essential in any agentic system. They provide the system prompt to specify agent behavior, tools to interact with the environment, and a looped LLM call to progress task execution, along with telemetry such as logging or sandboxing (Yao et al., 2023; Yang et al., 2024). As such, the harness defines the characteristics of an agent, and its actions and the resulting execution traces are also affected by the harness used (Wang et al., 2025; Zhu et al., 2026).

However, recent studies show that the task-solving capabilities, or task accuracy, of state-of-the-art models are barely affected by the choice of harness (Pan et al., 2026). Our experiments also show that the newer family of agentic models such as GPT-6 (OpenAI, 2026) or Claude-5.5 (Anthropic, 2026b) suffer marginal impact on task accuracy even when the harness does not provide a system prompt and tools ex-

cept for bash, as shown in Sec. 2.3. We observe that these newer agentic models are capable enough to find a solution regardless of the harness used, raising questions about the importance and efficacy of optimizing the harness layer in the agent systems stack.

Fortunately, we find a different optimization direction that the harness layer can still provide, in the form of token and cost reductions. With breakthroughs in long-context training and attention mechanisms (Liu et al., 2024; Yuan et al., 2025; Yang et al., 2025), state-of-the-art models easily reach context lengths up to one million tokens (OpenAI, 2026; Anthropic, 2026b; Qwen Team, 2026), making long-horizon agentic executions accessible to anyone. Unfortunately, this improvement is not without its price, quite literally with longer agent sessions reaching 10 to 100 times the cost of shorter sessions, as shown in Sec. 3.2.

To tackle this problem, we profile and analyze agent behaviors and cost accumulation patterns in our internal agent traces and open-source trace datasets (Nixon et al., 2026; Zhu et al., 2026), and present five opportunities to optimize cost in agent executions. First, we find reading existing context is the largest source of agent cost in real-world executions even with caching, taking up to 73% of the total cost (Sec. 3.2). Second, tool calls incur significant cost without increasing the token count, causing up to a 26× cost increase at the same token count (Sec. 3.3). Third, tool call outputs are often information sparse, and the agent uses only 27% of tools' outputs on average (Sec. 3.4). Fourth, agents often invest many turns in filesystem exploration, and up to

¹University of California, Berkeley ²Northwestern University ³University of Illinois at Urbana-Champaign. Correspondence to: Alvin Cheung akcheung@berkeley.edu.

Preprint.

Table 1. Model prices in USD (1M). “Input” is uncached input.

ModelInputCache writeCache readOutput
GPT-6-Luna*0.110.13750.0110.55
GPT-6.1-Sol*2.202.750.1111.00
Sonnet 5.52.202.750.1111.00
Opus 5.54.405.500.2222.00
Qwen3.8-27B----

*GPT models cost 1.5× for output and 2× for others when over 272K input tokens.

89% of agent turns can be spent searching the filesystem in retrieval-heavy tasks (Sec. 3.5). Finally, agent traces contain a large number of parallel subtasks, and we find on average 1.3 to 2.7 independent subtasks that can run concurrently to reduce context sharing across subtasks (Sec. 3.6).

Based on this analysis, we implement proof-of-concept systemic cost-optimization techniques to leverage these opportunities. Some agent cost reduction techniques are already well known: users are often instructed to start a new session on a new task (Anthropic, 2026a), sub-agents are delegated to a cheaper LLM (Sarkis, 2026), and some LLMs are trained to automatically remove unused context (Shao et al., 2026). However, many of these techniques require user decisions or unpredictable model behavior and fine-tuning, limiting the approach’s reliability and applicability.

Instead, we focus on system solutions that provide transparent and deterministic optimizations on top of popular off-the-shelf harnesses such as Claude Code or Codex. We design Agency, a harness interposition platform that provides a unified abstraction for monitoring and manipulating context, tools, and environments. Using Agency, optimizations written once can be easily reused across harnesses and models, and different agent configurations can be evaluated consistently. We implement our cost-optimization solutions on Agency and report up to 35% end-to-end cost reduction on real-world benchmarks with marginal accuracy loss.

In summary, we present the following contributions:

  • We analyze agentic costs and their accumulation patterns to identify five different opportunities to optimize agent token usage and cost.
  • We design Agency, a harness interposition platform that allows systematic manipulation of off-the-shelf harnesses for easy implementation and reuse of user-designed optimizations across various agent configurations.
  • We implement proof-of-concept techniques leveraging the five opportunities on Agency and achieve end-to-end cost reductions of up to 35% with marginal accuracy loss.

References (68)