Repository navigation
RFC 006: Agentic RL through Harness Interception — token-faithful traces for TRL - #941
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.
|
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: |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
rfcs/006-agentic-rl-harness-interception.md:7
- RFC numbering: RFC 010 explicitly states that numbers 006–009 are reserved for the self-improving-gym RFC family (rfcs/010-echo-env-token-world-model.md:8-11). Using RFC ID: 006 here (and the filename/README index) creates an in-repo inconsistency. Consider renumbering this RFC (and renaming the file + README entry), or updating RFC 010’s reservation note if that plan has changed.
**Created**: 2026-07-11
**Authors**: @rycerzes, @sergiopaniego
**RFC ID**: 006
rfcs/README.md:96
- This RFC index entry uses
006-..., but RFC 010 notes that IDs 006–009 are reserved (rfcs/010-echo-env-token-world-model.md:8-11). If that reservation still stands, this entry (and the RFC filename/header) should be renumbered to an unreserved ID to avoid conflicting documentation.
- [005-agentic-harnesses.md](./005-agentic-harnesses.md) - Agentic Harness Integration (OpenClaw, Claude Code, etc.)
- [006-agentic-rl-harness-interception.md](./006-agentic-rl-harness-interception.md) - Agentic RL through Harness Interception: token-faithful traces for TRL
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
rfcs/006-agentic-rl-harness-interception.md:6
- RFC ID 006 is currently also used by open PRs #624 and #794 (both add different
rfcs/006-*.mdfiles). Keeping this as 006 will force a renumber + file rename + README index update during merge conflict resolution; it’s safer to pick an unused RFC ID now (or mark the ID as TBD) to avoid collisions and broken cross-references.
**Created**: 2026-07-11
**Authors**: @rycerzes, @sergiopaniego
**RFC ID**: 006
rycerzes
left a comment
There was a problem hiding this comment.
@sergiopaniego Pushed a revision covering all three points.
- Seam — now
AsyncGRPOTrainer+HarnessRolloutWorker;run_white_boxis the secondary mode,rollout_funca sync bridge. - Buffer — your call. My "verifiers and Polar assemble at the interception point" claim was wrong: Polar merges post-hoc in
prefix_merging.py, verifiers ingraph.py, TRL in_chain_to_sequences. None buffers in the proxy. OpenEnv is a recorder only. - D3 adds one thing: inject
return_token_idsand record the engine's canonicalprompt_token_ids. Interstitials then come from slicing the next call's prompt after the EOT token (as Polar does) — nothing re-rendered, no tokenizer in core. - That implies one TRL change:
_turns_from_tracereadingentry["prompt_token_ids"]instead of re-rendering, with a fallback. It currently passes neitherchat_templatenorchat_template_kwargswhere_sample_turnpasses both, so the training-template substitution is skipped and ourenable_thinking=Falseinjection is invisible. Divergent prompts make_chain_to_sequencesFORKevery turn and pairinput_idswith logprobs from a different rendering. - Topology — D18 + a section from your description, now grounded in
huggingface_hub.Sandbox.proxy_url_for. Since that port proxy carrieswss://and streamed responses, the trainer can dial in to a thin in-sandbox relay rather than needing a publicly reachable address, so I wrote that up as the preferred transport with an outbound tunnel as the alternative — which of the two did you actually use? Also kept the in-sandbox proxy as a supported mode rather than legacy; it's the simpler deployment and both modes can share the recorder andTraceEntry. - D12 fixed — the fence is TRL's
WeightTransferClient.pause()/.resume()on aVLLM_SERVER_DEV_MODE=1server, nottrl vllm-serve(no pause endpoint there).
One question: D16 puts TraceEntry + the loop-owning session protocol in openenv.core.harness. Does that match your "contract stays HarnessTrace"? I made TraceEntry what OpenEnv emits and HarnessTrace the consumer-built target, since a framework-side buffer means we can't be emitting a loss_mask.
Yes please on wiring up the OpenCode/Pi harnesses once the server exists.
39ca25d to
92812e1
Compare
|
@sergiopaniego Rescoped the RFC against #1036 rather than patching it — it was arguing for a component that now exists, so it is now the rationale and contract spec for Four decisions moved, three against what I argued last time.
New D19 for the four wire dialects, plus the hazard I had missed: One question, on the example: Still yes on wiring up the OpenCode/Pi harnesses once consolidation lands. |
Adopt RFC 012's amendment to D2 (hosted providers for eval only; startup refuses only unreachable endpoints), the explicit training sampling policy (D3), enforced model-call and output-token budgets (D13), and the authoritative Harbor contract reader (D16). Fix stale paths after openenv#1097. Refs openenv#940
rycerzes
left a comment
There was a problem hiding this comment.
@sergiopaniego @adithya-s-k @burtenshaw, reconciled this with merged #1036 and RFC 012: D2 now adopts RFC 012's eval/train split, and D3, D13 and D16 are updated to match main. It's now the rationale and contract record for core/harness/capture.
Could you both take a final look for merge?
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
@rycerzes @sergiopaniego the links for the Environments have to be updated to use the latest FineEnvs releases https://huggingface.co/collections/FineEnvs/smoldataenvs |
sergiopaniego
left a comment
There was a problem hiding this comment.
lgtm with the changes requested by @adithya-s-k 🚀
|
i think it would make sense to merge both these RFCs(006 and 012) into a single one as there is an overlap @sergiopaniego @burtenshaw how do we go about this ? |
mmm we can actually combine both RFCs, you're right. 2 options: merge this one as is and then you can open a follow-up PR, or we can fold those sections into 006 here. Which one would you prefer @adithya-s-k? Also @rycerzes, GOVERNANCE.md still lists RFC 006 as "multi-component rewards" (#623), so those two lines will need an update once this lands as 006 |
|
we can get this merged and i will create a consolidated PR, and i will be a pushing a few more things for harbor x openenv |
58f16df to
8345daa
Compare
|
Sounds good. Merging this as it is, with a consolidated 006 + 012 follow-up from @adithya-s-k, works for me. @sergiopaniego, I've updated GOVERNANCE.md in this PR (8345daa). RFC 006 now points to this RFC in both the in-flight list and the RFC table. The reward/eval authors row still asked people to adopt the multi-component reward schema, but #623, #624 and #625 were closed as not planned, so it now says to expose reward components through the rubric tree (RFC 004), which is shipped and is what RFC 008's rubric checks read. @adithya-s-k, could you review and re-approve? |
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
Changes are limited to RFC and governance markdown; no runtime or training behavior is modified in this diff.
Overview
This PR is documentation-only: it adds
rfcs/006-agentic-rl-harness-interception.mdand updatesGOVERNANCE.mdandrfcs/README.mdso RFC 006 is the agentic RL / harness interception spec, not the older “multi-component rewards” pointer.The new RFC reframes the topic as the design rationale and contract for the capture stack already landed in #1036 (
core/harness/capture/), reconciled with RFC 012. It documents the token capture contract (canonicalprompt_token_ids/ sampled ids + generation-time logprobs →(input_ids, loss_mask, logprobs, reward)), ownership vs TRL, and 19 design decisions, including corrections where implementation diverged from an earlier draft (OpenEnv assembles graphs without a tokenizer, prefix-linked graphs not chains, structural roles + ATIF, sandbox dials out to a trainer-side proxy).Governance now links RFC 006 to this file (status In review), and the reward/eval persona bullet points eval authors at RFC 004 rubrics instead of RFC 006 multi-component rewards. Open work called out in the RFC includes consolidating
opencode_env/pi_envonto core capture and TRL consumingcapture/contract.pyconverters instead of re-tokenizing in_turns_from_trace.Reviewed by Cursor Bugbot for commit 15fb7b2. Bugbot is set up for automated code reviews on this repo. Configure here.