Skip to content

Fix streaming reasoning conversion to preserve extra fields#11669

Open
shr8769 wants to merge 2 commits into
deepset-ai:mainfrom
shr8769:main
Open

Fix streaming reasoning conversion to preserve extra fields#11669
shr8769 wants to merge 2 commits into
deepset-ai:mainfrom
shr8769:main

Conversation

@shr8769

@shr8769 shr8769 commented Jun 17, 2026

Copy link
Copy Markdown

Root Cause:
OpenAI Responses API v2 sends encrypted_content and other metadata in reasoning items to preserve reasoning context across multi-turn conversations. However, _convert_streaming_chunks_to_chat_message() was discarding all extra fields except id and type, breaking multi-turn reasoning interactions.

Fix Summary:
Modified lines 810-824 of openai_responses.py to aggregate all extra fields from streaming reasoning chunks instead of discarding them. Uses loop + update() to collect all metadata, then setdefault() for id and type to ensure they're always present without overriding existing values.

Regression Test Added:
New test test_convert_streaming_chunks_to_chat_message_preserves_encrypted_content() verifies that encrypted_content, status, and other provider metadata survive the streaming conversion round-trip.

Test Commands Run:

  • pytest test/components/generators/chat/test_openai_responses_conversion.py -xvs: ✅ All 14 tests pass
  • pytest test/components/generators/test_utils.py -k streaming --tb=short -xvs: ✅ All 14 tests pass

Fixes #11658

Related Issues

  • fixes #issue-number

Proposed Changes:

How did you test it?

Notes for the reviewer

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.

@shr8769 shr8769 requested a review from a team as a code owner June 17, 2026 16:40
@shr8769 shr8769 requested review from davidsbatista and removed request for a team June 17, 2026 16:40
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

**Root Cause:**
OpenAI Responses API v2 sends encrypted_content and other metadata in reasoning items to preserve reasoning context across multi-turn conversations. However, _convert_streaming_chunks_to_chat_message() was discarding all extra fields except id and type, breaking multi-turn reasoning interactions.

**Fix Summary:**
Modified lines 810-824 of openai_responses.py to aggregate all extra fields from streaming reasoning chunks instead of discarding them. Uses loop + update() to collect all metadata, then setdefault() for id and type to ensure they're always present without overriding existing values.

**Regression Test Added:**
New test test_convert_streaming_chunks_to_chat_message_preserves_encrypted_content() verifies that encrypted_content, status, and other provider metadata survive the streaming conversion round-trip.

**Test Commands Run:**
- pytest test/components/generators/chat/test_openai_responses_conversion.py -xvs: ✅ All 14 tests pass
- pytest test/components/generators/test_utils.py -k streaming --tb=short -xvs: ✅ All 14 tests pass

Fixes deepset-ai#11658
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.

OpenAIResponsesChatGenerator drops reasoning encrypted_content in streaming mode.

2 participants