Repository navigation
fix(claude_code_agent): emit a capture-attributable transcript; keep partial output on CLI timeout - #4015
Merged
pthombre merged 3 commits intoOct 16, 2026
Conversation
linj-glitch
marked this pull request as draft
October 5, 2026 06:11
linj-glitch
force-pushed
the
linj/claude-code-capture-transcript
branch
from
October 8, 2026 00:15
2133cf5 to
e6b8038
Compare
…partial output on CLI timeout With training-token capture on, Gym joins the finished transcript to one captured model call by hashing the model-authored text and, failing that, by response id. The agent folded the model's thinking into the message text as `<think>...</think>` and named the response with a random `resp_<uuid>`, so neither reading could match (`response_id_no_match,no_content_match`) and every captured rollout was masked even with a single verified chain. When capture is enabled, `parse_stream_json(..., fold_thinking=False)` emits thinking as a separate `reasoning` item (which the fingerprint ignores by design) and keeps the message text bare. The last assistant message's served id is reported as `terminal_response_id` in the run metadata and, under capture, used as the response id. Behavior without capture is unchanged. A CLI timeout returned `[]` and dropped the transcript already streamed, so there was nothing to grade or attribute. Return the parsed partial output. Signed-off-by: Lin Jia <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
linj-glitch
force-pushed
the
linj/claude-code-capture-transcript
branch
from
October 8, 2026 00:20
e6b8038 to
1a0f57b
Compare
linj-glitch
marked this pull request as ready for review
October 13, 2026 23:08
pthombre
self-requested a review
October 15, 2026 18:59
pthombre
reviewed
Oct 15, 2026
Keep capture transcripts on the main conversation and retain pending tool calls in model order. Complete calls when their results arrive, preserving evaluation behavior while avoiding timeout witness disagreements. Exercise the real execution and timeout wiring, terminal witnesses, and missing response IDs. Clarify capture setup and terminal ID semantics. Signed-off-by: Lin Jia <[email protected]>
Contributor
|
/ok to test 8286b38 |
pthombre
approved these changes
Oct 16, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38952569892 |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fix Claude Code's capture transcript so Gym can corroborate the parent conversation's terminal model call. With training-token capture enabled, thinking stays in separate reasoning items, the last non-empty main-thread served ID becomes
response.id, and subagent assistant/tool-result frames are excluded from the parent transcript. Subagent token usage is still counted.Tool calls enter the capture transcript in model order and remain
incompleteuntil their result arrives. A timeout therefore retains pending calls even when parallel tools finish out of order. The partial transcript is returned with run metadatastatus="incomplete"anderror_type="timeout". The internalterminal_response_idis not exported as a declared terminal ID on/run; attribution still corroborates the response against independent witnesses.Without capture, thinking remains folded into
<think>text, unmatched tool calls remain omitted, and the response retains a generated ID. Timeout responses now retain partial output; verifiers that inspect assistant text can consequently score that partial work.No separate issue is needed: this PR documents and fixes the existing capture-attribution and timeout failures.
Validation
Validated fix commit
2a537a91a142c842d1782d0d1df1d73b0e566a94.gym env test +entrypoint=responses_api_agents/claude_code_agent +should_validate_data=true: 87 passed, reusing the validated Python 3.13.14 environment withskip_venv_if_present=trueanduv_venv_diroverrides.python -m pytest -q -o addopts= responses_api_agents/claude_code_agent/tests tests/unit_tests/test_terminal_attribution.py tests/unit_tests/test_conversation_fingerprint.py: 135 passed (Python 3.13.14)._create_response→_run_claude_codesuccess/timeout paths with capture on/off, with only the subprocess boundary replaced. The timeout uses the real asyncio timeout path.pre-commit run --all-files: passed.Rollouts and remaining gates
The original author-reported evidence was internal GRPO training through the real Claude Code CLI: with this patch's initial representation/ID changes plus the tool-call lineage fallback, capture attribution succeeded over several thousand rollouts. No public rollout numbers were supplied.
That historical report does not validate this revision's subagent and pending-tool fixes. A fresh representative real model/verifier smoke rollout was not run in this review environment; the unit tests use synthetic CLI frames. That rollout evidence, current-head CI, and Ananth's shared capture review remain outstanding before merge. Complete Claude Code training attribution also depends on the still-open #4014.