Repository navigation
Conversation
vLLM returns thinking blocks without a signature, and the synthesized Messages stream never sent a signature_delta. Some clients turn an unsigned thinking block into a text block when they replay history, so the next request rewrites the assistant turn and token capture splits every model call into its own training path. Set NEMO_GYM_ANTHROPIC_THINKING_SIGNATURE to put a placeholder signature on thinking blocks that have none, and stream any signature as a signature_delta. Off by default. Signed-off-by: Christian Munley <[email protected]>
727583f to
522aabf
Compare
|
/review |
|
/ok to test 522aabf |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — the placeholder signature breaks replay through Chat Completions-backed vLLM servers, and streamed observability captures discard the newly emitted signatures.
Reviewed both changed files and traced signature generation, SSE synthesis, request replay, and capture reconstruction. Two findings below. Validation was source-only; tests could not be executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex
| "type": "thinking", | ||
| "thinking": summary["text"], | ||
| "signature": item.get("encrypted_content") or "", | ||
| "signature": item.get("encrypted_content") or _PLACEHOLDER_SIGNATURE, |
There was a problem hiding this comment.
BLOCKER — Consume the placeholder signature on replay
Failure / blast radius: Start Gym with NEMO_GYM_ANTHROPIC_THINKING_SIGNATURE=gym-unsigned, obtain a thinking block from /v1/messages, and replay that block in the next request. The ingress thinking branch copies gym-unsigned into encrypted_content. VLLMModel.responses then downconverts through ResponsesConverter._format_reasoning, which rejects every nonempty encrypted_content. Thus clients that preserve thinking as intended now fail the next model call with NotImplementedError/HTTP 500 instead of continuing the rollout. Both streaming and non-streaming Messages replies introduce this sentinel.
Correction: Treat the configured placeholder as a reserved, wire-only sentinel. In _append_anthropic_blocks_as_items's thinking branch, replace the encrypted_content argument with:
encrypted_content=(
None
if _PLACEHOLDER_SIGNATURE
and block.get("signature") == _PLACEHOLDER_SIGNATURE
else block.get("signature")
),Keep adding the placeholder on outbound Messages replies. Do not remove the shared Chat converter's guard or strip arbitrary signatures: genuine opaque reasoning must still be preserved or rejected rather than silently discarded. This targeted suggestion needs author verification.
Preservation / proposed acceptance checks: With the sentinel configured, render unsigned reasoning step plus text ok, replay the resulting thinking/text blocks through ingress, then downconvert with ResponsesConverter(return_token_id_information=False). Assert the replayed reasoning has encrypted_content is None and the assistant chat content is ok, without an exception. Cover the SSE-produced replay too. Retain the existing unsigned/default-empty behavior when the setting is unset and the placeholder emission assertions. A distinct real signature such as sig-1 must still survive ingress unchanged, as asserted by test_thinking_block_becomes_reasoning_item; the opaque-content rejection test must continue raising. These checks were not executed.
| return [{"type": "thinking_delta", "thinking": block.get("thinking", "")}] | ||
| deltas = [{"type": "thinking_delta", "thinking": block.get("thinking", "")}] | ||
| if block.get("signature"): | ||
| deltas.append({"type": "signature_delta", "signature": block["signature"]}) |
There was a problem hiding this comment.
RISK — Update capture reconstruction for the new signature delta
Failure / blast radius: Stream a thinking block with signature s through a rollout-correlated Messages endpoint with observability enabled. This new event delivers s to the client, but _reconstruct_anthropic_sse handles only text, thinking, and tool-input deltas. The capture middleware persists that reconstruction, so its parsed response contains signature: "" while the served response contains signature: "s". The same mismatch affects placeholder signatures. Raw SSE remains available, but consumers of the structured captured response lose the signature needed for faithful replay.
Correction: Add this branch to _reconstruct_anthropic_sse, adjacent to thinking_delta and before input_json_delta:
elif dtype == "signature_delta":
block["signature"] = (block.get("signature") or "") + (
delta.get("signature") or ""
)The invariant is that capture reconstructs the same thinking text and signature delivered on the wire, including fragmented signatures. Keep the signature in deltas rather than moving it into the start shell. Suggested code is source-reasoned, not executed; verify before adopting.
Preservation / proposed acceptance checks: Synthesize a complete message containing signed thinking, text, and a tool call, then pass the encoded SSE to _reconstruct_streamed_response(..., "messages"); assert reconstructed content equals the original content for both s and gym-unsigned. Also assert signature fragments a and b reconstruct as ab, and unsigned thinking remains unsigned. Preserve the existing capture regression assertions: input/output token counts remain 17/7, reasoning remains let me think, the tool arguments remain {"x": 1}, and response_raw remains identical to the forwarded SSE. These checks were not executed.
|
/ok to test 522aabf |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — both prior findings remain unresolved: placeholder replay still fails, and capture reconstruction still drops streamed signatures.
Same-head follow-up to review 5577278701. Rechecked both changed files and traced the directly affected replay and capture paths. There are no inter-review changes or verified fixes; no fresh whole-PR discovery was performed. Validation was source-only; tests were not executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
| "type": "thinking", | ||
| "thinking": summary["text"], | ||
| "signature": item.get("encrypted_content") or "", | ||
| "signature": item.get("encrypted_content") or _PLACEHOLDER_SIGNATURE, |
There was a problem hiding this comment.
BLOCKER — Consume the placeholder signature on replay
Still unresolved from review 5577278701, comment 4318466390.
Failure / blast radius: Set NEMO_GYM_ANTHROPIC_THINKING_SIGNATURE=gym-unsigned, obtain unsigned reasoning step plus text ok from /v1/messages, and replay the returned thinking/text blocks. The ingress thinking branch copies the placeholder into encrypted_content. VLLMModel.responses downconverts through ResponsesConverter._format_reasoning, which rejects nonempty encrypted content. Clients preserving thinking therefore fail their next model call with NotImplementedError/HTTP 500 instead of continuing. Both JSON and synthesized SSE replies introduce this sentinel.
Correction: Reserve the configured placeholder as a wire-only sentinel. In _append_anthropic_blocks_as_items's thinking branch, replace the encrypted_content argument with:
encrypted_content=(
None
if _PLACEHOLDER_SIGNATURE
and block.get("signature") == _PLACEHOLDER_SIGNATURE
else block.get("signature")
),Keep outbound placeholder emission. Only the configured sentinel should be consumed; do not strip arbitrary signatures or weaken the shared Chat converter's opaque-content guard.
Preservation / proposed acceptance checks: With the sentinel configured, render unsigned step plus text ok, replay the JSON blocks and separately the client-assembled SSE blocks, then downconvert using ResponsesConverter(return_token_id_information=False). Assert the reasoning retains summary step, has encrypted_content is None, and produces assistant content ok without raising. With the setting unset, retain empty outbound signatures and no signature delta. Preserve the placeholder/default and genuine-signature output assertions. A distinct genuine signature sig-1 must still survive ingress unchanged, as in the existing ingress test, and opaque reasoning rejection must continue raising. Suggested code is source-reasoned, not executed; verify before adopting.
| return [{"type": "thinking_delta", "thinking": block.get("thinking", "")}] | ||
| deltas = [{"type": "thinking_delta", "thinking": block.get("thinking", "")}] | ||
| if block.get("signature"): | ||
| deltas.append({"type": "signature_delta", "signature": block["signature"]}) |
There was a problem hiding this comment.
RISK — Reconstruct signature deltas in streamed captures
Still unresolved from review 5577278701, comment 4318466398.
Failure / blast radius: Stream a thinking block with signature s through a rollout-correlated Messages endpoint with observability enabled. The client receives signature_delta, but _reconstruct_anthropic_sse handles only text, thinking, and tool-input deltas. The capture middleware persists that reconstruction, leaving signature: "" in the structured response instead of signature: "s". Placeholder signatures are also lost. Raw SSE remains intact, but structured captures cannot faithfully replay the served thinking block.
Correction: In _reconstruct_anthropic_sse, insert this branch after thinking_delta, before input_json_delta:
elif dtype == "signature_delta":
block["signature"] = (block.get("signature") or "") + (
delta.get("signature") or ""
)The invariant is that reconstruction preserves the signature delivered on the wire, including fragments. Keep the empty start shell and signature-delta protocol; do not move the signature into the shell to bypass reconstruction.
Preservation / proposed acceptance checks: Generate a complete thinking/text/tool response with anthropic_response_to_sse, encode it, and call _reconstruct_streamed_response(..., "messages"). Assert reconstructed content equals the original for signatures s, gym-unsigned, and ""; separately assert fragments a and b reconstruct as ab. Unsigned input with no signature field must remain without one when no signature delta occurs. Retain the stream tests' empty-shell, ordered-delta, and unsigned-no-delta assertions. Preserve the capture regression: token counts 17/7, reasoning let me think, tool arguments {"x": 1}, and response_raw identical to forwarded SSE. Suggested code and checks are source-reasoned, not executed; verify before adopting.
…inking-signature Signed-off-by: Christian Munley <[email protected]>
…signature deltas The placeholder signature only exists on the wire. When a client replayed a thinking block that carried it, ingress copied it into encrypted_content, and the Chat Completions conversion behind vLLM rejects any encrypted content, so the next model call failed. Ingress now treats the configured placeholder as absent. Real signatures are still forwarded unchanged. Streamed capture reconstruction ignored signature_delta events, so the structured capture lost the signature the client received. It now appends signature deltas to the block, including fragmented signatures. Signed-off-by: Christian Munley <[email protected]>
|
/ok to test 522ab8a |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — both prior findings are fixed; no eligible regressions found in this follow-up.
- Placeholder replay now clears only the configured sentinel in ingress conversion, retaining the reasoning summary and distinct genuine signatures. The new regression tests cover successful Chat conversion and genuine-signature preservation; the shared opaque-reasoning guard remains intact.
- Streamed capture now accumulates signature deltas. The new reconstruction tests cover genuine, placeholder, empty, and fragmented signatures alongside thinking, text, and tool blocks.
Compared against the previous reviewed head, inspected all four changed files, and traced the directly affected replay and capture paths. This was a scoped follow-up, not a fresh whole-PR review. Validation was source-only; tests were not executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
vLLM returns thinking blocks without a signature, and the synthesized Messages stream never sent a
signature_delta. Some clients replay an unsigned thinking block as a text block, which rewrites the assistant turn on the next request. Token capture then starts a new training path for every model call (40-56 per rollout in a run, instead of ~1).NEMO_GYM_ANTHROPIC_THINKING_SIGNATURE(off by default) puts a placeholder signature on unsigned thinking blocks, and the SSE synthesizer now streams signatures assignature_delta. In a small Gym eval this took affected clients from 170-240 paths to 4. Unit tests added.