Skip to content

fix: return ContentThinkingDelta from completions provider streaming#301

Merged
cpsievert merged 1 commit into
mainfrom
fix/streaming-thinking-delta
May 12, 2026
Merged

fix: return ContentThinkingDelta from completions provider streaming#301
cpsievert merged 1 commit into
mainfrom
fix/streaming-thinking-delta

Conversation

@cpsievert
Copy link
Copy Markdown
Collaborator

Summary

  • OpenAICompletionsProvider.stream_content() was returning ContentThinking (the finalized type for completed turns) instead of ContentThinkingDelta (the streaming fragment type)
  • The TurnAccumulator only recognizes ContentThinkingDelta for thinking block handling, so thinking content was silently dropped during streaming
  • Affects all completions-based providers: DeepSeek, Groq, OpenRouter, HuggingFace, LMStudio, Mistral, Ollama, etc.

Closes #300

Test plan

  • Existing test_stream_content_extracts_reasoning_content updated to assert ContentThinkingDelta
  • All 11 tests in test_stream_thinking.py pass (verify thinking deltas flow through TurnAccumulator correctly)
  • test_response_as_turn_extracts_reasoning_content still passes (non-streaming path unchanged)
  • Pyright passes with 0 errors

OpenAICompletionsProvider.stream_content() was returning ContentThinking
(the finalized type) instead of ContentThinkingDelta (the streaming
fragment type). The TurnAccumulator only recognizes ContentThinkingDelta,
so thinking content was silently dropped during streaming for all
completions-based providers (DeepSeek, Groq, OpenRouter, etc.).

Closes #300
@cpsievert cpsievert requested a review from Copilot May 12, 2026 14:20
@cpsievert cpsievert merged commit e990727 into main May 12, 2026
9 checks passed
@cpsievert cpsievert deleted the fix/streaming-thinking-delta branch May 12, 2026 14:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes streaming “thinking/reasoning” handling for completions-based providers by ensuring streaming chunks emit ContentThinkingDelta (the expected streaming fragment type) instead of ContentThinking (the finalized, non-streaming type), allowing TurnAccumulator to correctly detect and surface thinking blocks during streaming.

Changes:

  • Update OpenAICompletionsProvider.stream_content() to return ContentThinkingDelta when reasoning_content is present.
  • Update the corresponding unit test to assert ContentThinkingDelta is produced for reasoning chunks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
chatlas/_provider_openai_completions.py Emit ContentThinkingDelta for reasoning_content during streaming so downstream streaming logic can recognize thinking chunks.
tests/test_provider_openai_completions.py Adjust test to validate the corrected streaming content type for reasoning chunks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants