Skip to content

fix(llm): send assistant text as input_text in OpenAI Responses requests (#42613) - #42614

Closed
j34ni wants to merge 1 commit into
anomalyco:devfrom
j34ni:fix-openai-responses-assistant-message
Closed

fix(llm): send assistant text as input_text in OpenAI Responses requests (#42613)#42614
j34ni wants to merge 1 commit into
anomalyco:devfrom
j34ni:fix-openai-responses-assistant-message

Conversation

@j34ni

@j34ni j34ni commented Aug 14, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #42613

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When conversation history contains an assistant text message, the OpenAI
Responses (/responses) request body used:

{"role": "assistant", "content": [{"type": "output_text", "text": "..."}]}

output_text is not a valid easy-input content part: per the official OpenAI
schema (openai-python types), assistant easy-input messages accept only
str | input_text | input_image | input_file. Real api.openai.com tolerates
the non-conformant shape, but strict OpenAI-compatible servers validating with
the official SDK types (e.g. a self-hosted Qwen server exposing /v1/responses)
reject it with a 422/400 pydantic ValidationError, so switching a session to
such a model fails.

The fix lowers assistant text content as input_text in request bodies:

  • packages/llm/src/protocols/openai-responses.ts:
    • Remove the now-unused OpenAIResponsesOutputText schema.
    • Lower assistant text content as input_text in request bodies
      (lowerMessages).
    • OpenAIResponsesInputItem assistant schema now uses input_text parts.
  • packages/llm/test/provider/openai-responses.test.ts: update expected request
    bodies (output_textinput_text for assistant input messages).

The AI SDK path (@ai-sdk/openai convertToOpenAIResponsesMessages) emits the
same invalid shape and would need a separate fix upstream (vercel/ai) to fix
released builds.

How did you verify your code works?

cd packages/llm
bun test test/provider/openai-responses.test.ts

54 pass, 0 fail.

Screenshots / recordings

N/A — not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 14, 2026
@github-actions github-actions Bot closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] OpenAI Responses: assistant messages sent as {role:"assistant", content:[{type:"output_text"}]} rejected by strict OpenAI-compatible servers

1 participant