Skip to content

fix(sse): read Responses-style usage names in OpenAI to Claude streaming - #14205

Merged
diegosouzapw merged 4 commits into
diegosouzapw:release/v3.8.51from
soroush5:fix/openai-claude-responses-usage
Sep 29, 2026
Merged

diegosouzapw merged 4 commits into
diegosouzapw:release/v3.8.51from
soroush5:fix/openai-claude-responses-usage

Conversation

@soroush5

Copy link
Copy Markdown
Contributor

The streaming translator only read prompt_tokens/completion_tokens, so upstreams reporting Responses-style input_tokens/output_tokens left Claude clients with zeroed usage. It now reads both namings like the rest of the pipeline.

Verified: 4 new tests fail before and pass after, neighbors green.

Fixes #14204

trackUsageFromChunk only read prompt_tokens/completion_tokens, so
upstreams reporting input_tokens/output_tokens left Claude clients
with 0/0 usage. Fall back to the Responses names (and
input_tokens_details) the way stream.ts and usageTracking.ts do.

Refs diegosouzapw#14204
@diegosouzapw

Copy link
Copy Markdown
Owner

Nice catch — this brings the Claude-format streaming translator in line with what open-sse/utils/stream.ts already does for the same prompt_tokens/input_tokens ambiguity, so it's a consistency fix rather than a new pattern. The precedence test (OpenAI naming wins when both are present) is the right call for safety. Merging.

One small item: please add a changelog.d fragment (the merge-integrity gate requires one) — or we'll add it at merge time.

@soroush5

Copy link
Copy Markdown
Contributor Author

Added the changelog fragment. Thanks for merging.

Moves the Chat/Responses usage-name fallback into firstNumber() and
readUsageCounters() so trackUsageFromChunk stays under the complexity
ratchet. Behavior unchanged; covered by the diegosouzapw#14204 tests.
@diegosouzapw
diegosouzapw merged commit 844a342 into diegosouzapw:release/v3.8.51 Sep 29, 2026
11 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(backend): OpenAI to Claude streaming reports 0/0 usage when upstream uses Responses token names

2 participants