Skip to content

fix(openai): filter out content blocks the chat completions api rejects as input#11175

Merged
Colin Francis (colifran) merged 2 commits into
mainfrom
colifran/openai-reasoning
Jul 9, 2026
Merged

fix(openai): filter out content blocks the chat completions api rejects as input#11175
Colin Francis (colifran) merged 2 commits into
mainfrom
colifran/openai-reasoning

Conversation

@colifran

@colifran Colin Francis (colifran) commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

The Chat Completions outbound converter (convertMessagesToCompletionsMessageParams) forwarded provider reasoning content blocks back into the request history. Strict openai-compatible providers reject them, for example DeepSeek returns 400 unknown variant 'reasoning', expected 'text'. Short requests worked, but longer agent runs failed once a reasoning block accumulated in history.

The converter already dropped tool_use blocks. This extends that guard to also drop reasoning, reasoning_content, and thinking blocks, which are output-only and not valid Chat Completions input content.

Reference issue: langchain-ai/openwiki#231

Tests

Unit tests

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5c68d5b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@langchain/openai Patch
@langchain/classic Patch
@langchain/deepseek Patch
@langchain/fireworks Patch
@langchain/openrouter Patch
@langchain/together-ai Patch
@langchain/xai Patch
@langchain/neo4j Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the ready label Jul 9, 2026
@colifran
Colin Francis (colifran) merged commit a9f123a into main Jul 9, 2026
35 checks passed
@colifran
Colin Francis (colifran) deleted the colifran/openai-reasoning branch July 9, 2026 16:35
Colin Francis (colifran) pushed a commit that referenced this pull request Jul 9, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @langchain/classic@1.0.40

### Patch Changes

- Updated dependencies
[[`a9f123a`](a9f123a),
[`09e7f6d`](09e7f6d)]:
  - @langchain/openai@1.5.5
## @langchain/deepseek@1.1.5

### Patch Changes

- Updated dependencies
[[`a9f123a`](a9f123a),
[`09e7f6d`](09e7f6d)]:
  - @langchain/openai@1.5.5
## @langchain/fireworks@0.2.5

### Patch Changes

- Updated dependencies
[[`a9f123a`](a9f123a),
[`09e7f6d`](09e7f6d)]:
  - @langchain/openai@1.5.5
## @langchain/neo4j@0.1.12

### Patch Changes

- Updated dependencies []:
  - @langchain/classic@1.0.40
## @langchain/openai@1.5.5

### Patch Changes

- [#11175](#11175)
[`a9f123a`](a9f123a)
Thanks [@colifran](https://github.com/colifran)! - fix(openai): filter
out content blocks the chat completions api rejects as input

- [#11177](#11177)
[`09e7f6d`](09e7f6d)
Thanks [@colifran](https://github.com/colifran)! - fix(openai): drop
tool_call content blocks from chat completions input
## @langchain/openrouter@0.4.5

### Patch Changes

- Updated dependencies
[[`a9f123a`](a9f123a),
[`09e7f6d`](09e7f6d)]:
  - @langchain/openai@1.5.5
## @langchain/together-ai@0.2.5

### Patch Changes

- Updated dependencies
[[`a9f123a`](a9f123a),
[`09e7f6d`](09e7f6d)]:
  - @langchain/openai@1.5.5
## @langchain/xai@1.4.5

### Patch Changes

- Updated dependencies
[[`a9f123a`](a9f123a),
[`09e7f6d`](09e7f6d)]:
  - @langchain/openai@1.5.5

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment