Skip to content

feat: use StreamingChunk.reasoning field in Ollama chat generator#2850

Open
yaowubarbara wants to merge 1 commit intodeepset-ai:mainfrom
yaowubarbara:fix/ollama-streaming-reasoning
Open

feat: use StreamingChunk.reasoning field in Ollama chat generator#2850
yaowubarbara wants to merge 1 commit intodeepset-ai:mainfrom
yaowubarbara:fix/ollama-streaming-reasoning

Conversation

@yaowubarbara
Copy link

Summary

This mirrors the approach from #2849 (Anthropic) for the Ollama integration:

  • Populate StreamingChunk.reasoning with ReasoningContent instead of stuffing thinking data into meta["reasoning"]
  • Update the accumulation logic in both sync and async streaming handlers to read from chunk.reasoning
  • Update test assertions accordingly

The Ollama case is simpler than Anthropic since there are no signatures or redacted thinking blocks — just a plain message.thinking string per chunk.

Changes

  • _build_chunk(): create ReasoningContent from the thinking field and pass it as the reasoning kwarg
  • _handle_streaming_response() / _handle_streaming_response_async(): read c.reasoning.reasoning_text instead of c.meta.get("reasoning")
  • Tests: assert on chunk.reasoning.reasoning_text instead of chunk.meta["reasoning"]

Related: deepset-ai/haystack#10481
Related: deepset-ai/haystack#9785 (parent tracking issue)

Populate the dedicated StreamingChunk.reasoning field with
ReasoningContent instead of storing thinking data in meta dict.
Update accumulation logic and tests accordingly.

Closes deepset-ai/haystack#10481
@yaowubarbara yaowubarbara requested a review from a team as a code owner February 17, 2026 15:21
@yaowubarbara yaowubarbara requested review from bogdankostic and removed request for a team February 17, 2026 15:21
@CLAassistant
Copy link

CLAassistant commented Feb 17, 2026

CLA assistant check
All committers have signed the CLA.

@sjrl
Copy link
Contributor

sjrl commented Feb 18, 2026

Once all comments on #2849 are resolved let's make sure to bring all learnings to this PR as well.

@sjrl sjrl self-assigned this Feb 18, 2026
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.

3 participants