Claude Desktop on antigravity/gemini-4-carbon failed 403 of 408 requests: 400 "Request contains an invalid argument", 502 empty reply after 170-230s, and 200s marked failed with output tokens. Changed, in internal/gateway: - A tool name starting with a digit or a dash (MCP tools named for an id) goes to Google as _x_<name> and comes back without it; a property with no name is left out of the Antigravity schema. Both turned the whole request away on a live call. - A MALFORMED_FUNCTION_CALL / UNEXPECTED_TOOL_CALL finish carries the call in finishMessage; it is now made the call instead of reading as an empty reply (tokens spent, then asked again for nothing). - passing(): a 502 empty reply is asked again once, not lastRetries times on top of the in-place emptyRetries. Run (mica): go test -run 'TestCodeAssist|TestEmptyReply' ./internal/gateway; the new tests are red on the old code (names, malformed case). Live (owner account, gemini-3.8-flash): names with a digit/dash first, a space, unicode, a slash and an empty property key each 400; 64 and 100 char names are 200. Not tried: real gemini-4-carbon (the account lacks it, 404), so the user's exact 400 is not reproduced; the finishMessage form is Google's documented shape, not captured from Carbon.
50 lines
2.0 KiB
Go
50 lines
2.0 KiB
Go
package gateway
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Google turns the whole request away over a function name that starts with
|
|
// a digit or a dash, and over a property with no name (fwxkogaia on X).
|
|
func TestCodeAssistToolNamesGoogleTakes(t *testing.T) {
|
|
schema := json.RawMessage(`{"type":"object","properties":{"":{"type":"string"},"q":{"type":"string"}},"required":["","q"]}`)
|
|
r := &Request{Model: "gemini-4-carbon", Tools: []Tool{{Name: "1pass_get", Schema: schema}, {Name: "-dash", Schema: schema}, {Name: "ok", Schema: schema}},
|
|
Messages: []Message{
|
|
{Role: "user", Parts: []Part{{Kind: Text, Text: "hi"}}},
|
|
{Role: "assistant", Parts: []Part{{Kind: ToolCall, ID: "c1", Name: "1pass_get", Args: json.RawMessage(`{}`)}}},
|
|
{Role: "user", Parts: []Part{{Kind: ToolResult, CallID: "c1", Text: "x"}}},
|
|
}}
|
|
out := string(buildCodeAssistSent(r, "gemini-4-carbon", "antigravity"))
|
|
for _, bad := range []string{`"name":"1pass_get"`, `"name":"-dash"`, `"":`} {
|
|
if strings.Contains(out, bad) {
|
|
t.Errorf("request still has %s: %s", bad, out)
|
|
}
|
|
}
|
|
if n := strings.Count(out, `"name":"_x_1pass_get"`); n != 3 {
|
|
t.Errorf("_x_1pass_get in declaration, call and result: %d, want 3: %s", n, out)
|
|
}
|
|
if got := toolOfCall("_x_1pass_get"); got != "1pass_get" {
|
|
t.Errorf("decoded %q", got)
|
|
}
|
|
if got := toolOfCall("default_api:_x_-dash"); got != "-dash" {
|
|
t.Errorf("decoded %q", got)
|
|
}
|
|
}
|
|
|
|
// A reply that answered nothing is asked again in place, so the request
|
|
// is asked again once, not as often as an outage (fwxkogaia on X).
|
|
func TestEmptyReplyAskedAgainOnce(t *testing.T) {
|
|
body := []byte(`{"error":{"message":"antigravity: ` + emptyReply + `"}}`)
|
|
if _, ok := passing(502, nil, body, 0); !ok {
|
|
t.Error("an empty reply is asked again once")
|
|
}
|
|
if _, ok := passing(502, nil, body, 1); ok {
|
|
t.Error("an empty reply is not asked again a second time over")
|
|
}
|
|
if _, ok := passing(502, nil, []byte(`bad gateway`), 1); !ok {
|
|
t.Error("a busy vendor is still asked again")
|
|
}
|
|
}
|