devin 0.1.17: a tool whose schema has a list type, an array with no items, or properties or an enum with no type goes to Gemini models in a shape they take, not "There is an issue with this request" (7eleven on Discord)

7eleven, in ZCode on devin/gemini-4-argon, got every turn refused:
"Devin: There is an issue with this request, please try a different
model." (invalid_argument). It is the request content, on Gemini models
only. On a real account, gemini-4-argon, gemini-3-1-pro and
gemini-3-8-flash refuse a request offering a tool whose schema has, at
any depth:
- a list type: ["string","null"], ["string"], ["string","number"];
- type "array" with no items, items true, or items that are a list;
- properties with no type;
- an enum with no type.
claude-sonnet-4-6 and swe-2 take all of them. Nullable written as anyOf,
items {}, nullable:true, const, $ref/$defs, additionalProperties and
format all go through on Gemini.

geminiSchema rewrites them, for a Gemini uid only:
- a list type becomes its one type, nullable when it had "null", or
  anyOf of each type;
- such an array's items become {} (a one-schema list becomes that
  schema);
- a schema with properties gets type object;
- an enum gets its values' type, and an enum of mixed values is dropped.
The caller's schema is not changed. Claude and swe-2 requests are byte
for byte what they were.

What was run:
- HOME=$(mktemp -d) bun test packages/devin: 80 pass.
- gemini-schema.test.mjs, with the gemini line in build() turned off by
  hand: 10 red, one per refused shape.
- bun scripts/check.mjs: ok.
- Real account: each refused schema, sent as built here, went through on
  gemini-4-argon-medium and gemini-3-1-pro-high.
- build() end to end with a search tool holding a list type, an array
  with no items and an untyped enum: gemini-4-argon called the tool, where
  0.1.16 got invalid_argument. claude-sonnet-4-6 called it on both.

Not tried: ZCode itself against the plugin. The reporter's exact tool is
not known; ZCode's own zod 4 tools write anyOf, so it is likely one of
their MCP or plugin tools.
This commit is contained in:
yetone
2026-10-15 11:08:07 +08:00
parent 5d5d86e225
commit 157c7c0f88
3 changed files with 153 additions and 2 deletions
+97
View File
@@ -0,0 +1,97 @@
// Devin's Gemini models answer "There is an issue with this request, please
// try a different model" (invalid_argument, 400 in magpie) to a request
// offering a tool whose schema has a list type, an array with no items or
// with a list or true as items, or properties or an enum with no type, at
// any depth (7eleven on Discord: ZCode on gemini-4-argon). Each schema
// below was sent to gemini-4-argon on a real account and refused, and went
// through as built here; Claude models and swe-2 took every one, so their
// schemas go as they came.
import { expect, test } from "bun:test"
import { _internal } from "./index.mjs"
const dec = new TextDecoder()
const sent = (b) =>
Object.fromEntries(
_internal
.fields(b)
.filter((f) => f.num === 10 && f.wire === 2)
.map((f) => {
const g = _internal.fields(f.data)
return [dec.decode(g.find((h) => h.num === 1).data), JSON.parse(dec.decode(g.find((h) => h.num === 3).data))]
}),
)
const P = (props) => ({ type: "object", properties: props })
// refused by gemini-4-argon, each on its own
const REFUSED = {
typeList: P({ a: { type: ["string", "null"] } }),
typeListOne: P({ a: { type: ["string"] } }),
typeListTwo: P({ a: { type: ["string", "number"] } }),
noItems: P({ a: { type: "array" } }),
itemsTrue: P({ a: { type: "array", items: true } }),
itemsList: P({ a: { type: "array", items: [{ type: "string" }] } }),
deepNoItems: P({ a: { type: "object", properties: { b: { type: "array" } } } }),
unionNoItems: P({ a: { anyOf: [{ type: "array" }, { type: "null" }] } }),
propsNoType: P({ a: { properties: { b: { type: "string" } } } }),
enumNoType: P({ a: { enum: ["x", "y"] } }),
}
const chatWith = (parameters) => ({
messages: [{ role: "user", content: "ok" }],
tools: [{ type: "function", function: { name: "t", description: "t", parameters } }],
})
// what Devin's Gemini models refuse, anywhere in the schema
function refused(s, at = "$") {
if (!s || typeof s !== "object" || Array.isArray(s)) return []
const out = []
if (Array.isArray(s.type)) out.push(at + " list type")
if (s.type === "array" && (!s.items || typeof s.items !== "object" || Array.isArray(s.items))) out.push(at + " items")
if (s.type === undefined && (s.properties || s.enum)) out.push(at + " no type")
for (const [k, v] of Object.entries(s.properties ?? {})) out.push(...refused(v, at + "." + k))
for (const k of ["anyOf", "oneOf", "allOf"]) for (const [i, v] of (s[k] ?? []).entries()) out.push(...refused(v, `${at}.${k}[${i}]`))
if (s.items) out.push(...refused(s.items, at + "[]"))
return out
}
for (const [name, parameters] of Object.entries(REFUSED)) {
test(`${name}: goes to a Gemini model in a shape it takes`, () => {
const before = JSON.stringify(parameters)
const got = sent(_internal.build(chatWith(parameters), "gemini-4-argon-medium", "k")).t
expect(refused(got)).toEqual([])
expect(JSON.stringify(parameters)).toBe(before)
})
test(`${name}: goes to a Claude model as it came`, () => {
expect(sent(_internal.build(chatWith(parameters), "claude-opus-5-5-high", "k")).t).toEqual(parameters)
expect(sent(_internal.build(chatWith(parameters), "swe-2-high", "k")).t).toEqual(parameters)
})
}
test("a list type keeps what it allowed", () => {
const g = (s) => _internal.geminiSchema(s)
expect(g({ type: ["string", "null"], description: "d" })).toEqual({ type: "string", nullable: true, description: "d" })
expect(g({ type: ["string"] })).toEqual({ type: "string" })
expect(g({ type: ["string", "number", "null"] })).toEqual({ nullable: true, anyOf: [{ type: "string" }, { type: "number" }] })
expect(g({ type: ["array", "null"] })).toEqual({ type: "array", nullable: true, items: {} })
expect(g({ type: "array", items: [{ type: "string" }] })).toEqual({ type: "array", items: { type: "string" } })
expect(g({ type: "array", items: [{ type: "string" }, { type: "number" }] })).toEqual({ type: "array", items: {} })
expect(g({ enum: [1, 2] })).toEqual({ type: "integer", enum: [1, 2] })
expect(g({ enum: ["x", null] })).toEqual({ type: "string", enum: ["x"], nullable: true })
expect(g({ enum: ["x", 1] })).toEqual({})
})
test("a schema Gemini takes goes as it came", () => {
const parameters = {
type: "object",
properties: {
a: { anyOf: [{ type: "string" }, { type: "null" }] },
b: { type: "array", items: { type: "string", enum: ["x"] } },
c: { $ref: "#/$defs/x" },
d: { const: "k" },
},
$defs: { x: { type: "object", properties: { y: { type: "integer" } } } },
required: ["a"],
}
expect(sent(_internal.build(chatWith(parameters), "gemini-4-argon-medium", "k")).t).toEqual(parameters)
})
+55 -1
View File
@@ -1198,6 +1198,59 @@ function foldRoot(root, ps, depth) {
const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v)
// geminiSchema is a tool's parameters as Devin's Gemini models take them.
// Devin answers "There is an issue with this request, please try a
// different model" (invalid_argument) to a Gemini model offered a tool
// whose schema, at any depth, has a type that is a list (["string",
// "null"], as zod-to-json-schema writes a nullable field), an array with
// no items, items that are a list or true, or properties or an enum with no
// type (7eleven on Discord, ZCode on gemini-4-argon). Its Claude models
// and swe-2 take all of them, so only a Gemini uid gets this. A list type
// becomes its one type, nullable when it had "null", or anyOf of each;
// such an array's items become {} (a one-schema list, that schema); a
// schema with properties is an object; an enum's type comes from its
// values, and an enum of mixed values goes. The caller's own is never
// changed.
function geminiSchema(s, depth = 0) {
if (!isObj(s) || depth > 32) return s
const out = { ...s }
const sub = (v) => geminiSchema(v, depth + 1)
for (const k of ["properties", "patternProperties", "$defs", "definitions", "dependentSchemas"])
if (isObj(out[k])) out[k] = Object.fromEntries(Object.entries(out[k]).map(([n, v]) => [n, sub(v)]))
for (const k of ["anyOf", "oneOf", "allOf", "prefixItems"]) if (Array.isArray(out[k])) out[k] = out[k].map(sub)
for (const k of ["additionalProperties", "not", "if", "then", "else", "contains"]) if (isObj(out[k])) out[k] = sub(out[k])
if (Array.isArray(out.type)) {
const types = [...new Set(out.type.filter((t) => typeof t === "string"))]
const some = types.filter((t) => t !== "null")
if (some.length < types.length && some.length) out.nullable = true
if (some.length === 1) out.type = some[0]
else if (!some.length) out.type = types.length ? "null" : undefined
else {
delete out.type
const branches = some.map((t) => ({ type: t, ...(t === "array" ? { items: {} } : {}) }))
out.anyOf = Array.isArray(out.anyOf) ? [...out.anyOf, ...branches] : branches
}
if (out.type === undefined) delete out.type
}
if (out.type === undefined && Array.isArray(out.enum)) {
const vals = out.enum.filter((v) => v !== null)
if (vals.length < out.enum.length) out.nullable = true
const kinds = new Set(vals.map((v) => (Number.isInteger(v) ? "integer" : typeof v)))
const one = kinds.size === 1 ? [...kinds][0] : kinds.size === 2 && kinds.has("integer") && kinds.has("number") ? "number" : ""
if (["string", "integer", "number", "boolean"].includes(one)) {
out.type = one
out.enum = vals
} else delete out.enum
}
if (out.type === undefined && isObj(out.properties)) out.type = "object"
if (out.type === "array" || (out.type === undefined && Object.hasOwn(out, "items"))) {
if (Array.isArray(out.items)) out.items = out.items.length === 1 && isObj(out.items[0]) ? sub(out.items[0]) : {}
else out.items = isObj(out.items) ? sub(out.items) : {}
out.type = "array"
}
return out
}
const osName = () => (process.platform === "win32" ? "windows" : process.platform)
// metadata is what each request says of the client: the CLI's own (with
@@ -1287,6 +1340,7 @@ function build(chat, uid, key) {
.filter((t) => (!t?.type || t.type === "function") && t.function?.name)
.map((t) => ({ name: t.function.name, description: t.function.description ?? "", schema: objectRoot(t.function.parameters) }))
if (chat.tool_choice === "none") tools = []
if (/gemini/i.test(uid)) tools = tools.map((t) => ({ ...t, schema: geminiSchema(t.schema) }))
const instructions = joinNonEmpty(system.join("\n\n"), toolDescriptions(tools))
if (instructions) {
let at = msgs.findIndex((m) => m.role === USER)
@@ -1713,4 +1767,4 @@ export async function DevinAuthPlugin() {
}
// for tests
export const _internal = { parseFree, freeIDs, outID, inID, objectRoot, seesImages, imagesFor, forgetSaid: () => said.clear(), parseModelConfigs, parseConfigFamilies, SNAPSHOT_IMAGES, withImages, forgetImages: () => (seen = null), effortOf, runtimeModel, configModel, live, build, failure, complete, parseFamilies, listed, variantFor, familiesOf, SNAPSHOT, parseStatus, readsHome, tierName, whoByKey, success, familiesFor, readCredentials, credentials, fields, frame, PB, events, frames }
export const _internal = { parseFree, geminiSchema, freeIDs, outID, inID, objectRoot, seesImages, imagesFor, forgetSaid: () => said.clear(), parseModelConfigs, parseConfigFamilies, SNAPSHOT_IMAGES, withImages, forgetImages: () => (seen = null), effortOf, runtimeModel, configModel, live, build, failure, complete, parseFamilies, listed, variantFor, familiesOf, SNAPSHOT, parseStatus, readsHome, tierName, whoByKey, success, familiesFor, readCredentials, credentials, fields, frame, PB, events, frames }
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-devin-auth",
"version": "0.1.16",
"version": "0.1.17",
"description": "Devin subscriptions (the devin CLI's account) in OpenCode and magpie",
"type": "module",
"main": "./index.mjs",