RFC 006: Agentic RL through Harness Interception — token-faithful traces for TRL#941
RFC 006: Agentic RL through Harness Interception — token-faithful traces for TRL#941rycerzes wants to merge 3 commits into
Conversation
sergiopaniego
left a comment
There was a problem hiding this comment.
linking huggingface/trl#6420 for considering it as it's directly related with this one.
|
@rycerzes solid RFC. One alignment point on the TRL seam: the harness-training path is being implemented in TRL as |
There was a problem hiding this comment.
Pull request overview
Adds a new design RFC describing an “installed-agent” RL training path for black-box CLI harnesses by intercepting OpenAI-compatible LLM traffic and emitting token-faithful traces consumable by TRL.
Changes:
- Introduces RFC 006 describing an interception server + trace recorder architecture for token-level rollouts.
- Defines the proposed trace contract
(prompt_ids, response_ids, loss_mask, response_logprobs, reward)and key design decisions (TITO, prefix-break forking, session-as-API-key, etc.). - Documents intended integration points with existing OpenEnv harness seams (
CLIHarnessAdapter.run_white_box,build_harness_rollout_func) and TRL’srollout_func.
Alignment Review Notes (per skill)
- Automated Checks
- Lint: Not run (no facility to execute
.claude/hooks/lint.shin this review environment) - Debug code: Not run (no facility to execute
.claude/hooks/check-debug.shin this review environment)
- Lint: Not run (no facility to execute
- Open RFCs context (relevant)
- RFC 005: In Review (
rfcs/005-agentic-harnesses.md) — this RFC explicitly extends it. - Other RFCs in Draft/In Review exist but no direct conflict identified from this doc-only change.
- RFC 005: In Review (
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| **Status**: Draft | ||
| **Authors**: @rycerzes | ||
| **RFC ID**: 006 |
| This is the shape Polar (`prompt_ids, response_ids, loss_mask, response_logprobs, reward`), Prime, and OpenEnv main's [`HarnessRolloutResult`](../src/openenv/core/harness/__init__.py) converged on, and what TRL's `rollout_func` consumes directly. | ||
|
|
|
|
||
| (mask `0` = env/template output only, D9; `0.0` logprob filler at mask=0, D15) | ||
|
|
||
| **The seam.** `CLIHarnessAdapter.run_white_box(...)` launches the harness against the interception server, drives one episode, and returns the assembled traces; [`build_harness_rollout_func`](../src/openenv/core/harness/__init__.py) adapts them to TRL's `rollout_func` (`prompt_ids`, `completion_ids`, `logprobs`, `env_reward`, `env_mask`). |
| rollout_func=rollout_func, # returns prompt_ids, completion_ids, logprobs, env_reward, env_mask | ||
| ..., # TRL owns vLLM (return_token_ids), weight sync, advantages, IS |
|
|
||
| **Status**: Draft | ||
| **Authors**: @rycerzes | ||
| **RFC ID**: 006 |
| from openenv.core.harness import CLIHarnessAdapter, build_harness_rollout_func | ||
|
|
||
| adapter = CLIHarnessAdapter(spec=swe_rl_agent_spec) # black-box harness spec | ||
| rollout_func = build_harness_rollout_func(adapter) # → TRL contract | ||
|
|
|
Following up on my earlier note about the TRL seam. Now that huggingface/trl#6420 is merged, the installed-agent path in TRL is concretely 1. Remote / managed-sandbox interception topology. The architecture assumes the harness can reach the trainer-side interception server. For agents in remote, network-isolated sandboxes (HF Sandbox, E2B) that needs spelling out: the sandbox can egress HTTPS but has no easy inbound. The shape we validated keeps the server trainer-side/colocated and exposes it to the sandbox through an egress tunnel. The harness only gets 2. Where the TITO buffer should live. For context on the status quo: in the merged worker path, We have validated real OpenCode/Pi harnesses that could plug into the interception server, happy to help wire them up when it exists. For reference, the in-sandbox vs trainer-side placement in a remote-sandbox run: |
Summary
Adds an RFC for training the policy driving a black-box agent harness (Pi, OpenCode, Claude Code, …) inside OpenEnv by intercepting its LLM calls at an OpenAI-compatible boundary and recording a token-faithful trace —
(prompt_ids, response_ids, loss_mask, response_logprobs, reward)— that TRL consumes viarollout_func.This turns RFC 005's
CLIHarnessAdapter.run_white_boxstub (currentlyNotImplementedError) into a real seam. It is the installed-agent training path — the counterpart to the external-agent pattern TRL's Harbor integration already covers.Design-only RFC PR — no runtime behavior changes.
What's in it
chat_template_utils, prefix-break forking, session-ID-as-API-key auth, synthetic SSE replay, weight-sync fencing, proxy-enforced budgets.Relationship to other work
rfcs/005-agentic-harnesses.md) — reconciles with it, does not parallel it.Note on numbering
Filed as
006, but006is also used by open PRs #794 and #624 — happy to renumber to whatever's free at merge time.cc @burtenshaw @adithya-s-k @sergiopaniego
Note
Low Risk
Documentation-only RFC with no production code, config, or behavioral changes.
Overview
Introduces RFC 006 (
rfcs/006-agentic-rl-harness-interception.md) as a design document only—no runtime or API changes in this PR.The RFC specifies how OpenEnv will train policies for black-box CLI harnesses (Pi, OpenCode, Claude Code, etc.) by hosting an OpenAI-compatible interception server that fronts TRL-controlled vLLM, records generation-time
(prompt_ids, response_ids, loss_mask, response_logprobs, reward), and feeds TRL viarun_white_box+build_harness_rollout_func. It targets the installed-agent gap left by TRL Harbor (external-agent only) and replaces the currentCLIHarnessAdapter.run_white_boxNotImplementedErrorstub from RFC 005.The doc lays out an OpenEnv vs TRL ownership table (interception/trace/masking vs generation, weight sync, GRPO/IS), a
HarnessTracecontract aligned with Polar/verifiers, 15 decisions (TITO via TRLchat_template_utils, prefix-break forking, session bearer auth, synthetic SSE, envverify()rewards, δ diagnostics, provenance, weight-sync fencing, rollout budgets), plus architecture/request-lifecycle mermaid diagrams, a GRPO wiring example, and references. It extends RFC 005 and supersedes the message-level draft in #864.Reviewed by Cursor Bugbot for commit 08c1aeb. Bugbot is set up for automated code reviews on this repo. Configure here.