Skip to content

fix: preserve streamed provider thinking blocks - #4177

Merged
seratch merged 1 commit into
mainfrom
fix/streamed-anthropic-thinking-replay
Aug 4, 2026
Merged

seratch merged 1 commit into
mainfrom
fix/streamed-anthropic-thinking-replay

Conversation

@seratch

@seratch seratch commented Aug 4, 2026

Copy link
Copy Markdown
Member

This pull request fixes thinking-block preservation for LiteLLM-backed Chat Completions streams.

Streaming responses now retain the complete ordered sequence of signed and redacted thinking blocks for client-managed replay. Reasoning items are finalized before their done events, thinking-only streams produce replayable items, opaque provider metadata survives round trips, and assistant message content indexes remain consistent when reasoning occupies a separate output slot.

A runtime probe using LiteLLM 1.83.0 verified that multiple signed thinking blocks and an interleaved redacted block survive stream transformation, SDK event serialization, and outbound converter replay without losing their order, signatures, or provider metadata.

The implementation also preserves the released normalized reasoning text and final-signature behavior while rejecting malformed interpreted thinking fields before emitting an item.

Co-authored-by: abhay-codes07 <abhaysingh0293@gmail.com>
@seratch seratch added this to the 0.19.x milestone Aug 4, 2026
@seratch
seratch enabled auto-merge (squash) August 4, 2026 23:01
@seratch
seratch merged commit d3463f2 into main Aug 4, 2026
9 checks passed
@seratch
seratch deleted the fix/streamed-anthropic-thinking-replay branch August 4, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant