Skip to content

fix: OpenAIResponsesChatGenerator filter streaming event fields from reasoning extra before call to Responses API#11720

Open
davidsbatista wants to merge 1 commit into
mainfrom
fix/OpenAIResponses
Open

fix: OpenAIResponsesChatGenerator filter streaming event fields from reasoning extra before call to Responses API#11720
davidsbatista wants to merge 1 commit into
mainfrom
fix/OpenAIResponses

Conversation

@davidsbatista

@davidsbatista davidsbatista commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes:

  • In Previous PR Fix streaming reasoning conversion to preserve extra fields #11669: streaming response.reasoning_summary_text.delta events spread event-level fields (item_id, output_index, summary_index, etc.) into ReasoningContent.extra. When sent back in next calls the API rejected them with Unknown parameter: 'input[N].item_id'.

  • Fix filters reasoning.extra to only valid reasoning input item fields (id, type, encrypted_content, status) before serialising.

How did you test it?

  • Integration test test_live_run_with_agent_streaming_and_reasoning — was failing Windows without the fix, passes with it.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Jun 22, 2026 4:50pm

Request Review

@davidsbatista davidsbatista added the ignore-for-release-notes PRs with this flag won't be included in the release notes. label Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/generators/chat
  openai_responses.py
Project Total  

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

@davidsbatista davidsbatista changed the title discard streaming event fields from reasoning items before sending to… fix: OpenAIResponsesChatGenerator filter streaming event fields from reasoning extra before call to Responses API Jun 22, 2026
@davidsbatista davidsbatista marked this pull request as ready for review June 22, 2026 17:02
@davidsbatista davidsbatista requested a review from a team as a code owner June 22, 2026 17:02
@davidsbatista davidsbatista requested review from bogdankostic and removed request for a team June 22, 2026 17:02
Comment on lines +934 to 938
_valid_reasoning_fields = {"id", "type", "encrypted_content", "status"}
filtered_extra = {k: v for k, v in reasoning.extra.items() if k in _valid_reasoning_fields}
reasoning_item = {"summary": [], **filtered_extra}
if reasoning.reasoning_text:
reasoning_item["summary"] = [{"text": reasoning.reasoning_text, "type": "summary_text"}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@davidsbatista It seems there is one more supported field I think according to docs here https://developers.openai.com/api/reference/resources/responses/methods/retrieve#(resource)%20responses%20%3E%20(model)%20response_output_item%20%3E%20(schema)%20%3E%20(variant)%207

I think the content field as well which is structured similarly to summary. I'm not entirely sure how we are meant to distinguish between summary and content fields currently.

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

Labels

ignore-for-release-notes PRs with this flag won't be included in the release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants