Client or integration
Claude Code / Claude-on-Antigravity through the OpenCodex Google adapter
Provider or upstream service
Google Gemini / Claude-on-Antigravity gateway
OpenCodex version
v2.28.0 (upstream base 5840591; local validation patch c0dcef24)
Endpoint or capability
Anthropic messages translated to Gemini functionCall / functionResponse tool turns
Current behaviour
The Google adapter can emit a model turn containing one or more tool calls followed by a user turn containing tool results. In interrupted histories, a tool call can have no corresponding result; in replayed or duplicated histories, a result can have no adjacent call. Gemini/Claude-on-Antigravity rejects the resulting wire shape with HTTP 400 errors such as Invalid functionResponse or an unpaired tool call.
The upstream already has analogous protections for other transports (for example the merged Responses/Cursor work in #1912, #1990 and #2038), but the Google adapter path did not have the same adjacency contract.
Expected behaviour
For every model turn with tool calls, the immediately following user turn should contain exactly one response for each call in call order. If history is interrupted, the adapter should emit an explicit synthetic response such as [missing tool_result for this tool_use in history]. If a tool result has no adjacent matching call, it should be preserved as plain text with an explicit marker instead of being emitted as an unpaired functionResponse.
The repair must cover parallel calls, preserve stable call ids, and leave image-bearing tool results representable without manufacturing an image result.
Minimal redacted request or reproduction
- Send an Anthropic/Claude messages history through the Google adapter.
- Include a model turn with tool_use(call_1) and omit its later tool_result (simulating an interrupted turn), or include a standalone tool_result(call_orphan).
- Target a Claude-on-Antigravity model.
- Observe the translated Gemini request and the provider response.
No credentials or account identifiers are required for the reproduction.
Actual response or error
The provider rejects the translated request with HTTP 400: Invalid functionResponse / unpaired tool call (exact wording varies by gateway build). The request cannot be resumed until the history is manually repaired.
Upstream documentation
Anthropic tool-use message contract: https://docs.anthropic.com/en/docs/build-with-claude/tool-use
Gemini function calling: https://ai.google.dev/gemini-api/docs/function-calling
Suggested mapping or implementation notes
The attached local validation patch groups consecutive tool results after each model tool-call batch, synthesizes missing results in call order, and degrades orphan results to text. The relevant implementation shape is in src/adapters/google.ts around the tool-adjacency handling and is covered by the local adapter tests for missing, orphaned, duplicate, parallel, and image-bearing results. This is intentionally a wire-repair boundary; it does not fabricate successful tool output.
Additional context and attachments
Local v2.28.0 validation: typecheck exit 0; migration-focused suite 593 pass / 0 fail. The local patch is byte-for-byte validated against the installed package. Related upstream fixes: #1912, #1990, #2038.
This request is scoped to the Google/Claude-on-Antigravity adapter; it does not ask to duplicate the already-landed fixes for those other transports.
Client or integration
Claude Code / Claude-on-Antigravity through the OpenCodex Google adapter
Provider or upstream service
Google Gemini / Claude-on-Antigravity gateway
OpenCodex version
v2.28.0 (upstream base 5840591; local validation patch c0dcef24)
Endpoint or capability
Anthropic messages translated to Gemini functionCall / functionResponse tool turns
Current behaviour
The Google adapter can emit a model turn containing one or more tool calls followed by a user turn containing tool results. In interrupted histories, a tool call can have no corresponding result; in replayed or duplicated histories, a result can have no adjacent call. Gemini/Claude-on-Antigravity rejects the resulting wire shape with HTTP 400 errors such as Invalid functionResponse or an unpaired tool call.
The upstream already has analogous protections for other transports (for example the merged Responses/Cursor work in #1912, #1990 and #2038), but the Google adapter path did not have the same adjacency contract.
Expected behaviour
For every model turn with tool calls, the immediately following user turn should contain exactly one response for each call in call order. If history is interrupted, the adapter should emit an explicit synthetic response such as [missing tool_result for this tool_use in history]. If a tool result has no adjacent matching call, it should be preserved as plain text with an explicit marker instead of being emitted as an unpaired functionResponse.
The repair must cover parallel calls, preserve stable call ids, and leave image-bearing tool results representable without manufacturing an image result.
Minimal redacted request or reproduction
No credentials or account identifiers are required for the reproduction.
Actual response or error
The provider rejects the translated request with HTTP 400: Invalid functionResponse / unpaired tool call (exact wording varies by gateway build). The request cannot be resumed until the history is manually repaired.
Upstream documentation
Anthropic tool-use message contract: https://docs.anthropic.com/en/docs/build-with-claude/tool-use
Gemini function calling: https://ai.google.dev/gemini-api/docs/function-calling
Suggested mapping or implementation notes
The attached local validation patch groups consecutive tool results after each model tool-call batch, synthesizes missing results in call order, and degrades orphan results to text. The relevant implementation shape is in src/adapters/google.ts around the tool-adjacency handling and is covered by the local adapter tests for missing, orphaned, duplicate, parallel, and image-bearing results. This is intentionally a wire-repair boundary; it does not fabricate successful tool output.
Additional context and attachments
Local v2.28.0 validation: typecheck exit 0; migration-focused suite 593 pass / 0 fail. The local patch is byte-for-byte validated against the installed package. Related upstream fixes: #1912, #1990, #2038.
This request is scoped to the Google/Claude-on-Antigravity adapter; it does not ask to duplicate the already-landed fixes for those other transports.