Repository navigation
fix: preserve opaque reasoning through Anthropic replay - #4615
RyaliNvidia merged 4 commits into
Conversation
Signed-off-by: RyaliNvidia <[email protected]>
There was a problem hiding this comment.
Thanks for tracking this down. Carrying the ciphertext opaquely through the Anthropic client is the right mechanism, and keeping it on the shared /v1/messages route is the right layer: every model server inherits that route, and the carrier only activates when the backend actually returned encrypted_content, so vLLM-backed servers are unaffected. It does not need to become a per-server setting.
The inline comments ask for changes in three areas.
- Wire correctness. Encrypted-only items replayed from the client are forwarded without
summary, and multi-summary reasoning comes back as several items withencrypted_content="". - Prefix ownership.
litellm_encrypted_reasoning:is a LiteLLM internal tag that LiteLLM strips before forwarding to an Anthropic provider, so a Gym-owned prefix avoids a silent-loss path. - Scope. The Anthropic provider path has no production caller and can stay out of this PR.
flowchart LR
client["Anthropic client"] --> route["Shared /v1/messages route"]
route --> ingress["Ingress: strip carrier"]
ingress --> server["Model server"]
server --> backend["Responses backend"]
backend --> server
server --> egress["Egress: wrap ciphertext in carrier"]
egress --> client
Interaction with other open PRs. #4461 emits signature_delta only when the signature is non-empty and adds an unmarked placeholder signature. #2507 treats redacted_thinking data as raw ciphertext with no prefix. The three PRs need one shared rule. The suggestion inline: only carrier-tagged values become encrypted_content, and everything else is treated as having no ciphertext.
Per-backend decision. No Gym server or config requests include=["reasoning.encrypted_content"] today, so this path only activates when a user adds it. A short note in the PR description on which setup produces encrypted reasoning without a summary would help reviewers. So would a smoke run against a real Responses provider at this head.
Signed-off-by: RyaliNvidia <[email protected]>
|
Hi @ananthsub . Can you please review this again? I just addressed your comments |
yaoyu-33
left a comment
There was a problem hiding this comment.
LGTM. The earlier replay/prefix concerns are addressed; 300 focused tests and SDK replay checks passed. Full CI is still required.
|
/ok to test 450f523 |
|
could @RyaliNvidia merge main? |
|
Yep. Merging main and then reverifying the test |
Signed-off-by: RyaliNvidia <[email protected]>
|
/ok to test b2a86cc |
Signed-off-by: RyaliNvidia <[email protected]>
|
/ok to test 3efefb8 |
yaoyu-33
left a comment
There was a problem hiding this comment.
Reapproved after checking the main integration and reasoning-ID correction. 317 focused converter/replay/streaming tests passed; no new blocking issue found. The required CI gate passes at this head. The KiloCode conformance check still fails and is explicitly non-blocking.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41510023316 |
Brings in main up to 94545e7 (#5141, #5384, #5144, #4615, #4954, #5001, #5175). Textual conflict: nemo_gym/cli/env.py, imports only. This branch imports PIPE from subprocess (the server start error capture); main imports SIGKILL from signal (#5141, the shutdown drain). Both are kept: "from signal import SIGINT, SIGKILL" and "from subprocess import PIPE, Popen, TimeoutExpired". Semantic conflict: #5141 starts each server in its own session (run_command(..., start_new_session=True)) so shutdown can signal its process group, while this branch starts servers through RunHelper._spawn_server, which keeps the tail of the error stream. The merged call passed start_new_session to _spawn_server, which did not accept it (11 test_cli failures). _spawn_server now takes start_new_session and forwards it to run_command, so both behaviours hold. The dry-run path keeps this branch's process.wait(): the tail thread of _spawn_server owns the piped stream, so main's communicate() would compete with it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
What does this PR do?
Preserve opaque Responses reasoning when an Anthropic client replays a tool result through Gym's
/v1/messagesbridge. A Gym-ownednemo_gym_responses_reasoning:marker carries nonempty ciphertext verbatim in a thinking signature or, without readable summaries, redacted-thinking data.Emit one block per reasoning item, joining summary text with
\n\n. Streaming emits signature deltas and redacted blocks. Ingress accepts only marked, nonempty ciphertext, explicitly supplies summaries, and skips unsupported redacted history. Unmarked Anthropic signatures retain readable thinking without becoming Responses ciphertext. Native Anthropic provider conversion remains unchanged.Incorporates current main
c69f3b15ff794d6cb49418117748bb16be195cbb. Use main's reasoning input type from #5024 to omit invented replay IDs: Anthropic history has no original Responses item ID, and providers can reject ciphertext paired with a fabricated ID. No new carrier format or schema relaxation.This converter bug has direct reproductions, so a separate tracking issue is unnecessary. Related: #4461 (signature streaming) and #2507 (broader conversion design).
Validation
Runtime tests below ran after the
b36c37b1integration. Main then advanced by three unrelated KiloCode/comparison/Gymnasium commits. The finalc69f3b15merge changes none of this PR's feature code or tests; independent reviews verified equivalence and that the fixes remain necessary. Full hooks were repeated on the final tree.exclude_unset=Trueserialized replay omit invented IDs, retain explicit summaries and preserve exact ciphertext after revalidation.pre-commit run --all-files, Ruff/format and scopedgit diff --checkpassed. The private guardwords scan was skipped because its catalog was unavailable. Independent verifier and simplifier found no remaining defects or redundant production code.Compatibility and limits
The required Responses summary schema and native provider path remain unchanged. Multiple summaries normalize into one joined summary per item. No dependency, authentication, retention, benchmark or scoring change. Fixtures are synthetic; commits have DCO sign-off.
Live model rollout: N/A for this transport correction. Full core/all-server suites, the Linux/tmux-only Terminus test and Linux-only harness probes were not rerun locally on macOS. The earlier upstream baseline had an optional KiloCode conformance failure; final main includes a subsequent KiloCode fix, whose CI outcome is not claimed here. New-head CI still needs the normal maintainer trust approval; no approval comment or review reply was posted.
Proposed maintainer labels:
bug,area:model,needs-review.