Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gateway: a Gemini model's untyped tool schemas go typed (Vertex refused cua-driver's drag)

yetone68ee4117af81
diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md
index 34263a16d..19918a9f7 100644
--- a/docs/subsystems/gateway-routing.md
+++ b/docs/subsystems/gateway-routing.md
@@ -215,6 +215,7 @@ recorded as a prediction failure (`noPrediction`).
- A Chat upstream that wants a turn's reasoning back (`chatReplaysReasoning` in [`chat.go`](../../internal/gateway/chat.go): a host or a model, as magpie or the provider names it, with `deepseek` in it, such as OpenCode Go's `deepseek-v4.1-flash`, or Command Code's plugin) gets every assistant tool call with `reasoning_content`, relayed (`withReasoningOnToolTurns` in `passthrough`) or translated (`buildChat`). DeepSeek turns the whole request away ("The `reasoning_content` in the thinking mode must be passed back to the API") when a tool call made since the user's last message has none, which a client sends for a turn it saw no thinking on: another model's, a translated one (#1462). The turn's own thinking goes back as it came; one sent in `reasoning` or `reasoning_details` is copied in, and `reasoning` is then left out (`asReasoningContent`): a self-hosted DeepSeek server reads the two as one field and refused pi's tool turn, which carried its thinking in `reasoning`, as "duplicate field reasoning" (ArvinCharl on X, v0.1.1560), while `reasoning_details`, a list of typed entries that can hold an encrypted one, stays; otherwise it goes with a space (`noReasoning`: DeepSeek's Chat API takes an empty one, but a relay that leaves empty fields out would drop it). An assistant message right after a tool result, a reply with no call of its own, gets one too: DeepSeek refuses it the same way (checked 2026-10-12, #1822). A reply to the user, any other model and Mistral (#494) are sent as before.
- An assistant turn the user cut off before it said anything (only its thinking, an empty text, nothing; an isolated Codex reasoning item; a Gemini thought alone) stays in the agent's history and is sent on every later turn. DeepSeek and Kimi turn the whole request away over an assistant message with neither content nor tool calls, `reasoning_content` alone included ("Invalid assistant message: content or tool_calls must be set", #2599). Every Chat upstream gets such a turn left out, translated (`buildChat`, before `pairToolMessages`) or relayed (`silentAssistantsOut` in `passthrough`), by one rule (`withoutSilentAssistants` in [`chat.go`](../../internal/gateway/chat.go)): the two user messages it stood between join into one, and after a tool result the user's message follows the tool message. A prefill to go on from (`prefix`, `partial`, a Resume), a legacy `function_call`, a refusal and an audio reply stay, and a relayed body without such a turn goes byte for byte. `TestChatEmptyAssistantLeftOutFromAnthropic`, `…FromResponses`, `…FromGemini`, `TestChatRelayLeavesOutEmptyAssistant`, `TestChatRelaySilentAssistantsOnly`.
- Kimi's Chat API (`isKimi`: the Kimi platform's and a Kimi Code membership's hosts or presets) turns `reasoning_details` in a message away in any shape: an entry with a stream's `index` ("the reasoning_details at position 1 entry 0 must not contain streaming index") and any other entry ("… has an invalid type"), checked against api.kimi.com/coding on 2026-10-12. pi keeps another vendor's thinking there (MiMo's, through Command Code, with `index: 0`), so a conversation routed on to Kimi was refused on every turn (#1765). `passthrough` sends it to Kimi as `reasoning_content` (`reasoningDetailsAsContent`, with the message's `reasoning` left out once its text is there), which Kimi takes; a message with `reasoning_content` of its own keeps that. Another upstream that refuses a thinking field "at position N", as Kimi words it (a relay in front of it), is asked once more the same way and marked (`refusedInMessages`, `withoutMessageReasoning`).
+- Vertex AI takes a function declaration's parameters as its own Schema object, whose `type` is required, and turns the whole request away over one schema without it, though the tool is never called: 400 "`mcp__cua-driver__drag` functionDeclaration `parameters.target` schema didn't specify the schema type field." (kthink on Discord: dsh with cua-driver's MCP tools, from before cua's own fix in its #4888, on Command Code's `google/gemini-3.8-flash`, which Command Code's gateway serves on Vertex; `target` was an anyOf of an untyped oneOf and null, `scope` a const). A body whose `model` names Gemini (`geminiNamed`: the id's last `/` segment starts with `gemini`, whoever serves it) has each untyped schema under its tools' `function.parameters`, `parameters` or `input_schema` given its type in place (`geminiToolTypes` in [`gemini_schema.go`](../../internal/gateway/gemini_schema.go), in `forwardOnce`, so a plugin's request too): from its enum or const values, its keywords or its branches, null left out, `{}` or a description alone a string, a tool's root an object. A node whose branches have more than one type, an unresolved `$ref` or union, and anything under `not` or `if` are left as they came, so such a schema can still be refused; every other model's tools go byte for byte. Google's own Gemini API and Code Assist are sent `parametersJsonSchema` and Antigravity `plainSchema`, so a Gemini-shaped body isn't walked (`TestGeminiToolTypesCuaDriverDrag`, with cua-driver's drag schema as its server listed it, `TestGeminiToolTypes`).
- A Responses request's top-level `access_programs`, the Cyber program Codex asks the model under (`{"cyber":"standard"}` on a subagent it inherits, OpenAI's Daybreak programs, magpie-releases#18), goes only where Codex itself would send it: codex-rs sends it with a ChatGPT sign-in, or an API key on its provider named `openai`, and to no other provider (`cyber_access_program.rs`, `for_auth`, `for_provider`). In `forwardOnce`, relayed or built (from Chat too), it goes as it came to a ChatGPT (Codex) account, a host ending in `openai.com`, another magpie (`IsRemoteMagpie`, whose own upstream decides) and a relay set `codexAsSent` when Codex sent the request; every other Responses upstream is sent the request without it (`keepsAccessPrograms`, `withoutTopMember`, the rest byte for byte). OpenCode Go answered it, for DeepSeek and GLM, with 503 "Upstream request failed: Endpoint is unavailable." and 200 without it or with null; its Haiku took it (#3172, three reporters' real A/B runs). It is taken out before the user's extraBody is merged, so an `access_programs` written there still goes. Chat and Messages builds never carry it; a Chat request relayed as it came keeps whatever its client wrote. `TestAccessProgramsGoToOpenAIAlone`, `TestWithoutTopMember`, `TestCodexAccessProgramsReachBackend`.
- Claude Code's deferred tools (ToolSearch, MCP tools that come and go) put blocks of their own in a message: a `tool_addition` (`tool` a `tool_reference` naming the tool, or a `tool_definition`), a `tool_removal`, and a `tool_reference`. Kimi's Anthropic endpoint refuses any of them with a whole-request 400 "Invalid request Error" that names nothing, so once a session had loaded a tool every turn failed (#2042); DeepSeek's takes a `tool_addition` naming a tool but refuses one defining it, a `tool_removal` and a message's `tool_reference` with 422 "unknown variant `tool_removal`" (both checked against the real endpoints on 2026-10-14). OpenCode Go also rejects DeepSeek inline definitions with a generic 422 "Upstream request failed: Endpoint is unavailable." (checked on 2026-10-15). Kimi and DeepSeek models on OpenCode are never sent these blocks (`forwardOnce`); a provider that refuses one in those words is asked again at once without them and not sent them again while magpie runs (`refuseShapes`, `shapeDeferred`; the retry loop reads a 422 as well as a 400). `withoutDeferredTools` drops the blocks and a message they leave empty; definitions present only in a `tool_addition.tool.definition` join the request's `tools` once by name (an existing top-level definition wins), and a `tool_reference` inside a `tool_result` (ToolSearch's answer, which both take) stays. Any other provider is sent them as Claude Code wrote them ([`anthropic_shapes.go`](../../internal/gateway/anthropic_shapes.go), `TestKimiIsSentNoDeferredToolBlocks`, `TestDeferredToolBlocksRefusedOnceLeftOut`, `TestOpenCodeDeepSeekInlineTools`, `TestDeferredInlineDefinitionPreserved`).
- ToolSearch's answer is a `tool_result` whose content is `tool_reference` blocks alone. OpenDesign's Anthropic endpoint can't read one: 422 "Failed to deserialize the JSON body into the target type: messages[4]: missing field `content`" (#2124, the reporter's direct request without magpie fails the same way; the same result with a text block beside the references is taken). A provider that refuses in those words while the request holds such a result is asked again at once with a text block first in each, "Tool <name> is loaded and can be called now." (`toolLoadedText`, the words a translated route already gives a model in `stringOrText`), the references and the `tool_use`/`tool_result` pairing kept, and is sent it that way while magpie runs (`refuseShapes`, `shapeRefsOnly`, `withRefsSaid`). This is in `forward`, so `/v1/messages`, `count_tokens` and a group's member all get it; a request translated to another API already carries the references as that text. Any other provider is sent the bare references (`TestRefsOnlyToolResultRefusedGetsText`, `TestRefsSaidLeavesOtherResults`).
diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go
index f9da9b196..e66e1a621 100644
--- a/internal/gateway/gateway.go
+++ b/internal/gateway/gateway.go
@@ -4091,6 +4091,7 @@ func (s *Server) forwardOnce(ctx context.Context, p provider.Provider, to provid
body = toolOneOfAsAnyOf(p, to, body)
body = kimiToolEnumTypes(p, to, body)
body = kimiToolRefTypes(p, to, body)
+ body = geminiToolTypes(body)
body = kimiLockedSampling(p, to, body)
body = clinePin(p, to, body)
body = codexImagesFit(p, to, body)
diff --git a/internal/gateway/gemini_schema.go b/internal/gateway/gemini_schema.go
new file mode 100644
index 000000000..70534bc6d
--- /dev/null
+++ b/internal/gateway/gemini_schema.go
@@ -0,0 +1,147 @@
+package gateway
+
+import (
+ "strings"
+
+ "github.com/tidwall/gjson"
+)
+
+// geminiToolTypes is body with a type written into each schema of its
+// tools' that has none, for a Gemini model whoever serves it. Vertex AI
+// takes a function declaration's parameters as its own Schema object, whose
+// type is required, and turns the whole request away over one schema
+// without it, though the tool is never called: 400 "Unable to submit
+// request because `mcp__cua-driver__drag` functionDeclaration
+// `parameters.target` schema didn't specify the schema type field."
+// (kthink on Discord: dsh with cua-driver's MCP tools, Command Code's
+// google/gemini-3.8-flash, which its gateway serves on Vertex). Whoever
+// relays a Chat, Responses or Messages body to Vertex — a plugin's
+// gateway, a router, a relay — turns the schema into Vertex's, and an
+// untyped node stays untyped, so it is keyed on the model, not the
+// provider.
+//
+// Each schema with no type is given the one its values (enum, const,
+// default), keywords (properties: object, items: array, pattern:
+// string …) or branches (anyOf, oneOf, allOf, a local $ref) say, null
+// left out: Vertex has one type a node, nullable apart. A node whose
+// branches have more than one type, or a $ref or union whose types can't
+// be told, is left as it came: no one type is right for it. One that says
+// nothing ({} or only a description) is a string, the value that carries
+// anything; a tool's root is an object. "not" and "if" are left alone: a
+// type there would turn the rule round. The type is written in place,
+// after the schema's brace, so the rest of the body and a cache's prefix
+// stay as they were; every other model's body goes as it came.
+//
+// Google's own Gemini API and Code Assist are sent parametersJsonSchema,
+// which takes JSON Schema whole, and Antigravity its own cut-down schema
+// (plainSchema), so a Gemini-shaped body isn't walked.
+func geminiToolTypes(body []byte) []byte {
+ if !geminiNamed(gjson.GetBytes(body, "model").String()) {
+ return body
+ }
+ tools := gjson.GetBytes(body, "tools")
+ if !tools.IsArray() || tools.Index <= 0 {
+ return body
+ }
+ var ins []typeInsert
+ tools.ForEach(func(_, tool gjson.Result) bool {
+ for _, at := range []string{"function.parameters", "parameters", "input_schema"} {
+ if root := tool.Get(at); root.IsObject() {
+ collectGeminiUntyped(body, root, root, true, &ins)
+ }
+ }
+ return true
+ })
+ return withTypes(body, ins)
+}
+
+// geminiNamed is whether a model id names a Gemini model: gemini-…, or
+// a relay's or router's vendor/gemini-… (google/gemini-3.8-flash,
+// vertex_ai/gemini-…).
+func geminiNamed(id string) bool {
+ if i := strings.LastIndexByte(id, '/'); i >= 0 {
+ id = id[i+1:]
+ }
+ return strings.HasPrefix(strings.ToLower(id), "gemini")
+}
+
+// collectGeminiUntyped adds, for node and each schema under it that has no
+// type, where it opens and the type Vertex is told.
+func collectGeminiUntyped(body []byte, root, node gjson.Result, isRoot bool, ins *[]typeInsert) {
+ switch {
+ case node.IsArray():
+ node.ForEach(func(_, v gjson.Result) bool {
+ collectGeminiUntyped(body, root, v, false, ins)
+ return true
+ })
+ case node.IsObject():
+ if !node.Get("type").Exists() && node.Index > 0 && node.Index < len(body) && body[node.Index] == '{' {
+ if t := geminiSchemaType(root, node, isRoot); t != "" {
+ *ins = append(*ins, typeInsert{node.Index, `"` + t + `"`})
+ }
+ }
+ node.ForEach(func(key, v gjson.Result) bool {
+ switch key.String() {
+ case "properties", "$defs", "definitions", "dependentSchemas", "patternProperties":
+ v.ForEach(func(_, s gjson.Result) bool {
+ collectGeminiUntyped(body, root, s, false, ins)
+ return true
+ })
+ case "items", "additionalProperties", "contains", "propertyNames", "then", "else", "allOf", "anyOf", "oneOf", "prefixItems", "unevaluatedProperties", "unevaluatedItems", "contentSchema":
+ collectGeminiUntyped(body, root, v, false, ins)
+ }
+ return true
+ })
+ }
+}
+
+// geminiSchemaType is the one type an untyped schema s is given for
+// Vertex, "" when it is left as it came.
+func geminiSchemaType(root, s gjson.Result, isRoot bool) string {
+ vals := s.Get("enum").Array()
+ if c := s.Get("const"); c.Exists() {
+ vals = []gjson.Result{c}
+ }
+ if s.Get("enum").IsArray() || s.Get("const").Exists() {
+ var rest []gjson.Result
+ for _, v := range vals {
+ if v.Type != gjson.Null {
+ rest = append(rest, v)
+ }
+ }
+ return valuesType(rest)
+ }
+ ts := schemaTypes(root, s, 0)
+ delete(ts, "null")
+ if ts["integer"] && ts["number"] {
+ delete(ts, "integer")
+ }
+ if len(ts) == 1 {
+ for t := range ts {
+ return t
+ }
+ }
+ if len(ts) > 1 {
+ return ""
+ }
+ if isRoot {
+ return "object"
+ }
+ for _, k := range []string{`\$ref`, "anyOf", "oneOf", "allOf"} {
+ if s.Get(k).Exists() {
+ return ""
+ }
+ }
+ if d := s.Get("default"); d.Exists() && d.Type != gjson.Null {
+ switch {
+ case d.IsObject():
+ return "object"
+ case d.IsArray():
+ return "array"
+ }
+ if t := valuesType([]gjson.Result{d}); t != "" {
+ return t
+ }
+ }
+ return "string"
+}
diff --git a/internal/gateway/gemini_schema_test.go b/internal/gateway/gemini_schema_test.go
new file mode 100644
index 000000000..fcc8af2a1
--- /dev/null
+++ b/internal/gateway/gemini_schema_test.go
@@ -0,0 +1,144 @@
+package gateway
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "strings"
+ "testing"
+
+ "github.com/tidwall/gjson"
+ "github.com/yetone/magpie/internal/provider"
+)
+
+// cua-driver's drag tool, as its MCP server listed it before cua's #4888
+// (the schema kthink's dsh sent): target is an anyOf of an untyped oneOf
+// and null, scope a const with no type. Command Code's
+// google/gemini-3.8-flash, served on Vertex, refused every request with
+// it: 400 "`mcp__cua-driver__drag` functionDeclaration `parameters.target`
+// schema didn't specify the schema type field." A Gemini model is sent
+// each untyped schema with its type, on the chat route, the Anthropic
+// route and from a Responses body, and the rest of the body as it came;
+// a GPT model on the same provider is sent the body byte for byte.
+func TestGeminiToolTypesCuaDriverDrag(t *testing.T) {
+ t.Setenv("XDG_CONFIG_HOME", t.TempDir())
+ t.Setenv("XDG_CACHE_HOME", t.TempDir())
+ if err := provider.Save(provider.Provider{ID: "cc", Name: "CC", Key: "k", Chat: "https://cc.test/v1", Anthropic: "https://cc.test",
+ Models: []string{"google/gemini-3.8-flash", "openai/gpt-5.5"}}); err != nil {
+ t.Fatal(err)
+ }
+ raw, err := os.ReadFile("testdata/cua_driver_drag_untyped.json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ schema := strings.TrimSpace(string(raw))
+ want := strings.NewReplacer(
+ `"scope":{"const"`, `"scope":{"type":"string","const"`,
+ `"target":{"anyOf":[{"description"`, `"target":{"type":"object","anyOf":[{"type":"object","description"`,
+ ).Replace(schema)
+ if want == schema || strings.Count(want, `"type":"object","`) != strings.Count(schema, `"type":"object","`)+2 {
+ t.Fatal("the fixture no longer has the shape the test is about")
+ }
+ var got []byte
+ s := New()
+ s.client = &http.Client{Transport: countTransport(func(r *http.Request) (*http.Response, error) {
+ got, _ = io.ReadAll(r.Body)
+ return &http.Response{StatusCode: 400, Header: http.Header{"Content-Type": {"application/json"}},
+ Body: io.NopCloser(strings.NewReader(`{"error":{"message":"no","type":"invalid_request_error"}}`))}, nil
+ })}
+ routes := []struct{ path, tools, at string }{
+ {"/v1/chat/completions", `"tools":[{"type":"function","function":{"name":"mcp__cua-driver__drag","parameters":%s}}]`, "tools.0.function.parameters"},
+ {"/v1/messages", `"tools":[{"name":"mcp__cua-driver__drag","input_schema":%s}]`, "tools.0.input_schema"},
+ {"/v1/responses", `"tools":[{"type":"function","name":"mcp__cua-driver__drag","parameters":%s}]`, ""},
+ }
+ for _, r := range routes {
+ for _, model := range []string{"google/gemini-3.8-flash", "openai/gpt-5.5"} {
+ got = nil
+ msgs := `"messages":[{"role":"user","content":"hi"}],"max_tokens":16,`
+ if r.path == "/v1/responses" {
+ msgs = `"input":"hi",`
+ }
+ body := `{"model":"cc/` + model + `",` + msgs + fmt.Sprintf(r.tools, schema) + `}`
+ rec := httptest.NewRecorder()
+ s.Handler().ServeHTTP(rec, httptest.NewRequest("POST", r.path, strings.NewReader(body)))
+ if got == nil {
+ t.Fatalf("%s %s: nothing went upstream: %d %s", r.path, model, rec.Code, rec.Body)
+ }
+ if !json.Valid(got) {
+ t.Fatalf("%s %s: invalid JSON went upstream:\n%s", r.path, model, got)
+ }
+ sent := ""
+ for _, at := range []string{"tools.0.function.parameters", "tools.0.input_schema", "tools.0.parameters"} {
+ if v := gjson.GetBytes(got, at); v.Exists() {
+ sent = v.Raw
+ break
+ }
+ }
+ gemini := strings.HasPrefix(model, "google/")
+ switch {
+ case gemini && sent != want:
+ t.Errorf("%s: Gemini was sent the schema\n%s\nwant\n%s", r.path, sent, want)
+ case !gemini && sent != schema:
+ t.Errorf("%s: GPT was sent the schema\n%s\nwant it as it came\n%s", r.path, sent, schema)
+ }
+ if !gemini && r.path != "/v1/responses" {
+ // The same route, untranslated: the tools go byte for byte.
+ if exp := fmt.Sprintf(r.tools, schema); !bytes.Contains(got, []byte(exp)) {
+ t.Errorf("%s: GPT's tools changed:\n%s\nwant\n%s", r.path, got, exp)
+ }
+ }
+ }
+ }
+}
+
+// Each schema a Gemini model is sent without a type gets the one its
+// values, keywords or branches say; one that could be several, a "not"
+// and every typed schema are left as they were, and a model no one names
+// Gemini gets the body back as it came.
+func TestGeminiToolTypes(t *testing.T) {
+ params := `{"properties":{` +
+ `"any":{},"spaced":{ },"said":{"description":"x"},` +
+ `"n":{"enum":[1,2]},"f":{"enum":[1,2.5]},"b":{"const":true},"maybe":{"enum":["a",null]},"mixed":{"enum":["a",1]},` +
+ `"list":{"items":{}},"obj":{"properties":{"k":{"type":"string"}}},"pat":{"pattern":"^a"},` +
+ `"u":{"anyOf":[{"type":"string"},{"type":"null"}]},"two":{"anyOf":[{"type":"string"},{"type":"integer"}]},` +
+ `"num":{"oneOf":[{"type":"integer"},{"type":"number"}]},"r":{"$ref":"#/$defs/D"},"dflt":{"default":3},` +
+ `"neg":{"type":"string","not":{"enum":["x"]}},"typed":{"type":"array","items":{"type":"integer"}}},` +
+ `"$defs":{"D":{"properties":{}}}}`
+ want := strings.NewReplacer(
+ `{"properties":{"any":{}`, `{"type":"object","properties":{"any":{"type":"string"}`,
+ `"spaced":{ }`, `"spaced":{"type":"string" }`,
+ `"said":{`, `"said":{"type":"string",`,
+ `"n":{`, `"n":{"type":"integer",`,
+ `"f":{`, `"f":{"type":"number",`,
+ `"b":{`, `"b":{"type":"boolean",`,
+ `"maybe":{`, `"maybe":{"type":"string",`,
+ `"list":{"items":{}}`, `"list":{"type":"array","items":{"type":"string"}}`,
+ `"obj":{`, `"obj":{"type":"object",`,
+ `"pat":{`, `"pat":{"type":"string",`,
+ `"u":{`, `"u":{"type":"string",`,
+ `"num":{`, `"num":{"type":"number",`,
+ `"r":{`, `"r":{"type":"object",`,
+ `"dflt":{`, `"dflt":{"type":"integer",`,
+ `"D":{`, `"D":{"type":"object",`,
+ ).Replace(params)
+ for _, id := range []string{"gemini-3.8-flash", "google/gemini-3.8-flash", "vertex_ai/Gemini-2.5-pro"} {
+ body := []byte(`{"model":"` + id + `","tools":[{"type":"function","function":{"name":"t","parameters":` + params + `}}]}`)
+ out := geminiToolTypes(body)
+ if !json.Valid(out) {
+ t.Fatalf("%s: invalid JSON:\n%s", id, out)
+ }
+ if got := gjson.GetBytes(out, "tools.0.function.parameters").Raw; got != want {
+ t.Errorf("%s: sent\n%s\nwant\n%s", id, got, want)
+ }
+ }
+ for _, id := range []string{"claude-sonnet-4.6", "gpt-5.5", "google/gemma-4", "my-gemini/m", "kimi-k3", ""} {
+ body := []byte(`{"model":"` + id + `","tools":[{"type":"function","function":{"name":"t","parameters":` + params + `}}]}`)
+ if out := geminiToolTypes(body); !bytes.Equal(out, body) {
+ t.Errorf("%s: the body changed:\n%s", id, out)
+ }
+ }
+}
diff --git a/internal/gateway/kimi_schema.go b/internal/gateway/kimi_schema.go
index 8d698c323..e6a7a26d9 100644
--- a/internal/gateway/kimi_schema.go
+++ b/internal/gateway/kimi_schema.go
@@ -54,13 +54,31 @@ func withTypes(body []byte, ins []typeInsert) []byte {
}
start := last + 1
out.Write(body[start : in.at+1])
- out.WriteString(`"type":` + in.typ + `,`)
+ out.WriteString(`"type":` + in.typ)
+ if !emptyObjectAt(body, in.at) {
+ out.WriteByte(',')
+ }
last = in.at
}
out.Write(body[last+1:])
return out.Bytes()
}
+// emptyObjectAt is whether the object opening at body[at] is {}, spaces
+// aside: a type written into it has nothing after it to be parted from.
+func emptyObjectAt(body []byte, at int) bool {
+ for i := at + 1; i < len(body); i++ {
+ switch body[i] {
+ case ' ', '\t', '\n', '\r':
+ continue
+ case '}':
+ return true
+ }
+ return false
+ }
+ return false
+}
+
// isKimi is whether p is served by Moonshot: the Kimi platform's API or a
// Kimi Code membership's.
func isKimi(p provider.Provider, to provider.Protocol) bool {
diff --git a/internal/gateway/testdata/cua_driver_drag_untyped.json b/internal/gateway/testdata/cua_driver_drag_untyped.json
new file mode 100644
index 000000000..f30ddfcac
--- /dev/null
+++ b/internal/gateway/testdata/cua_driver_drag_untyped.json
@@ -0,0 +1 @@
+{"additionalProperties":false,"properties":{"button":{"enum":["left","right","middle"],"type":"string"},"duration_ms":{"maximum":10000,"minimum":0,"type":"integer"},"from_x":{"type":"number"},"from_y":{"type":"number"},"modifier":{"items":{"type":"string"},"type":"array"},"scope":{"const":"desktop","description":"Deprecated flat desktop target retained for wire compatibility."},"session":{"description":"For multi-call work, prefer a short public session label and repeat it on every call that\naccepts it. Omit it to use the authenticated transport's implicit lifecycle session.","type":"string"},"steps":{"maximum":200,"minimum":1,"type":"integer"},"target":{"anyOf":[{"description":"Exact capture/input target selected independently for each action.\n\n`display_id=\"primary\"` is the portable desktop target in this release.\nPlatforms that cannot address another display reject it explicitly rather\nthan silently changing coordinate spaces.","oneOf":[{"additionalProperties":true,"properties":{"kind":{"const":"window","type":"string"},"pid":{"minimum":0,"type":"integer"},"window_id":{"minimum":0,"type":"integer"}},"required":["kind","pid","window_id"],"type":"object"},{"additionalProperties":true,"properties":{"display_id":{"type":"string"},"kind":{"const":"desktop","type":"string"}},"required":["kind","display_id"],"type":"object"}]},{"type":"null"}],"description":"Preferred per-call target: an exact window (`kind=\"window\"`, `pid`, `window_id`) or the\nprimary desktop (`kind=\"desktop\"`, `display_id=\"primary\"`)."},"to_x":{"type":"number"},"to_y":{"type":"number"}},"required":["from_x","from_y","to_x","to_y"],"type":"object"}