Skip to content

fix(openai): preserve reasoning item boundaries - #39278

Merged
ccurme (ccurme) merged 3 commits into
langchain-ai:masterfrom
alexonufrak:alexonufrak/openai/preserve-reasoning-item-boundaries
Aug 18, 2026
Merged

fix(openai): preserve reasoning item boundaries#39278
ccurme (ccurme) merged 3 commits into
langchain-ai:masterfrom
alexonufrak:alexonufrak/openai/preserve-reasoning-item-boundaries

Conversation

@alexonufrak

Copy link
Copy Markdown
Contributor

OpenAI Responses users can replay output_version="v1" messages after LangGraph streaming without losing distinct reasoning items.

The v1 projection explodes one Responses reasoning item into adjacent summary fragments. _implode_reasoning_blocks correctly reassembled those fragments, but it treated every adjacent reasoning fragment as part of the same item. When a stream contained two consecutive reasoning items, the second item's summary and replay metadata were folded into the first ID. A subsequent Responses tool turn could then be rejected because its required reasoning item was missing.

This change only combines fragments whose IDs match. Two legacy fragments that both omit IDs retain the existing grouping behavior, while mixed or differing identities stay separate. The regression coverage also verifies encrypted content, item metadata, native Responses blocks, ordering, and legacy ID-less summaries. The full relevant OpenAI chat-model and Responses-stream unit suites pass with network access disabled.

Release note

Fixed OpenAI Responses replay so consecutive reasoning items keep their own IDs and metadata when converting LangChain v1 content blocks back into provider input.

This contribution was developed with AI-agent assistance and reviewed and tested by the contributor.

@github-actions github-actions Bot added fix For PRs that implement a fix integration PR made that is related to a provider partner package integration openai `langchain-openai` package issues & PRs size: S 50-199 LOC labels Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This PR has been automatically closed because it does not link to an approved issue.

All external contributions must reference an approved issue or discussion. Opening a PR before maintainer approval and assignment is discouraged. Please:

  1. Find or open an issue describing the change
  2. Wait for a maintainer to approve the approach and assign you
  3. After assignment, open a PR. If this PR was opened early, add Fixes #<issue_number>, Closes #<issue_number>, or Resolves #<issue_number> to the description and it can be reopened automatically

Maintainers: reopen this PR or remove the missing-issue-link label to bypass this check.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@ccurme
ccurme (ccurme) merged commit 32c15bb into langchain-ai:master Aug 18, 2026
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-issue-check external fix For PRs that implement a fix integration PR made that is related to a provider partner package integration new-contributor openai `langchain-openai` package issues & PRs size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openai: _implode_reasoning_blocks merges distinct reasoning items, dropping ids and encrypted content

2 participants