Skip to content

fix(protocol): bridge Responses custom_tool_call history - #191

Open
Gan332 wants to merge 1 commit into
jasonxu114514:mainfrom
Gan332:fix/responses-custom-tool-call-history
Open

Gan332 wants to merge 1 commit into
jasonxu114514:mainfrom
Gan332:fix/responses-custom-tool-call-history

Conversation

@Gan332

@Gan332 Gan332 commented Nov 22, 2026

Copy link
Copy Markdown

Problem

Codex declares apply_patch as a Responses custom tool, so its replayed
conversation history contains custom_tool_call / custom_tool_call_output
items. When the context window fills up, Codex auto-compaction resubmits the
full history, and the Responses → Chat/Anthropic bridge rejects it:

prepare zen upstream request: input[73] has unsupported Responses item type "custom_tool_call"

This makes auto-compaction permanently fail for Codex users going through
opencode2api, even though ordinary turns work.

Fix

Teach the bridge's Responses decoder to accept both item types:

  • custom_tool_call → assistant tool_call, using call_id/id and name;
    the freeform input is wrapped as JSON arguments under an "input" key
    because Chat and Anthropic only carry JSON tool arguments.
  • custom_tool_call_output → user tool_result keyed by call_id.

Verification

Reproduced against v1.5.1 with a minimal /v1/responses request containing a
custom_tool_call item (400 before). After the change the same request returns
200 and a normal model response; regular chat/responses requests are unchanged.

Note: custom tool definitions are still skipped when bridging to Chat, so
this change only makes replayed history decodable. Forwarding custom tools as
callable tools is a separate, larger change.

Codex declares apply_patch as a Responses custom tool, so its replayed
conversation history carries custom_tool_call and custom_tool_call_output
items. The Responses -> Chat/Anthropic bridge only recognized
function_call/function_call_output, so Codex auto-compaction resubmitting
that history failed with:

  input[n] has unsupported Responses item type "custom_tool_call"

Decode both item types. The freeform custom-tool input is wrapped as JSON
arguments under an "input" key (Chat and Anthropic only carry JSON tool
arguments), and the output maps to a tool_result keyed by call_id.
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.

1 participant