Skip to content

fix(openai): emit output_text for assistant content in responses input#11169

Merged
Colin Francis (colifran) merged 3 commits into
mainfrom
colifran/responses-api
Jul 9, 2026
Merged

fix(openai): emit output_text for assistant content in responses input#11169
Colin Francis (colifran) merged 3 commits into
mainfrom
colifran/responses-api

Conversation

@colifran

Copy link
Copy Markdown
Contributor

Summary

The openai responses converter typed all text content as input_text regardless of role. For example, an assistant message became { role: "assistant", content: [{ type: "input_text", … }] } and the API rejected it:

400 Invalid value: 'input_text'. Supported values are: 'output_text' and 'refusal'.

This bug only affects the native openai responses api and only on multi-turn runs since the bad input_text is on a prior assistant turn replayed as input meaning a single first turn never triggers it.

This PR makes the text part role-aware, i.e., output_text for assistant, input_text otherwise, this matches Python's _construct_responses_api_input.

Tests

Added convertStandardContentMessageToResponsesInput regression tests verifying that an assistant message converts to output_text and a user message stays input_text.

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8242ece

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

@open-swe open-swe Bot left a comment

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.

✅ Open SWE Review: No issues found

Open SWE reviewed this PR and found no potential bugs to report.

Open in WebView Open SWE trace

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@github-actions github-actions Bot added the ready label Jul 9, 2026
@colifran
Colin Francis (colifran) merged commit 988ca7d into main Jul 9, 2026
34 checks passed
@colifran
Colin Francis (colifran) deleted the colifran/responses-api branch July 9, 2026 05:01
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.39

### Patch Changes

- Updated dependencies
[[`988ca7d`](988ca7d)]:
  - @langchain/openai@1.5.4
## @langchain/deepseek@1.1.4

### Patch Changes

- Updated dependencies
[[`988ca7d`](988ca7d)]:
  - @langchain/openai@1.5.4
## @langchain/fireworks@0.2.4

### Patch Changes

- Updated dependencies
[[`988ca7d`](988ca7d)]:
  - @langchain/openai@1.5.4
## @langchain/neo4j@0.1.11

### Patch Changes

- Updated dependencies []:
  - @langchain/classic@1.0.39
## @langchain/openai@1.5.4

### Patch Changes

- [#11169](#11169)
[`988ca7d`](988ca7d)
Thanks [@colifran](https://github.com/colifran)! - fix(openai): emit
output_text for assistant content in responses input
## @langchain/openrouter@0.4.4

### Patch Changes

- Updated dependencies
[[`988ca7d`](988ca7d)]:
  - @langchain/openai@1.5.4
## @langchain/together-ai@0.2.4

### Patch Changes

- Updated dependencies
[[`988ca7d`](988ca7d)]:
  - @langchain/openai@1.5.4
## @langchain/xai@1.4.4

### Patch Changes

- Updated dependencies
[[`988ca7d`](988ca7d)]:
  - @langchain/openai@1.5.4

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