Repository navigation
Description
Client or integration
Codex App
Provider or upstream service
Google Vertex AI (google-vertex), gemini-4-argon.
OpenCodex version
Observed on @bitkyc08/opencodex 2.84.0 on Windows. The same sibling-image serialization is still present on dev at 2a10a2bc450067e3b475315ffeaefc4bb5b52ab4 (package version 2.89.0).
Endpoint or capability
POST /v1/responses, tool-result images translated to Vertex generateContent / streamGenerateContent.
Current behaviour
After a tool returns an image (for example a browser screenshot), the next Vertex Argon request fails with HTTP 400: Requests ending with a model turn are not supported. This interrupted two tool-driven Codex App turns.
The compiled request actually ends in a user turn. Its parts contain a functionResponse followed by sibling inline_data image parts. Appending more text to that final user turn does not repair the request. A text-only result succeeds.
Follow-up reproduction on the PR checkout: fixing matched images alone is incomplete. If an adjacent tool result repeats the call ID or has an unknown ID, the serializer preserves that orphan image beside the normal function response, and Vertex returns the same HTTP 400. Both duplicate and mismatched cases were reproduced. Moving the marked orphan batch into a following user turn succeeds without assigning its images to another call.
Expected behaviour
Codex should continue after receiving tool images. Preserve image bytes, result text, function name, call ID and result order. Associate matched images with their own function response using the documented functionResponse.parts shape accepted by Vertex Argon. Duplicate or mismatched images must also remain available without causing the same 400 or fabricating call ownership; preserve those marked orphan results separately after the complete response batch.
Minimal redacted request or reproduction
# Use a Vertex endpoint and credentials for your own account. The image is a synthetic 1x1 PNG.
# POST this JSON to your gemini-4-argon :generateContent endpoint:
{
"contents": [
{"role":"user","parts":[{"text":"A tool captured a screenshot. Reply OK when you receive the result."}]},
{"role":"model","parts":[{"functionCall":{"name":"inspect","id":"call_probe","args":{}},"thoughtSignature":"skip_thought_signature_validator"}]},
{"role":"user","parts":[
{"functionResponse":{"name":"inspect","id":"call_probe","response":{"result":"Screenshot captured."}}},
{"inline_data":{"mime_type":"image/png","data":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aO2kAAAAASUVORK5CYII="}}
]}
],
"tools":[{"functionDeclarations":[{"name":"inspect","description":"Inspect a screenshot.","parameters":{"type":"object","properties":{}}}]}],
"generationConfig":{"maxOutputTokens":256,"thinkingConfig":{"thinkingLevel":"low"}}
}
# Fails with HTTP 400 above. Move the identical inline_data object into
# contents[2].parts[0].functionResponse.parts and remove it from user.parts:
# {"role":"user","parts":[{"functionResponse":{
# "name":"inspect","id":"call_probe","response":{"result":"Screenshot captured."},
# "parts":[{"inline_data":{"mime_type":"image/png","data":"<same PNG above>"}}]
# }}]}
# The nested form returns HTTP 200, STOP, and "OK".Actual response or error
HTTP 400
Requests ending with a model turn are not supported.
Synthetic live comparison:
text-only function response: 200
function response + sibling image: 400
function response.parts image: 200, STOP, OK
image in a separate user turn: 200
sibling image + extra user text: 400
The nested success reports 1089 IMAGE input tokens, confirming the image was retained.Upstream documentation
Suggested mapping or implementation notes
In geminiToolResultParts, put image parts inside the matching functionResponse.parts for googleMode === "vertex" && modelId === "gemini-4-argon". For that route, move an adjacent orphan batch containing representable images to a separate user turn after the complete function-response batch. Keep other routes, text-only orphans and standalone orphans unchanged. No new configuration or retry is necessary.
This updates the initial suggestion to leave all orphan results unchanged, because subsequent live reproduction showed that adjacent duplicate and mismatched images trigger the same bug. It does not extend the fix to another provider or model.
The scope is intentionally limited to the provider/model combination reproduced here. Parallel results must still follow call order and keep their own images, IDs, names, and text. The fix, regression tests, and validation details are submitted against dev in #7280.
Additional context and attachments
Related but different resolved history-repair issues: #2199 and #5008. A similar upstream incompatibility is independently documented at router-for-me/CLIProxyAPI#5415.
Live diagnostics used only a synthetic PNG and generic text, not real screenshots or conversation contents. With the equivalent local patch on 2.84.0, /v1/responses completed with HTTP 200 and OK in both streaming and non-streaming smoke checks. These are local live-API observations, not a claim that the unpatched dev branch was tested against the live service.
Follow-up evidence from the PR source: duplicate-image and unmatched-image histories returned 400 before the orphan repair and 200/STOP/OK after it, with 2,178 IMAGE input tokens each. A real model-generated tool call through the production Responses parser and Google adapter also read random text and color present only in a synthetic PNG, in both streaming and buffered modes, preserving the exact real upstream thought signature. The full HTTP proxy path was not part of that follow-up. Buffered response latency remains variable; the missing-result live case timed out and is only locally covered. #7280 records all test results and these limits.
Checks
- I searched existing provider and compatibility issues.
- The request and response were redacted.
- The expected behaviour is based on an upstream specification or a concrete client requirement.
Activity
lidge-jun commentedon Oct 17, 2026
Fixed on dev by #7280 (merge commit d80dfcd): matched Vertex tool-result images are nested in functionResponse and orphan images go to a separate turn.