Skip to content

fix: preserve reasoning from compatible Chat Completions providers - #13101

Closed
carey-bk wants to merge 1 commit into
deepset-ai:mainfrom
carey-bk:fix/openai-chat-reasoning-13100
Closed

carey-bk wants to merge 1 commit into
deepset-ai:mainfrom
carey-bk:fix/openai-chat-reasoning-13100

Conversation

@carey-bk

@carey-bk carey-bk commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes

Preserve non-empty string reasoning / reasoning_content response extras in the existing ChatMessage.reasoning and StreamingChunk.reasoning fields. Prefer reasoning, fall back to reasoning_content, and ignore empty or non-string values.

Split mixed reasoning/text/tool deltas because a StreamingChunk permits only one payload type. Signal finish/usage on the last derived chunk. Once reasoning appears, track content-block indices separately from provider tool indices: ToolCallDelta.index stays unchanged so argument reconstruction and final tool ordering remain stable, including sparse or out-of-order indices. Without reasoning, preserve the existing chunk indices and start markers.

Update the docstring, component docs, and release note. No schema, dependency-bound, outgoing reasoning-replay, or Responses API changes.

How did you test it?

Offline HTTP JSON/SSE fixtures exercise real SDK parsing and public sync/async generator calls, with network sockets blocked.

  • Relevant OpenAI, Azure, and generator-utils tests: 203 passed, 20 integration tests deselected in each environment: Python 3.12.14 / OpenAI 3.24.0; Python 3.12.14 / OpenAI 2.6.0; Python 3.10.21 / OpenAI 2.6.0.
  • The 88 new cases on unchanged 87dba65f: 54 failed, 34 passed. All 22 ordinary-stream compatibility cases also pass on that baseline.
  • Changed-file mypy, Ruff lint/format, applicable pre-commit hooks, and reno lint passed. Full-tree mypy has the same three baseline errors (yaml.py:40, test_device.py:60, document_splitter.py:276).

These checks used focused Hatch environments. Live providers, the full unit suite, and the full docs build were not run.

Notes for the reviewer

Please review whether these non-standard fields belong in the generic generator or provider-specific integrations, given the historical discussion in #8776. A provider delta may now produce multiple callbacks when reasoning is present. #13079 addresses the separate Responses API path.

The implementation and tests were generated with AI assistance; the assistant performed the local validation above. Personal contributor attestations are left unchecked for human review.

Checklist

  • I have read the contributors guidelines and code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I have used a conventional commit type for the PR title.
  • I have documented my code.
  • I have added a release note.
  • I have run pre-commit hooks and fixed applicable issues.

@vercel

vercel Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

@carey-bk is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Oct 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/generators
  utils.py
  haystack/components/generators/chat
  openai.py 712, 817
Project Total  

This report was generated by python-coverage-comment-action

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

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAIChatGenerator drops reasoning / reasoning_content from OpenAI-compatible providers (streaming and non-streaming)

1 participant