Repository navigation
fix(openai): preserve streaming service tier - #38294
Closed
daleselaji-dev wants to merge 1 commit into
Closed
daleselaji-dev wants to merge 1 commit into
daleselaji-dev wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
|
devin-ai-integration
Bot
changed the base branch from
litellm_internal_staging
to
main
September 23, 2026 14:55
Contributor
|
Main already keeps the served service_tier on streamed chunks since #42870 landed, so closing this. Please reopen if something is missing |
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.
Problem
OpenAI-compatible streaming responses can include a provider-served
service_tiersuch aspriority, but LiteLLM'sOpenAIChatCompletionStreamingHandler.chunk_parserrebuilds each chunk from a fixed field set and drops that metadata. This prevents downstream hooks, assembled streaming responses, and billing diagnostics from verifying the tier actually served.Root Cause
The parser copied
id,object,created,model,choices, and optionalusage, but never copied a non-nullservice_tierfield from the raw provider chunk.Solution
Preserve a non-null
service_tierin the normalizedModelResponseStream, matching the existing optionalusagepass-through pattern.Changes
service_tierpass-through inOpenAIChatCompletionStreamingHandler.chunk_parser.Testing
tests/test_litellm/llms/openai/chat/test_openai_gpt_transformation.py— 49 passed..venv\Scripts\ruff.exe checkon both changed files — passed..venv\Scripts\python.exe -m compileallon both changed files — passed.git diff --check— passed.ruff format --checkwas attempted; the Windows checkout has mixed CRLF/LF normalization and the formatter reports existing formatting differences in these files. The repository HEAD passed the formatter through normalized stdin; no unrelated format rewrite was included.basedpyrightwas attempted; it reports 333 repository-existing diagnostics across the touched module/test and is not a clean typecheck signal for this two-line behavior change. No typecheck pass is claimed.Compatibility/Risk
Low-risk parser-only metadata preservation. Providers that do not send
service_tierare unchanged. The field is optional and already supported by LiteLLM response models and downstream service-tier utilities.Notes for Reviewer
The regression uses a mocked raw chunk and verifies the normalized response exposes
priority. The existing xAI handler inherits this parser, so no provider-specific branch is needed. The fork may still require the repository CLA gate before merge.Linked Issue
Fixes #38247
Repository Gates