Repository navigation
feat(claude_code_agent): make thinking folding configurable - #5955
Conversation
Without training-token capture, parse_stream_json folds each assistant message's thinking into its text as <think>...</think>. A judge that grades the final message then reads the full reasoning (median ~22K chars on a K3.1 HLE run vs ~650 for other harnesses) and often returns no verdict. Add an optional fold_thinking config field. None keeps the current default (folded unless capture is on); false returns the capture-style transcript without capture (thinking as separate reasoning items); true is rejected under capture. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Wei Du <[email protected]>
13af6f4 to
d5f76c6
Compare
yaoyu-33
left a comment
There was a problem hiding this comment.
Reviewed d5f76c6. No actionable issues found. The default behavior is preserved, and the explicit false setting consistently selects the existing unfolded transcript across local success, local timeout, and sandbox paths.
Validation: all 203 Claude Code agent tests passed, plus four focused fixture-based integration probes for explicit false without capture through local/sandbox success and timeout. Model rollout evidence is author-reported and was not independently rerun. Full repository CI remains gated on runner authorization.
|
/ok to test d5f76c6 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42948523025 |
Main's OpenAI 2.45 schemas (NVIDIA-NeMo#5464) give Responses usage a cache_write_tokens count. The Anthropic-to-Responses conversion keeps it beside this branch's total input (uncached + cache writes + cache reads), and the reverse conversion now reports it as cache_creation_input_tokens and leaves it out of input_tokens, as it already did for cache reads. Main's configurable thinking folding (NVIDIA-NeMo#5955) is kept at each parse_stream_json call with this branch's transcript records. Signed-off-by: gwarmstrong <[email protected]>
What does this PR do?
Adds an optional
fold_thinkingfield toClaudeCodeAgentConfig.Without training-token capture,
parse_stream_jsonfolds each assistant message's thinking into the message text as<think>...</think>, and there is no config option to turn that off. When a judge grades the final message, it then reads the whole reasoning instead of the answer.On a Kimi-K3.1 HLE run (1,000 text questions, sdg-pipelines in-harness recipe), 989/997 Claude Code final messages contained
<think>. Their median length was ~22K characters, against ~650 for the Pi, Codex, Hermes and OpenClaw harnesses on the same questions. About 50 rollouts per Claude variant came back with no judge verdict. The raw backend responses were clean (reasoning and content separate), so the folding is the only source of the difference.fold_thinking: null(default): unchanged. Thinking is folded unless training-token capture is on.fold_thinking: false: returns the capture-style transcript without capture. Thinking comes back as separatereasoningitems, so the final message holds only the answer.fold_thinking: truetogether with capture raisesValueError, since capture needs unfolded output.No issue is linked: this is a small opt-in config field with no change to the default behavior.
Validation
pytest responses_api_agents/claude_code_agent/testsfrom the repo root (uv 0.13.7, Python 3.13): 203 passed. There are 2 new tests: a parametrized test of the config/capture matrix, and a test thattrueis rejected under capture.pre-commit run --fileson the three changed files: all hooks pass.Rollouts
The same patch on top of Gym
7d4bcf98, with Kimi-K3.1 (max effort) in AWS OpenSandbox, 30 HLE questions per variant,fold_thinking: false:<think>reasoningitemsRegraded with DeepSeek-V4.1-Flash, the standard variant had 0 unjudged out of 30.
Compatibility and benchmark impact
None by default. The new field is optional and
nullkeeps today's behavior. Configs that setfold_thinking: falseget answer-only final messages, which changes what an answer-grading judge sees. The transcript is the same one capture already produces, so subagent frames are excluded and pending tool calls stayincomplete.Checklist
responses_api_agents/claude_code_agent/README.md)pre-commit run --all-files) (so CI lint/format checks pass). (Run on the changed files.)git commit -s) (so the DCO check passes).🤖 Generated with Claude Code