Repository navigation
fix(proxy): keep reasoning_items on the streaming fast-serialization path - #38908
CNSeniorious000 wants to merge 3 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Greptile SummaryThis PR prevents streaming proxy responses from dropping
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness or security issues identified. The new guard handles every non-
|
| Filename | Overview |
|---|---|
| litellm/proxy/proxy_server.py | Correctly routes deltas containing reasoning_items away from the limited fast serializer and into canonical serialization. |
| tests/test_litellm/proxy/proxy_server/test_streaming_helpers.py | Adds representative regression coverage using production response models and the actual streaming serialization entry point. |
Reviews (1): Last reviewed commit: "fix(proxy): keep reasoning_items on the ..." | Re-trigger Greptile
Merging this PR will not alter performance
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Independent confirmation of this bug on a production gateway, and of the fix. Setup: LiteLLM proxy v1.101.0 (stock ghcr image), Azure OpenAI GPT reasoning model via the Responses→Chat bridge, Observed on the wire (unpatched): the terminal chunk that should carry No Evidence it is the fast serializer: those two chunks are the only ones in the stream with key order Fix verification: cherry-picked this PR's one-line change onto v1.101.0 and onto current We need this on our gateways and will carry the patch locally until it lands. Would appreciate a maintainer look; #38961 is the same change without the test. |
ba8d403 to
20d4a0d
Compare
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20d4a0d5dc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a5535793a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| chunk.choices[0].delta.reasoning_items = [ | ||
| {"id": "rs_abc", "type": "reasoning", "encrypted_content": "ENCRYPTED-BLOB"} | ||
| ] | ||
| assert _fast_serialize_simple_model_response_stream(chunk) is None |
There was a problem hiding this comment.
Drop the fast-path sentinel regression test
When fast serialization later supports reasoning_items directly, this assertion fails despite identical output; keep only the output-level serialization regression below.
AGENTS.md reference: AGENTS.md:L26-L26
Useful? React with 👍 / 👎.
| chunk = _simple_chunk(content="") | ||
| chunk.choices[0].delta.reasoning_items = [ | ||
| {"id": "rs_abc", "type": "reasoning", "encrypted_content": "ENCRYPTED-BLOB"} | ||
| ] |
There was a problem hiding this comment.
Construct complete Final chunks without mutation
These tests leave chunk unannotated and mutate its delta after setup; build complete Final chunks to keep their arrange phase immutable.
AGENTS.md reference: AGENTS.md:L96-L97
Useful? React with 👍 / 👎.
|
Closing as superseded by #49398, which deleted the streaming fast path that dropped reasoning_items from chunks. Thanks for the fix |
Description
Streaming chat completions through the proxy now preserve encrypted reasoning state, so clients can send it back on the next turn. Two regression tests cover the fast-path guard and the complete serialized response
Details
Relevant issues
Fixes #38907
Changes
The Responses-to-chat bridge can emit an empty-content chunk carrying
reasoning_items. The proxy's fast serializer treats that chunk as plain text and drops the encrypted stateAdd
reasoning_itemstounsupported_delta_fieldsso these chunks use the existingmodel_dump_json(exclude_none=True, exclude_unset=True)fallbackUser Flow
Before, the streamed response loses the reasoning state needed for the next turn
After, the streamed response preserves the reasoning state
Validation
Latest validation at 5a55357, after merging main at 81d8c9a
Ruff with
ruff-tests.tomlpasses for the streaming helper tests, andruff format --checkpasses forlitellm/proxy/proxy_server.pyThe merged main includes the test-isolation fix from #47559 and the CI scripts required by the current lint workflow
On this commit, Python lint and the root unit shard pass. The root shard reports 6981 passed and 1 skipped, including the previously failing GPT-4o function-calling case
Pre-Submission checklist
Type
Bug Fix
Caveats
Medium
The scan reports GHSA-698v-4r3x-3vcv for Vite 7.3.5 in the dashboard lockfile and 8.3.0 in the extension lockfile. Both lockfiles are identical to main at 81d8c9a
Low
The original live-proxy observation is recorded in #38907. Current validation covers serialization and unit tests