Skip to content

fix(responses-bridge): encode assistant text as output_text, not input_text#129

Merged
teamchong merged 1 commit into
teamchong:mainfrom
dex0shubham:fix/responses-bridge-assistant-output-text
Jul 21, 2026
Merged

fix(responses-bridge): encode assistant text as output_text, not input_text#129
teamchong merged 1 commit into
teamchong:mainfrom
dex0shubham:fix/responses-bridge-assistant-output-text

Conversation

@dex0shubham

Copy link
Copy Markdown
Contributor

Problem

When a Claude Code /v1/messages request is bridged to a GPT model on the Responses path (bridgedGptMessages, proxy.ts), prior assistant text turns were encoded as content parts of type input_text. The OpenAI Responses API only accepts output_text (or refusal) for role:assistant content — input_text there is a hard 400, so any multi-turn conversation to a Responses-routed GPT model failed after the first assistant reply.

The bug is confirmed by the bridge's own asymmetry: the read side (openAIResponseToAnthropicMessage) already maps assistant text ↔ output_text; only the write side (inputParts) was wrong. The branch had no test coverage.

Fix

Thread the message role into inputParts and select the text part type: output_text for assistant, input_text for user/system (unchanged). Added a regression test in responses-bridge-roles.test.ts.

Full suite passes (804/804); typecheck clean.

🤖 Generated with Claude Code

…t_text

When a Claude Code /v1/messages request is bridged to a GPT model on the
Responses path (bridgedGptMessages), prior assistant text turns were lowered
to content parts of type input_text. The OpenAI Responses API requires
assistant-role message content to be output_text; input_text under
role:assistant is rejected with 400, breaking every multi-turn session to a
Responses-routed GPT model after the first assistant reply. The bridge's read
side already maps assistant text to/from output_text — only the write side was
wrong. Thread the role into inputParts and pick the text type accordingly;
user/system stay input_text.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@teamchong teamchong left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks

@teamchong
teamchong merged commit fbe2c25 into teamchong:main Jul 21, 2026
1 check passed
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.

2 participants