ferock on Discord: Claude Code, model group/gemini-3-8-flash on a local magpie whose group is served by a remote magpie's Antigravity, 400 "Remote magpie: Antigravity: GenerateContentRequest.tools[0]. function_declarations[19].parameters.properties[display].items: field predicate failed: $type == Type.ARRAY". It worked in the morning and broke after updating. The tool's literal schema wasn't posted, and no Claude Code 2.1.311 built-in has a display property with items (searched the binary), so it is an MCP tool of theirs. Cause: geminiToolTypes (68ee4117a, v0.1.1624, 10-27 01:26) runs in forwardOnce for any body whose model names Gemini, the local magpie's forward to a remote magpie included. geminiSchemaType typed an untyped schema from its enum/const values before its keywords, so {"items":{...},"enum":["a","b"]} went on as type "string" with items beside it. The remote's plainSchema kept the explicit type and the items, and Google refused the whole turn. Before68ee4117athe same node reached plainSchema untyped and was inferred an array. - geminiSchemaType: an object's or array's keywords (properties, items and the rest, keywordType, split out of schemaTypes unchanged) decide before enum/const values. - plainSchema (the remote's Antigravity side, so a local magpie from before is served too): items/minItems/maxItems are kept only on an array and properties/required/min-maxProperties/propertyOrdering only on an object, as JSON Schema reads them; of a type list it takes the type its items or properties are for (["string","array"] with items is an array, not a string with items). - docs/subsystems/gateway-routing.md says both. - Sibling not changed: kimiSchemaType/collectUntypedEnums still type such a node from its enum; whether Kimi refuses items on a string is unknown, filed as #3867. Tests (antigravity_display_items_test.go): the shape the error points to (an untyped display with items and a string enum, plus properties with a const) through geminiToolTypes, and through parseAnthropic + buildCodeAssist(antigravity) as Claude Code sent it, as this version's local passes it on, and as an older local passes it on (display typed "string", type lists, a string with object/array keywords); every node sent has items only as an array and properties only as an object. Run, in a worktree at origin/main32ea16c5a: - go test -tags nogui ./internal/gateway -run 'CodeAssist|Codeassist| Gemini|Schema|Antigravity|Kimi|Plain|Grok|OneOf|Tool|Vertex|Google| Shape|Enum' -count=1: ok (60s) - gofmt -l internal/gateway: clean; go vet -tags nogui (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet on internal/gateway: clean Broken by hand: gemini_schema.go back to origin/main, TestGeminiToolTypesItemsBeforeEnum and TestAntigravityItemsOnlyOnArrays FAIL (display typed "string"); codeassist.go back to origin/main, TestAntigravityItemsOnlyOnArrays FAILs (items, minItems, properties on type "string"). Not tried: the reporter's literal tool schema (not posted; the fixture is the shape the error and the update point to), a real Antigravity account, and a real two-magpie setup. Not run: the whole gateway package or ./... (another session's full internal/gateway run was on the machine, load ~60-75).
103 lines
4.9 KiB
Go
103 lines
4.9 KiB
Go
package gateway
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
// displayItemsAsk is a Claude Code request with a tool whose display
|
|
// property is an untyped array of choices: items, with the choices as a
|
|
// string enum beside them. ferock on Discord sent such a request through
|
|
// a routing group of a remote magpie's Antigravity Gemini, and Google
|
|
// turned it away: 400 "GenerateContentRequest.tools[0].
|
|
// function_declarations[19].parameters.properties[display].items: field
|
|
// predicate failed: $type == Type.ARRAY". The tool's literal schema
|
|
// wasn't posted; this is the shape that error and the update that broke it
|
|
// (geminiToolTypes, which typed such a node from its enum) point to.
|
|
const displayItemsAsk = `{"model":"group/gemini-3-8-flash","max_tokens":32,"messages":[{"role":"user","content":"hi"}],
|
|
"tools":[{"name":"show","description":"show rows","input_schema":{"type":"object","properties":{
|
|
"display":{"description":"columns to display","items":{"type":"string"},"enum":["name","size","date"]},
|
|
"filter":{"description":"a filter","properties":{"q":{"type":"string"}},"const":"x"},
|
|
"limit":{"type":"integer"}},"required":["display"]}}]}`
|
|
|
|
// A Gemini model's untyped schema that has items is an array and one
|
|
// that has properties an object, whatever its enum or const says: typed
|
|
// from its values, the node went on with items on a string.
|
|
func TestGeminiToolTypesItemsBeforeEnum(t *testing.T) {
|
|
out := geminiToolTypes([]byte(displayItemsAsk))
|
|
props := gjson.GetBytes(out, "tools.0.input_schema.properties")
|
|
if got := props.Get("display.type").String(); got != "array" {
|
|
t.Errorf("display typed %q, want array: %s", got, props.Get("display").Raw)
|
|
}
|
|
if got := props.Get("filter.type").String(); got != "object" {
|
|
t.Errorf("filter typed %q, want object: %s", got, props.Get("filter").Raw)
|
|
}
|
|
// an enum with no items or properties is still typed from its values
|
|
enum := `{"model":"gemini-3.8-flash","tools":[{"name":"a","input_schema":{"type":"object","properties":{"m":{"enum":["a","b"]}}}}]}`
|
|
if got := gjson.GetBytes(geminiToolTypes([]byte(enum)), "tools.0.input_schema.properties.m.type").String(); got != "string" {
|
|
t.Errorf("enum typed %q, want string", got)
|
|
}
|
|
}
|
|
|
|
// Every node Antigravity is sent has items only as an array and
|
|
// properties only as an object, on each route: the tool as Claude Code
|
|
// sent it, as this version's local magpie passes it on, and as a magpie
|
|
// from before passed it on (display typed "string").
|
|
func TestAntigravityItemsOnlyOnArrays(t *testing.T) {
|
|
older := `{"model":"group/gemini-3-8-flash","max_tokens":32,"messages":[{"role":"user","content":"hi"}],
|
|
"tools":[{"name":"show","description":"show rows","input_schema":{"type":"object","properties":{
|
|
"display":{"type":"string","description":"columns to display","items":{"type":"string"},"enum":["name","size","date"]},
|
|
"listed":{"type":["string","array","null"],"items":{"type":"string"}},
|
|
"shaped":{"type":["string","object"],"properties":{"q":{"type":"string"}}},
|
|
"word":{"type":"string","minItems":1,"properties":{"q":{"type":"string"}},"required":["q"]}}}}]}`
|
|
for name, body := range map[string]string{
|
|
"as sent": displayItemsAsk,
|
|
"local typed": string(geminiToolTypes([]byte(displayItemsAsk))),
|
|
"older local": older,
|
|
} {
|
|
r, err := parseAnthropic([]byte(body))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
decls := gjson.ParseBytes(buildCodeAssist(r, "gemini-3.8-flash", "antigravity")).Get("request.tools.0.functionDeclarations")
|
|
if !decls.IsArray() || len(decls.Array()) == 0 {
|
|
t.Fatalf("%s: no declarations", name)
|
|
}
|
|
var walk func(path string, s gjson.Result)
|
|
walk = func(path string, s gjson.Result) {
|
|
typ := s.Get("type").String()
|
|
for kw, want := range map[string]string{"items": "array", "minItems": "array", "properties": "object", "required": "object"} {
|
|
if s.Get(kw).Exists() && typ != want {
|
|
t.Errorf("%s: %s has %s on type %q: %s", name, path, kw, typ, s.Raw)
|
|
}
|
|
}
|
|
s.Get("properties").ForEach(func(k, v gjson.Result) bool {
|
|
walk(path+".properties."+k.String(), v)
|
|
return true
|
|
})
|
|
if it := s.Get("items"); it.IsObject() {
|
|
walk(path+".items", it)
|
|
}
|
|
}
|
|
walk("parameters", decls.Get("0.parameters"))
|
|
if name == "older local" {
|
|
p := decls.Get("0.parameters.properties")
|
|
if got := p.Get("listed.type").String(); got != "array" || !p.Get("listed.items").Exists() || !p.Get("listed.nullable").Bool() {
|
|
t.Errorf("listed: %s", p.Get("listed").Raw)
|
|
}
|
|
if got := p.Get("shaped.type").String(); got != "object" || !p.Get("shaped.properties.q").Exists() {
|
|
t.Errorf("shaped: %s", p.Get("shaped").Raw)
|
|
}
|
|
if got := p.Get("display.enum").Raw; got != `["name","size","date"]` {
|
|
t.Errorf("display's enum: %s", p.Get("display").Raw)
|
|
}
|
|
continue
|
|
}
|
|
d := decls.Get("0.parameters.properties.display")
|
|
if d.Get("type").String() != "array" || d.Get("items.type").String() != "string" {
|
|
t.Errorf("%s: display %s", name, d.Raw)
|
|
}
|
|
}
|
|
}
|