Skip to content

fix: honor runtime streaming callback precedence - #13405

Draft
shuaiyafei wants to merge 1 commit into
deepset-ai:mainfrom
shuaiyafei:fix/runtime-streaming-callback
Draft

shuaiyafei wants to merge 1 commit into
deepset-ai:mainfrom
shuaiyafei:fix/runtime-streaming-callback

Conversation

@shuaiyafei

Copy link
Copy Markdown

Related Issues

Found through source inspection and reproduced locally. No existing issue is claimed.

Proposed Changes

Honor the documented priority of a runtime streaming callback before checking execution-context compatibility.

Currently, an unused async initialization callback makes a synchronous run fail even when a valid synchronous runtime callback replaces it. Conversely, an unused sync initialization callback produces an event-loop-blocking warning when the selected runtime callback is async.

Validate the initialization callback only when it will be used. Select a provided runtime callback by checking for None, so an empty callable collector is not silently replaced by the initialization callback.

The existing rejection of a selected async callback in a synchronous context and the warning for a selected sync callback in an async context remain covered.

How did you test it?

  • The three affected cases fail before the fix: the sync runtime override, the misleading warning for an unused initialization callback, and an empty callable collection that never receives its chunks.
  • hatch run test:unit test/dataclasses/test_streaming_chunk.py test/components/generators/chat/test_openai.py -q: 97 passed, 12 deselected. Integration tests are excluded by the unit-test command.
  • hatch run test:types on both changed Python files: passed.
  • hatch run fmt on both changed Python files and changed-file pre-commit checks: passed.
  • Normal commit hook: passed.

Tested with Python 3.12.15 on macOS arm64. No live provider request or full-suite run was performed.

Notes for the reviewer

This restores the existing callback-priority contract without adding an API or dependency. The function docstring and a Reno bug-fix note describe the behavior.

This PR was fully generated with Codex. The changed paths were reviewed locally and verified with the tests and checks above.

Checklist

  • Read the contributor guidelines and code of conduct.
  • Added regression coverage and updated the affected docstring.
  • Used a conventional commit title.
  • Added a release note through the repository's Reno command.
  • Ran formatting, typing, and pre-commit checks.

@shuaiyafei
shuaiyafei requested a review from a team as a code owner October 23, 2026 08:20
@shuaiyafei
shuaiyafei requested review from anakin87 and removed request for a team October 23, 2026 08:20
@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@shuaiyafei is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @shuaiyafei, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from anakin87 October 23, 2026 09:32
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Oct 23, 2026
@HaystackBot
HaystackBot marked this pull request as draft October 23, 2026 09:32
@github-actions github-actions Bot added the type:documentation Improvements on the docs label Oct 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/dataclasses
  streaming_chunk.py
Project Total  

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

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

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

Labels

cla-pending PR is in draft until the contributor signs the CLA topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants