Composing Task-specific Agent Harnesses at Test Time with Reusable Primitives

Peng Kuang, Haibo Jin, Dehao Wu, Feiyang Deng, Xiaopeng Yuan +2 more
9/30/2026
cs.AI

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

Agent harnesses govern how large language models (LLMs) gather context, invoke tools, verify results, preserve state, and terminate, largely affecting agent performance. However, the value of each harness mechanism can differ across heterogeneous tasks: a mechanism that improves one task may impose overhead or context distraction on another, leading to the suboptimality of a global harness. We characterize this suboptimality as a mismatch induced by fixed mechanism choices, motivating task-specific harness construction. Nonetheless, generating harness code for each task introduces generation and debugging costs, with execution risks that can compound as more mechanisms are generated. To address those challenges, we introduce Harness Primitives, reusable harness mechanisms with clear application scope and composition contract mined from failed task trajectories. Based on Harness Primitives, we propose STITCH, a framework that Selects suitable primitives given Task Information and compiles them into Task-speCific Harnesses at test time. This separation enables task-specific harnesses without generating or repairing mechanism code at test time. Extensive experiments demonstrate that STITCH not only improves harness adaptability and robustness, but also scales with the primitive library size, boosting task success rates by up to 12 points over fixed harness baselines, surpassing human-designed harnesses like Codex CLI while maintaining a minimal test-time harness composition overhead of only 2.7%, 638 times more efficient than generating task-specific harnesses from scratch. Ultimately, our work demonstrates that building task-adaptive harnesses can be beneficial for completing diverse tasks and that building reusable primitives can be a promising path towards this goal.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{kuang2026composing,
  title  = {Composing Task-specific Agent Harnesses at Test Time with Reusable Primitives},
  author = {Peng Kuang and Haibo Jin and Dehao Wu and Feiyang Deng and Xiaopeng Yuan and Jerry Wang and Haohan Wang},
  year   = {2026},
  eprint = {2609.38912},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2609.38912v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2609.38912.svg)](https://codeofpaper.com/paper/2609.38912)

Discussion