Skip to content

fix(openai): preserve zero cached tokens when reporting is enabled - #44010

Open
EazyReal wants to merge 1 commit into
sgl-project:mainfrom
EazyReal:vmax/fix-cache-report-zero-only
Open

EazyReal wants to merge 1 commit into
sgl-project:mainfrom
EazyReal:vmax/fix-cache-report-zero-only

Conversation

@EazyReal

@EazyReal EazyReal commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

With --enable-cache-report, an uncached request currently returns prompt_tokens_details: null. This preserves {"cached_tokens": 0} so clients can distinguish a zero cache hit from disabled reporting.

Applies the reporting flag consistently to buffered responses, final streaming usage, and Chat continuous usage. Adds regression coverage for zero, positive, and disabled-reporting cases. Existing multiple-choice aggregation and multimodal details are preserved.

Split from my original fix in #28801, which now covers the separate legacy Completions continuous-usage change. Related: #43005. Thanks to @ai-jz for helping narrow the scope.

Validation: pre-commit and git diff --check passed. Isolated usage and serialization checks passed; the zero-value regression cases fail on unchanged main. Full registered handler tests were not run locally because PyTorch/FastAPI are unavailable.

Split the zero-value reporting fix from sgl-project#28801, retaining the original flag-gated helper and tests. Leave the legacy Completions continuous-usage addition for a separate change.
EazyReal added a commit to EazyReal/sglang that referenced this pull request Oct 13, 2026
Keep only the legacy Completions remainder of sgl-project#28801; the response/final-stream and Chat zero-value fix is split into sgl-project#44010. Credit @rlrs for the earlier investigation in sgl-project#20203.

This branch has not been deployed

No deployments
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.

1 participant