The Vertex renderer commit let a non-thought part that carries only a
thoughtSignature (an empty text part, or a part with no text key) reach
the text path. On the Vertex path the text-part signature is dropped
since then, so the change has no effect there. On the antigravity
platform it added an empty thinking block for such a part: a stream whose
signature arrives in an empty final part ended [text, thinking("")], and
Claude Code reports an empty result for a turn that ends with a thinking
block. main renders [text].
Failure modes this commit guards against:
- Antigravity (zero options): "Hello world" followed by an empty final
part with a signature, or a part with only a signature, renders an
extra empty thinking block (stream with the signature in its own chunk,
and non-stream).
- Vertex options (marker prefix, text signatures dropped): the output
changes. A scratch probe over 8 part shapes (signature-only part before
text, after text, after thinking, between text and a call, after a
call; signed text; signed image), stream and non-stream, gives the same
bytes before and after this commit. With zero options the same probe
gives the bytes of main.
Changes:
- StreamingProcessor and NonStreamingProcessor: the text branch runs
again only for a part with text or a thought part, as on main.
Tests:
- New TestSignatureOnlyTextPartAddsNoBlock: [text] for both tail shapes,
stream (two chunks) and non-stream, with zero options and with the
Vertex options. The zero-option cases fail on the parent commit.
- TestProcessorsKeepSignatureOnlyPartsAndEmptyToolInput loses its two
signature-only cases and becomes
TestProcessorsKeepEmptyToolInputAndImageSignature.
- TestDropTextSignatures: with the drop off, a trailing empty signed part
now gives [text].
- TestThinkingSignaturePrefixMarksOnlyThinkingBlocks: the carried text
signature now comes from a signed non-empty text part, so the test still
checks that the carrier thinking block gets the prefix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gemini 3 and later put a thoughtSignature on the last part of a turn. When
that part is text (or an empty text part, as streaming does), the
antigravity processors emit an empty thinking block after the text only to
carry the signature. A final Vertex turn then ends [text, thinking("")],
and Claude Code reports an empty result for it, because it reads the last
block. Headless callers that read the result get "".
Vertex enforces signatures only on functionCall parts. A missing signature
on a text part causes no error ("The API does not strictly enforce
validation for signatures in non-functionCall parts"), see
https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures
So on the Vertex-account path the text-part signature is dropped.
Failure modes this commit guards against:
- A Vertex text turn with a signature on its text part, or in a trailing
empty text part, ends with an empty thinking block (stream and
non-stream).
- An empty thinking block is emitted between text and a function call, or
after a function call, only to carry a text-part signature.
- A real thinking block loses its signature (signature_delta), or loses the
vertex-thought-v1 marker.
- A function call loses tool_use.signature.
- Text is lost or reordered when its signature is dropped.
- The antigravity platform output changes: it must still emit the empty
thinking block with the raw signature.
Changes:
- pkg/antigravity: ResponseTransformOptions.DropTextSignatures and
StreamingProcessor.SetDropTextSignatures. When set, a non-thought text
part is processed without its signature. The zero value keeps today's
output.
- streamGeminiSSEAsClaude takes antigravity.ResponseTransformOptions
instead of the prefix string, so stream and non-stream use one option
set. The antigravity platform passes the zero value.
- G: geminiVertexResponseOptions (the vertex-thought-v1 marker plus
DropTextSignatures) for the Vertex stream and non-stream renderers, the
same switch as the marker.
Tests (go test -tags=unit):
- pkg/antigravity TestDropTextSignatures: 5 cases, stream and non-stream,
drop on and off. Text-part signature, trailing empty part, real thinking
plus signed text, signed text before a function call, and text split
around a signed part. With the drop on, there is no empty thinking
block; thinking and tool_use signatures stay, and the text stays in
order. With it off, the output is today's.
- service TestGeminiCompatForward_VertexTextPartSignatures: a real Forward,
stream and non-stream. A text turn renders [thinking(marker+sig), text
"PROBE_DONE"] with no text signature; a call turn renders [text,
tool_use(SIG_CALL)] with no empty thinking.
- service TestAntigravityClaudeStreamKeepsTextSignatureCarrier: the
antigravity handler still emits [text, thinking] with the raw signature.
- Updated to the new rule: the Vertex render test no longer expects the
trailing SIG_TAIL thinking block after tool_use. The Vertex signature
test now gets its marked signature from a thought part, and checks that
the text-part signature is not sent.
After a switch from Claude to Gemini in the middle of a session, the history
holds thinking blocks with Anthropic signatures. The converter carries any
real thinking signature as thoughtSignature, so Vertex gets a foreign
signature, answers with a signature 400, and Forward retries with the
thinking blocks downgraded. That costs one extra upstream call on every
request for the rest of the session. tool_use.signature is not affected:
Anthropic tool_use blocks carry no signature.
Failure modes this commit guards against:
- A thinking signature from another upstream (no marker) reaches Vertex as
thoughtSignature on a text or functionCall part.
- A thinking signature that the Vertex path emitted no longer round-trips:
the marker reaches Vertex, or the signature is dropped.
- A marker in front of an empty or skip_thought_signature_validator
signature is carried.
- tool_use.signature changes on the Vertex path.
- The Vertex response sends a thinking signature without the marker, or
marks tool_use.signature.
- The signature-error retry rebuilds the request without the rule.
- The antigravity platform changes: its /v1/messages responses and its
compat path (which uses the same converter) must keep raw signatures.
Changes:
- Vertex responses (stream and non-stream) send thinking-block signatures
as "vertex-thought-v1:" + signature. tool_use signatures stay raw.
- pkg/antigravity: StreamingProcessor.SetThinkingSignaturePrefix and
TransformGeminiToClaudeWithOptions(ResponseTransformOptions). The zero
value keeps today's output; the antigravity callers do not set them.
- convertClaudeMessagesToGeminiRequest(body, model, markedThinkingSignatures):
Forward sets it for Vertex accounts, on the first request and on the
signature retry. With it set, a thinking signature is carried only when it
has the marker, and without the marker. Without the marker the block falls
back to today's handling: no signature on text, the dummy on a call.
convertClaudeMessagesToGeminiGenerateContent keeps the old behaviour for
every other caller.
Histories written by the Vertex path before this commit carry unmarked
signatures. They now fall back the same way, which costs only reasoning
continuity on those old turns.
Test changes: three assertions in gemini_messages_vertex_render_test.go now
expect the marker on thinking signatures. tool_use.signature assertions are
unchanged.
New: gemini_messages_vertex_signature_test.go,
pkg/antigravity/thinking_signature_prefix_test.go.
The antigravity response processors, which now also render Vertex
/v1/messages responses, mapped every finish reason except MAX_TOKENS to
end_turn (or tool_use). A blocked or broken turn then looked like a
successful empty answer: Claude Code ends the turn and the run reports
success.
Failure modes this commit guards against:
- SAFETY, PROHIBITED_CONTENT, SPII, BLOCKLIST, IMAGE_SAFETY or RECITATION
ends as end_turn. It is now stop_reason "refusal", in stream and
non-stream.
- A prompt blocked by promptFeedback.blockReason, with no candidates, ends
as end_turn. It is now "refusal".
- MALFORMED_FUNCTION_CALL, UNEXPECTED_TOOL_CALL, TOO_MANY_TOOL_CALLS or
MALFORMED_RESPONSE with no text and no tool_use ends as an empty
end_turn. Thinking blocks do not count as content: with thinking on, a
thought summary comes before almost every invalid call. The stream now
ends with an SSE error event of type api_error, which Claude Code
retries. Non-stream returns ErrMalformedFunctionCall or
ErrInvalidOutputWithoutContent, which callers write as a 502.
- The same reasons after text or a tool call must still end normally
(end_turn, or tool_use after a call). Non-stream MALFORMED_FUNCTION_CALL
with text now gives end_turn too; the antigravity collect path still
fails it before conversion, as before.
- After the error event, no later chunk may emit content, message_delta or
message_stop, and the usage must still be collected for billing.
- STOP, MAX_TOKENS, OTHER and tool calls without a refusal reason keep
their mapping. A refusal reason wins over tool_use.
Only the mapping changes; no safetySettings are added. Effects on the other
antigravity paths:
- Claude, chat-completions and responses non-stream now return 502 for
UNEXPECTED_TOOL_CALL, TOO_MANY_TOOL_CALLS and MALFORMED_RESPONSE without
text or tool calls, where they returned an empty 200 before.
- The chat-completions and responses stream adapters buffer the error event
like the empty end_turn before it, so they still report an empty stream.
- Not mapped, and so still end_turn: MODEL_ARMOR, IMAGE_PROHIBITED_CONTENT,
IMAGE_RECITATION, IMAGE_OTHER, NO_IMAGE and CONTINUATION.
Tests: pkg/antigravity/finish_reason_test.go (stream and non-stream per
reason), gemini_messages_vertex_finish_test.go (Vertex /v1/messages through
Forward).
Four request-side defects in convertClaudeMessagesToGeminiContents. They
apply to every caller of the Gemini compat converter, including the
antigravity compat path for gemini-* models.
Failure modes this commit guards against:
- Two parallel calls of the same tool get each other's results. Claude Code
sends tool results in completion order, and Vertex v1 matches a
functionResponse to its functionCall by position, because ids are stripped
(Vertex documents them for v1beta1 only, and the compat path calls /v1).
- A result whose tool_use_id is not in the previous model turn lands among
the known results.
- Reordering moves other parts of the user message.
- is_error is dropped, so the model cannot tell a failed call from output.
- A PDF read by Claude Code arrives as a document block inside tool_result
and is dropped. The "PDF file read: ..." text must also stay.
- A top-level base64 document is sent as JSON text with the base64 inside,
and a text-source document is not sent as plain text.
- A real thinking signature from history is dropped. An empty or
skip_thought_signature_validator signature must not be attached,
tool_use.signature must win over a thinking signature, and a parallel
sibling call must keep the dummy signature, also when the first call has
its own signature.
- A signature-only thinking block that follows a text block is lost. The
antigravity processors emit a text part's signature this way (text first,
then an empty thinking block with the signature), and a signature from a
final empty text part the same way at the end of the message. Such a
block is the text's own signature, so it also replaces a signature that
the text got from an earlier thinking block.
Changes:
- Results: each user message's functionResponse parts are reordered, in
place, to the call order of the previous model turn by tool_use_id.
Unknown ids go after the known ones. Other parts keep their positions.
stripGeminiFunctionIDs stays.
- is_error: response is {"error": text}; otherwise {"content": text} as
before.
- Documents: a base64 document becomes inlineData, a text-source document a
text part, other sources keep the JSON-text fallback. Inside tool_result,
base64 documents travel with images: in functionResponse.parts on models
with multimodal function responses (Gemini 3+), else as trailing parts.
- Signatures: the shape of upstream PR #8545, made stricter. A real
signature on a thinking block goes to the very next text or functionCall
part only. If that part has its own signature, the carried one is
dropped, so later parallel calls keep the dummy. A signature-only
thinking block right after a text part goes back to that text part.
ensureGeminiFunctionCallThoughtSignatures stays as the fallback.
- After a switch from Claude in the same session, Anthropic thinking
signatures in history now reach Vertex in place of the dummy. Vertex then
answers with a signature error, and the existing signature retry in
Forward downgrades the thinking blocks and sends the request again.
Tests: gemini_messages_history_test.go replays the block shapes of a
captured Claude Code session (signature echoes, out-of-order parallel
results, a PDF read, an error result, a tool_reference result).
Vertex accounts (service account JSON and API key) on /v1/messages keep the
Gemini compat request converter and the Vertex transport. Their responses are
now rendered by pkg/antigravity's StreamingProcessor (stream) and
NonStreamingProcessor (non-stream), the same processors that the antigravity
compat path already uses for gemini-* models. Both read plain Vertex
responses with no v1internal wrapper. Other account types keep the compat
emitters unchanged.
Failure modes this commit guards against:
- The client usage carries no cache_read_input_tokens when Vertex reports
cachedContentTokenCount. Claude Code then starts auto-compaction late or
never, and long sessions fail.
- The thoughtSignature of a functionCall part does not reach
tool_use.signature, so the next turn falls back to the dummy signature.
- The signature of a thought part is not sent as a signature_delta.
- A signature that arrives in a final empty text part is lost. Vertex
documents that a stream can return the signature this way. The
antigravity processors had the trailing-signature branch, but processPart
never reached it for an empty text part.
- Non-stream: no thought text (includeThoughts was set for stream only), no
signatures, and a call without args has no input object.
- A text chunk that is a prefix of earlier text is dropped as a duplicate.
- Web search grounding sources (groundingMetadata) never reach the client.
- Billing drifts: the recorded usage must still come from the upstream
usageMetadata (input minus cached, cache read, output plus thoughts, image
output tokens), and image outputs must still be counted.
- An empty upstream stream must fail over before a byte reaches the client.
- A client that leaves before any usage arrives must stay unbilled, as in
the compat stream handler.
- Non-Vertex accounts must keep the compat emitter.
Changes:
- AntigravityGatewayService.handleClaudeStreamingResponse becomes a thin
wrapper around streamGeminiSSEAsClaude(cfg, observeLine). The antigravity
path passes its own config and line observer, so its behaviour does not
change.
- GeminiMessagesCompatService.Forward: for Vertex accounts, the stream is
rendered by streamGeminiSSEAsClaude, and the non-stream body by
antigravity.TransformGeminiToClaude. Model, image and usage observation
per upstream payload stay as in the compat emitters, so billing keeps its
source. includeThoughts is also requested for non-stream calls.
- pkg/antigravity: a tool_use with no args serializes "input": {}, and a part
that carries only a thoughtSignature reaches the trailing-signature path.
An image part keeps today's behaviour.
The non-stream path keeps upstream generateContent, so the existing Vertex
endpoint tests still apply unchanged.
Behaviour changes beyond the fixes:
- The signature-only part fix is in pkg/antigravity, so the antigravity
platform's own Claude responses now also carry such a signature as an
empty thinking block, where it was dropped before.
- Vertex image models on /v1/messages now return generated images as
markdown data-URL text, as the antigravity processors render them. The
compat emitter did not forward images on this endpoint.
Tests: gemini_messages_vertex_render_test.go (Forward with a Vertex API key
account and scripted Vertex chunks), pkg/antigravity/signature_part_test.go.
Google AI Studio rejects replayed function calls without a thought signature (400 "Function call is missing a thought_signature in functionCall parts"). The signature arrives in tool_calls[].extra_content.google, which Codex Responses history cannot preserve, so follow-up turns after tool calls fail when routed to AI Studio.
Before a Chat Completions request goes to generativelanguage.googleapis.com, give each assistant tool call without an existing thought_signature the dummy value skip_thought_signature_validator (matching the native Gemini path). Signatures embedded in Unity/LiteLLM "__thought__" call-id suffixes are not reused because they are issued by a different Google backend and fail with INVALID_THOUGHT_SIGNATURE; the call id itself is kept intact so tool outputs still match. Other upstreams are byte-for-byte unchanged.
Google AI Studio OpenAI-compatible streams send parallel tool calls
without an index, each whole in its own chunk with its own id. A missing
index defaulted to 0, so both calls merged into one item with arguments
like {"cmd":"ls"}{"cmd":"date"} and the stream failed with
invalid tool call arguments (502). Without an index, continue the last
call when the delta has no id or the same id, otherwise open the next
contiguous slot. Indexed streams are unchanged.
Content moderation collected Anthropic image blocks only from source.data, never
from source.url. Since #8312 the /v1/messages -> OpenAI Responses bridge forwards
URL image sources upstream as input_image, so an image sent as
{"type":"url","url":...} (including a data: URI) reached the model without
being moderated, while the same image sent as base64 was. The native Anthropic
path forwarded such images unmoderated as well.
Collect source.url like the other image URL fields; addModerationImage still
accepts only http(s) and data: values.
The previous Codex catalog advertised only "none" for k3.1-pro, so Codex
clients that still hold it send reasoning.effort=none. Preserving none for
K3.1 made those requests fail upstream with HTTP 400 (K3.1 cannot disable
thinking) instead of running at the default effort as they do today.
Keep the existing compatible-upstream rule on the Responses path: strip the
none placeholder for K3.1 exactly like every other Kimi model. The new
catalog no longer advertises none, so current clients are unaffected.
openCodeSessionHintBody built the hint with strconv.Quote, which emits Go
escapes such as \U000f0001 that are not JSON. A session id containing such a
rune (private-use or tag characters, e.g. subdivision flag emoji) was read
back truncated, so different conversations could share one
x-opencode-session. Encode with json.Marshal instead.
Also measure the compaction allocation budget in a child test process, as
main already does for other process-wide allocation counters, so background
goroutines left by other service tests cannot fail it intermittently.
The Anthropic /v1/responses bridge had the same gap as the Chat Completions
bridge: successful OAuth/setup-token responses never refreshed the 5h/7d
subscription windows. Sample the response headers on 2xx exactly like the
Chat Completions path, and cover both bridges in one regression test.
HelpTooltip always centered its popup above the trigger, so on a ~375px
screen any info icon near the left or right edge (ops dashboard cards,
accounts table headers, modal fields) pushed the tooltip off screen.
Several forms also hand-rolled CSS-only hover popups that are absolutely
positioned from the icon and get cut off by the viewport and the dialog
body.
- Move the placement logic from UsageTable into a shared
getTooltipPosition helper (utils/floatingPanel.ts): prefer one side,
flip to the opposite side when it does not fit, otherwise pin to the
viewport edge; clamp the cross axis.
- HelpTooltip measures its popup and uses the helper (above, flipping
below near the top of the screen); the arrow keeps pointing at the icon.
- UsageTable token/cost tooltips use the same helper.
- Replace the hand-rolled info popups in GroupsView, Create/EditAccountModal
and the usage stats cache breakdown with HelpTooltip.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The token and cost detail tooltips in the usage table were always placed
8px to the right of the info icon. On narrow (mobile) screens the cost
column sits near the right edge, so the non-wrapping tooltip was cut off.
After rendering, measure the tooltip: flip it to the left of the icon when
it does not fit on the right, pin it to the right edge when neither side
fits, and clamp it vertically to the viewport.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>