X · Governance & ObservabilityEmerging

Harness-Native Rollout Capture

also known as In-Process LLM Proxying, Gateway-Captured Rollout, Token-Level Rollout Provenance

Capture reinforcement-learning rollouts by intercepting the model-call boundary inside the harness the agent already runs in, recording exact prompt and response token ids rather than reconstructing them from the transcript.

Context

A team post-trains an agent with reinforcement learning. In production the agent runs inside a harness — a long-running loop that manages tool integration, repository context, execution feedback and its own context budget. Rollouts for training can come from two places: a training-only reimplementation of that loop inside the trainer, or the real harness itself. The harness rewrites the conversation between turns; it compacts older messages, summarises sub-trajectories, truncates tool output and re-serialises the message list before each call. What the trainer sees afterwards is the rendered transcript, not the byte sequence the model was handed.

Problem

The prompt a trainer rebuilds from a transcript is not the prompt the model was asked. Harness-side compaction, summarisation and re-serialisation change which turns are present and how they are written, so the reconstructed token sequence diverges from the one that was generated against. Policy-gradient methods then recompute log-probabilities over tokens the model never saw, and the update is off-policy in a way no metric reports. The alternative — reimplementing the agent loop as a training-only environment — removes the mismatch by optimising a loop that is not the one shipped, so the two drift apart as the production harness evolves. Environmental crashes and reward hacking add a second corruption: a failed episode reaches the trainer as a low-reward rollout rather than as a discarded one.

Forces

  • The harness must keep rewriting the conversation to stay inside a context window, and every rewrite widens the gap between the transcript and what was actually sent.
  • A training-only reimplementation of the loop is easy to instrument but optimises a policy for an environment that never serves a request, while the production harness is faithful but was not built to emit training data.
  • Token ids are the only representation that survives re-serialisation; text survives it in appearance only, because a re-tokenisation can shift boundaries without changing a single visible character.
  • Interception at the model-call boundary leaves the harness's control flow untouched, but it also inherits the harness's failures — a crashed or reward-hacked episode is recorded as faithfully as a good one.
  • Rollouts are wanted as retained assets that can be resampled across runs, yet harnesses treat interaction traces as temporary runtime logs that are rotated away.

Example

A team fine-tunes a coding agent that runs inside an off-the-shelf harness. Halfway through a long task the harness compacts the older turns to stay inside the context window, so the transcript the trainer reads afterwards is not the prompt the model was handed. Gradients are computed against a prompt that never existed, and the reward curve climbs for a week while the deployed agent does not improve. Recording the token ids at the model-call boundary instead of rebuilding them removes the gap.

Diagram

Solution

Therefore:

Leave the harness alone and tap it. A proxy sits at the single point where the harness reaches an inference endpoint, forwards the request unchanged, and writes one step record per generation: the exact prompt token ids that were sent, the exact response token ids that came back, the reward once it is known, and metadata such as episode id, step index, model version and sampling configuration. The proxy adds no control flow of its own, so the harness keeps compacting and summarising exactly as it does in production; whatever it decided to send is what gets stored. Step records are collected into a pool that outlives the run, so an episode can be resampled, filtered or re-weighted later instead of being consumed once and discarded. The trainer reads token ids straight from the record and recomputes log-probabilities over them, never rebuilding a prompt from rendered text. The agreement between those recomputed values and the ones the serving path recorded at generation time becomes the health metric for the capture itself: a reported rollout-training probability correlation above 0.99 says the tap is faithful, and a drop says something in the path has started to re-tokenise or reorder. A filtering stage sits between the pool and the update, marking episodes that ended in a harness crash or that scored through reward hacking so they are excluded rather than learned from. Because the tap is at an API boundary rather than inside the loop, the same capture works across unmodified third-party harnesses; one reported setup trains through three of them without patching any.

What this pattern forbids. The trainer must not rebuild a prompt from the rendered transcript; only the token ids the proxy recorded at the model-call boundary may be consumed for a policy update, and the harness's control flow cannot be replaced by a training-only reimplementation of the loop.

And the patterns that stand alongside it, or against it —

  • complementsServed-Policy AnchoringTreat the policy the inference engine actually serves, not the one the training engine computes, as the object being optimised and gated, and measure their probability agreement continuously.
  • complementsJournaled LLM CallRecord the output of every non-deterministic step on first execution and replay that recorded value during crash-recovery instead of re-invoking the model.
  • complementsReplay / Time-Travel★★Re-run a past agent trace from any step with modified inputs/prompts/tools to debug or branch.
  • complementsEval Harness★★Run a held-out dataset against agent versions to detect regressions and measure improvement.
  • complementsManaged Agent RuntimeOffer the agent loop itself as a managed cloud primitive so a caller supplies a model, system prompt, and tools and the platform runs the orchestration in an isolated, session-scoped runtime.
  • complementsContext Folding·Let the agent branch into a temporary sub-context for a subtask and fold it back into a short summary on completion, so a long-horizon task stays within a small active window.
  • complementsReward HackingAnti-pattern: optimise the agent against a single proxy metric and assume the metric remains a faithful proxy after optimisation pressure.

Neighbourhood

Click any neighbour to follow the language. Scroll to zoom, drag to pan.