Repository navigation
fix(sse): include prompt cache usage fields on message_stop fallback path - #10545
Merged
diegosouzapw merged 1 commit intoAug 21, 2026
Conversation
…path claude-to-openai.ts built the final OpenAI-format usage payload in two places: the message_delta finish path (which already mapped cache_read/ cache_creation into prompt_tokens_details) and a message_stop fallback used when the finish signal arrives without usage attached to the same event. The fallback never copied the cache fields, so OpenAI-compatible clients saw 0% cache hit even though the data was present in state.usage. Fixes cheaper-inference#10535
Collaborator
|
The focused translator suite passes 15/15 and lint is clean. Before marking this merge-ready, |
diegosouzapw
merged commit Aug 21, 2026
00aba8e
into
cheaper-inference:release/v3.8.50
3 checks passed
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…path (cheaper-inference#10545) Mirrors the existing prompt_tokens_details cache-field mapping from the message_delta finish path into the message_stop fallback, so OpenAI-compatible clients see cache_read/cache_creation counters when the finish signal arrives without usage on the same event. Fixes cheaper-inference#10535. Validated in an isolated worktree boarded onto origin/release/v3.8.50 (0 conflicts, 2 files): - 16/16 focused tests pass (translator-resp-claude-to-openai.test.ts), including the new regression test for this exact fallback path. - check-file-size, check-changelog-integrity: OK. - typecheck:core: clean. - check-complexity / check-cognitive-complexity: OK, both under baseline. Co-authored-by: NahuSaruf <NahuSaruf@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
claude-to-openai.tsbuilt the final OpenAI-formatusagepayload in two places: themessage_deltafinish path (already mappedcache_read/cache_creationintoprompt_tokens_details) and amessage_stopfallback used when the finish signal arrives without usage on the same event.state.usage(matches the report: Claude-format responses had the counters, OpenAI-format ones didn't).prompt_tokens_detailsmapping from themessage_deltapath into themessage_stopfallback.Fixes #10535
Test plan
node --import tsx/esm --test tests/unit/translator-resp-claude-to-openai.test.ts— 16/16 passing.npm run typecheck:core— clean.npm run lint(suppressions applied) — no new violations on the two changed files.