fix(proxy): preserve reasoning fields on streaming cache hits - #32096
fix(proxy): preserve reasoning fields on streaming cache hits#32096jesco-absolut wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes async streaming cache-hit replay to preserve
Confidence Score: 5/5Safe to merge — a one-line change that aligns the async replay path with the already-shipped sync path, accompanied by a targeted regression test. The async path was constructing No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py | Replaces explicit four-field Delta construction in the async streaming replay path with Delta(**choice["message"]), matching the existing sync path (line 299). Preserves reasoning_content, thinking_blocks, and any future Delta fields from cached responses. |
| tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py | Adds test_preserves_reasoning_fields covering that the first replay chunk carries reasoning_content and thinking_blocks from the cache while later content-slice chunks do not duplicate them. All new tests; no existing test coverage weakened. |
Reviews (1): Last reviewed commit: "fix(proxy): preserve reasoning fields on..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
df9e379 to
33f60b6
Compare
Relevant issues
Fixes #32068
Linear ticket
N/A
Pre-Submission checklist
make test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Screenshots / Proof of Fix
Streaming cache hits were replayed through
convert_to_streaming_response_async, which rebuiltDeltawith onlycontent,role,function_call, andtool_calls. Cachedreasoning_contentandthinking_blockswere present in the stored response but dropped during replayThe regression test failed before the fix with:
After this change, async streaming replay preserves cached reasoning fields on the first replay chunk while later content-slice chunks still avoid duplicating metadata
Live proxy proof runbook for a reviewer with Redis and a reasoning-capable model configured:
Run the same request twice. Expected behavior: the first request is a cache miss and includes streamed
delta.reasoning_content; the second request is a cache hit and still includes streameddelta.reasoning_contentI could not run this live proxy proof locally because this checkout does not have a Redis-backed proxy and real reasoning provider key configured
Type
Bug Fix
Test
Changes
Follow-up to #31022 in the same reasoning-streaming area
This changes async cached streaming replay to construct
Deltafrom the full cached message dict, matching the sync cached replay path. That preservesreasoning_content,thinking_blocks, and any futureDeltafields instead of hard-coding a small subsetRegression coverage verifies that cached async streaming replay preserves reasoning metadata on the first replay chunk and does not duplicate it on later content-slice chunks
Validation run:
Results: