Manuscript Offprint

arXiv:2610.20261

Harness Policy Distillation: Aligning Agent Policies with Runtime Semantics

Junze Zhu, Weihao Chen, Zhiyang Zhou, Zhen Wu, Xinyu Dai

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

ABSTRACT

Deploying a general-purpose model as an agent means running it inside a product-specific runtime harness that decides which actions are executable, how state advances, and when the loop may terminate. Ordinary trajectory supervision shows which action was taken but leaves the runtime semantics behind that action implicit. We introduce Harness Policy Distillation (HPD), which makes these runtime control semantics an explicit training target alongside actions to align the harness policy. HPD replays reference trajectories through the harness to recover the runtime semantics that are implicit in ordinary trajectory data, and represents them as control documents at each model-call boundary. These documents provide privileged information for a teacher to generate actions, while harness verification ensures that the resulting targets are executable under the runtime contract. We jointly trains a shared model on the runtime semantics recovered from control-state privileged information and native history, thereby internalizing these semantics into the model policy. At deployment, the trained model uses the original harness interface without requiring the control document or any additional supplement. On TRAJECT-Bench with the Pi harness, Qwen3-8B trained with HPD reaches 22.98% autonomous task success and 49.23% runtime compliance, against 3.09% and 19.90% for the unadapted model. Harness-verified teacher actions substantially improve the native deployment policy, while joint control-state supervision provides further gains in task completion and runtime compliance. HPD turns executable runtime semantics into dense supervision for learning harness-compatible actions at each decision boundary.

1 INTRODUCTION

A general-purpose model becomes a deployed agent only inside a product-specific runtime harness. The harness serializes visible history, exposes an approved action interface, enforces permissions and workflow stages, inserts tool observations, schedules subsequent model calls, and defines valid termination (Yang et al., 2024; Wang et al., 2025). For an organization adapting a model to its own product, the relevant target is therefore not task competence or tool syntax alone, but a harness-bound policy whose actions remain executable under that product's runtime contract.

Most post-training objectives supervise behavior without separately specifying the runtime control state on which that behavior depends. Demonstration and trajectory training maximize the likelihood of reference actions conditioned on observed histories, leaving the control state implicit in the mapping from history to action. Direct Preference Optimization (DPO) increases the relative likelihood of preferred outputs (Rafailov et al., 2023); Reinforcement learning with verifiable rewards (RLVR) optimizes expected return from executable checks (Shao et al., 2024; Guo et al., 2025), leaving the policy to infer reward-relevant control state through credit assignment. On-policy distillation (OPD) matches teacher behavior at student-generated prefixes (Agarwal et al., 2024), improving the coverage of states at which supervision is supplied while leaving the teacher's action distribution as

∗^{*}Corresponding author.

Preprint

Figure

(a) Harness-Policy Teacher

Policy mismatch

Reference replay in Harness

Recorded a* advances state; Native context x*

AUTOPROBE → control document dH

Pre-action facts + Reference ledger + Action witness

Teacher model πθ0(⋅∣Inject(x∗,dH))\pi\theta_0(\cdot|\text{Inject}(x^*, d^H))

Candidate actions

Candidate actions

(b) State-conditioned Policy Alignment

HARNESS-REPLAY

x∗→a~x^* \rightarrow \tilde{a}

INJECTED

Inject (x∗,dH)→a~(x^{*}, d^{H}) \rightarrow \tilde{a}

RUNTIME

Probe (x∗)→dH(x^{*}) \rightarrow d^{H}

Shared θ\theta · interleaved training views

Control-entry alignment

--- Before

After

Prob Density

Harness Prob

State-valid actions

--- Before

After

p(a|x)

Allowed by Harness

Candidate actions a

Figure 1: Harness Policy Distillation. Left: agent model–harness policy mismatches. (a) Recorded actions advance replay; AUTOPROBE compiles control documents; teacher-model proposals are verified and ranked by reference similarity. (b) Three views train one shared model for native action prediction, document-conditioned action prediction, and document reconstruction.

the direct target. These objectives can learn runtime-sensitive behavior, but their standard forms leave the underlying control state to be inferred through action, preference, reward, or teacher supervision.

Within an agent, the model selects actions while the harness governs their execution. We distinguish two sources of policy mismatch between them. Supervision mismatch arises when the histories used for supervision differ from those generated by the agent's own rollout: a model may fit reference actions yet struggle to continue once its own actions lead to histories poorly covered during training (Ross et al., 2011; Bengio et al., 2015). Runtime-state mismatch arises when the model policy fails to reflect the harness's current execution requirements. Even on a valid reference history, action labels leave implicit which obligations remain and whether termination is allowed; the model may therefore repeat completed work or stop while required work is still pending. The two problems interact through the closed loop: each action changes the successor state and hence the context of the next decision. Improving the conditional policy at replayed boundaries is therefore a concrete training target, while autonomous task completion measures its effect across an entire execution. Because each action changes the next runtime state and model context, a local error can affect later decisions.

The harness provides a complementary source of supervision: its execution history and runtime bookkeeping identify the obligations and lifecycle conditions that govern the next action. For example, tool availability alone does not indicate whether the corresponding obligation has already been completed. Learning the next action from a reference trajectory leaves this distinction implicit; explicitly supervising the boundary's control state makes it a prediction. We therefore target this policy mismatch with explicit control-state and action supervision at replayed boundaries, and evaluate its effect through autonomous task completion.

To make this connection learnable, we propose Harness Policy Distillation (HPD), which couples explicit control-state supervision with harness-verified action targets to align the model policy with the runtime semantics governing execution. At each replayed boundary, HPD compiles runtime observations and reference-derived control annotations into a privileged control document. This document guides a sampling model to propose actions, while harness verification restricts the training targets to candidates consistent with the execution and reference-control requirements. Recorded actions advance replay while selected candidates provide training targets, preserving the reference histories on which the paired supervision is defined.

To internalize these control semantics without requiring the document during autonomous execution, HPD jointly trains three views of one shared model. RUNTIME uses the compiled document as a target for control-state prediction from native history; INJECTED teaches action selection with these conditions made explicit. HARNESS-REPLAY trains the same verified action from native context alone, so action learning also matches the input available at deployment. Together, these views connect explicit control supervision to native action selection. The trained model acts through the original harness without an external control document or an additional model call (Figure 1).

Preprint

References (80)

  • Learning from self-generated mistakes
  • Scheduled sampling for sequence prediction with recurrent neural networks
  • Reinforcement learning via sequence modeling
  • Group-in-group policy optimization for LLM agent training
  • Gemma 4 Technical Report
  • Nature, 645(8081):633–638, 2025 (opens the publisher in a new tab)
  • TRAJECT-Bench: A trajectory-aware benchmark for evaluating agentic tool use
  • Distilling the Knowledge in a Neural Network
  • Low-rank adaptation of large language models
  • Offline reinforcement learning as one big sequence modeling problem
  • Can language models resolve real-world GitHub issues? In International Conference on Learning Representations, 2024
  • Sequence-level knowledge distillation (opens the publisher in a new tab)
  • Group reward-decoupled normalization policy optimization for multi-reward RL optimization
  • Evaluating LLMs as agents
  • Unifying distillation and privileged information (opens arXiv in a new tab)
  • A stateful, conversational, interactive evaluation benchmark for LLM tool use capabilities (opens the publisher in a new tab)
  • An analytical evaluation board of multi-turn LLM agents
  • A benchmark for general AI assistants
  • The berkeley function calling leaderboard (BFCL): From tool use to agentic evaluation of large language models
  • Privileged information distillation for language models (opens arXiv in a new tab)
  • Facilitating large language models to master 16000+ real-world APIs
  • Your language model is secretly a reward model
  • A reduction of imitation learning and structured prediction to no-regret online learning
  • Language models can teach themselves to use tools
  • DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
  • Aligning text and embodied environments for interactive learning
  • Jonathan Uesato, Nate Kushman, Ramana Kumar, et al. Solving math word problems with process-and outcome-based feedback. arXiv preprint arXiv:2211.14275, 2022. URL https://arxiv.org/abs/2211.14275. Presented at the NeurIPS 2022 MATH-AI Workshop. (opens arXiv in a new tab)
  • A new learning paradigm: Learning using privileged information (opens the publisher in a new tab)
  • An open platform for AI software developers as generalist agents
  • Qwen3 Technical Report
  • Agent-computer interfaces enable automated software engineering
  • Teaching large language model to use tools via self-instruction
  • WebShop: Towards scalable real-world web interaction with grounded language agents
  • Synergizing reasoning and acting in language models
  • $\tau$-bench: A benchmark for tool-agent-user interaction in real-world domains
  • Self-distilled reasoner: On-policy self-distillation for large language models
  • Training with harnesses: On-policy harness self-distillation for complex reasoning (opens arXiv in a new tab)
  • Group Sequence Policy Optimization
  • A realistic web environment for building autonomous agents
  • TurnOPD: Making on-policy distillation turn-aware for efficient long-horizon agent training (opens arXiv in a new tab)
  • Teacher construction requires exact agreement on the designated harness-policy and tool-call portions of the reference
  • The recorded action is one executable witness that reconstructs the reference path
  • The observation adapter may inspect only messages, prior actions, tool results, scheduler events, permissions, and exit state available at the current boundary
  • When the callback fires, the current action has not yet been generated, whereas all prior assistant actions, tool results, errors, and user steering have already been inserted and the previous turn preparation has completed
  • \tag {11} $$
  • Each subsequent failure extends the prefix by one more turn before resampling
  • The Pi test set contains 2,140 gold-history action boundaries
  • Each boundary defines one HARNESS-REPLAY record, one INJECTED record, and one RUNTIME record, for 52,797 boundary-view records
  • Separate portability and signal-density studies retain their own fixed evaluation protocols
  • The completed HPD component runs use 20k batch exposures per active view, as defined in
  • HARNESS-REPLAY is HPD's native-action view
  • The HPD checkpoint is unchanged
  • We apply Holm correction within each comparison to TS, F1, Step-SR, and RC. The adjusted TS $p$-values for Full HPD versus HPD-T and OPD are 0.00343 and 0.00338, respectively
  • Task and tool execution follow BFCL v4's default settings
  • HPD-T matches Base's 13.04 TS but exceeds its F1 and Step-SR by 6.66 and 4.13 points
  • The 200-cycle mean loss decreases from 0.188 to 0.181 and 0.162
  • The 60k endpoint completes 20k training rounds
  • Aggregating each complete T/I/R cycle yields the trend in Figure 8
  • Harness-Replay is fixed at 1.0 while either Injected or Runtime is varied over 0.2, 0.6, 1.4, and 1.8; the other auxiliary view stays at 1.0
  • Highest scores are labeled
  • HPD improves both TS and F1 at every size, with TS gains ranging from 4.46 points at 0.6B to 14.41 at 14B; the 32B gain is 13.90 points
  • TS uses the historical task-success definition; F1, RC, and Exact use the runtime evaluation summaries
  • Final-answer F1 is token-level F1 between the emitted final response and the reference answer
  • RC is the fraction of tasks satisfying the harness execution contract: required tool sequence and parameter keys, exactly one final response, native exit, and a healthy worker
  • For $m_b > 0$, define
  • Writing $p_{\text{TS}} = \mathbb{E}[S_i]$, the mean decomposes as
  • The tables provide the aggregate and success rate, which describe answer overlap and completed-task coverage as separate outcomes
  • OPSD similarly raises TS over Base (13.55 versus 3.09) without raising F1 (26.27 versus 26.82)
  • Grouping instead by execution-only conditions, such as obligation completion and native termination, separates execution coverage from the answer threshold used in TS. These two decompositions distinguish the coverage of successful execution from answer quality within each group
  • Here $\delta_{z}$ assigns probability one to the sequence z and zero elsewhere; d and a are document and action variables, respectively:
  • Its document marginal $\pi_R^{\mathrm{rep}}$, document-conditioned action distribution $\pi_I^{\mathrm{rep}}$, and native action marginal $\pi_T^{\mathrm{rep}}$ satisfy
  • Each record has a point target; records sharing a serialized context induce an empirical mixture when conditioned on that context
  • Suppressing boundary and harness indices, the KL chain rule gives
  • The three losses in Equation 9 are
  • The three implementation pairs are
  • Student training consumes these stored targets and requires no teacher forward pass
  • To connect these per-record losses to the conditional teacher, average over the empirical distribution of prompt–target pairs
  • Let $\widehat{P}_v(c, y)$ be the empirical distribution of stored pairs for view $v$, with context marginal $\widehat{P}_v(c) = \sum_y \widehat{P}_v(c, y)$ and conditional teacher $q_v(y \mid c) = \widehat{P}_v(y \mid c)$
  • Thus per-record NLL averaging recovers $\mathcal{L}_T$, $\mathcal{L}_I$, and $\mathcal{L}_R$ up to constant entropies
  • One T/I/R round is one training step, giving default weights $\alpha_T = \alpha_I = \alpha_R = 1/3$ and 60k optimizer updates over 20k training steps