Repository navigation
fix(responses-streaming): integer usage detail counts on the wire - #3968
Conversation
linj-glitch
left a comment
There was a problem hiding this comment.
Reviewed the synthesized SSE usage normalization and the streaming/capture contracts in #3382. No logical issues found. Missing or null detail counts become integers only in the SSE envelope; known counts, totals, extension fields, and the caller's original response remain unchanged. The streaming, base model, and external capture integration suites pass 377 tests on this head with Python 3.13.14 and locked dependencies; full pre-commit checks pass. Additional checks cover missing, empty, null, and known detail values and source immutability. No fixes needed. Approval is for this head; required CI and merge-queue validation still apply.
Gym keeps an unreported cache or reasoning token breakdown as None internally to tell unknown from zero. On the wire the Responses schema types those counts as integers, and a strict streaming client that meets null fails to parse response.completed, treats the stream as disconnected, and re-sends the whole request: the Codex CLI retried every call five times. The synthesized SSE envelope fills zeros; the internal object is unchanged. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
0d39f28 to
ac68e3a
Compare
linj-glitch
left a comment
There was a problem hiding this comment.
Re-reviewed after rebasing onto main (1f2446c). The patch is preserved and the branch is linear. All 377 relevant streaming, base-model, and external-capture tests and pre-commit run --all-files passed on this head. The wire envelope supplies integer detail counts without mutating the original internal usage object. No remaining logical issue found in the scoped changes.
|
/ok to test ac68e3a |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37273437087 |
What does this PR do?
Gym keeps an unreported cache or reasoning token breakdown as
Noneinternally, to tell "unknown" from "zero". On the wire, the Responses schema typesinput_tokens_details.cached_tokensandoutput_tokens_details.reasoning_tokensas integers. A strict streaming client that meetsnullthere fails to parseresponse.completed, treats the stream as disconnected, and re-sends the whole request: the Codex CLI retried every call five times before giving up on the turn.synthesize_responses_ssenow passes the usage object through_wire_usage, which fills a missing orNonedetail count with0in the synthesized SSE envelope only. The internal response object and the non-streaming path are unchanged.Issue
No issue filed; the defect was observed as five identical retries of every streaming call from the Codex CLI, each logged by the engine as a complete generation.
Validation
tests/unit_tests/test_responses_api_model_streaming.pygainstest_unknown_usage_details_are_integers_on_the_wire, which synthesizes the SSE stream for a response whose detail counts areNoneand asserts theresponse.completedpayload carries integers.pytest tests/unit_tests, with the telemetry tests andtest_collect_downstream_junit.pyexcluded for missing local packages): 6229 passed, 27 skipped, 1 failed. The one failure istest_slurm_script.py::test_build_vllm_ray_serve_command_single_node_model_with_space_survives_quoting, which needs apipthat this machine's externally managed Python refuses; it fails identically onmain.ruff checkandruff format --checkon the changed files: clean.🤖 Generated with Claude Code