Files
magpie/internal/provider/testdata/codex_automation_update_schema.json
yetone faab600e50 provider: a tool's root union whose branches are unions themselves folds with their fields kept, so Grok can create a Codex automation (#1271)
xiaocui12: Codex on Grok, "[invalid_client_tool_schema]
mcp__codex_app__automation_update: tool parameter root must be an object
type (root schema is an anyOf/oneOf union with a non-object branch)".
Codex desktop's automation_update (ChatGPT.app 26.930, zod 4's
toJSONSchema with $defs) is a root anyOf of view, delete, create and
update, and create and update are unions on kind themselves. ObjectRoot
dropped those nested branches: the fold kept only mode (const "view") and
id, both required. Grok took the tool but could only view.

A branch that is itself a union is now folded first (on a copy, up to 8
deep); a field the root doesn't define takes each distinct schema the
branches give it, as anyOf when they differ; a field every branch
requires stays required (here only mode).

Verified with the real Grok subscription and the real schema
(testdata, rebuilt with zod 4.1.8 from ChatGPT.app's app.asar): raw, 400
with the reporter's exact message; the old fold, 200 but no tool call when
asked to create an automation; the new fold, 200 and
{"mode":"create","kind":"heartbeat","name":"CI watch","prompt":"check CI",
"status":"ACTIVE","destination":"thread","rrule":"FREQ=MINUTELY;INTERVAL=30"}.
TestObjectRootNestedUnion fails without the change ("no name among
[id mode]", "required = [mode id]", mode leaves out "delete", kind null).
2026-10-08 17:01:22 +08:00

383 lines
6.5 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"type": "object",
"properties": {
"mode": {
"type": "string",
"const": "view"
},
"id": {
"$ref": "#/$defs/__schema0"
}
},
"required": [
"mode",
"id"
],
"additionalProperties": false
},
{
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/__schema2"
},
"prompt": {
"$ref": "#/$defs/__schema3"
},
"rrule": {
"$ref": "#/$defs/__schema4"
},
"status": {
"$ref": "#/$defs/__schema5"
},
"notificationPolicy": {
"$ref": "#/$defs/__schema6"
},
"kind": {
"$ref": "#/$defs/__schema7"
},
"projectId": {
"$ref": "#/$defs/__schema8"
},
"model": {
"$ref": "#/$defs/__schema9"
},
"reasoningEffort": {
"$ref": "#/$defs/__schema10"
},
"mode": {
"$ref": "#/$defs/__schema11"
},
"destination": {
"type": "string",
"const": "local"
},
"executionEnvironment": {
"type": "string",
"const": "local"
}
},
"required": [
"name",
"prompt",
"rrule",
"status",
"kind",
"projectId",
"model",
"reasoningEffort",
"mode",
"executionEnvironment"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/__schema2"
},
"prompt": {
"$ref": "#/$defs/__schema3"
},
"rrule": {
"$ref": "#/$defs/__schema4"
},
"status": {
"$ref": "#/$defs/__schema5"
},
"notificationPolicy": {
"$ref": "#/$defs/__schema6"
},
"kind": {
"$ref": "#/$defs/__schema12"
},
"destination": {
"$ref": "#/$defs/__schema13"
},
"targetThreadId": {
"$ref": "#/$defs/__schema14"
},
"mode": {
"$ref": "#/$defs/__schema11"
}
},
"required": [
"name",
"prompt",
"rrule",
"status",
"kind",
"mode"
],
"additionalProperties": false
}
]
},
{
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/__schema2"
},
"prompt": {
"$ref": "#/$defs/__schema3"
},
"rrule": {
"$ref": "#/$defs/__schema15"
},
"status": {
"$ref": "#/$defs/__schema5"
},
"notificationPolicy": {
"$ref": "#/$defs/__schema6"
},
"kind": {
"$ref": "#/$defs/__schema7"
},
"projectId": {
"$ref": "#/$defs/__schema8"
},
"model": {
"$ref": "#/$defs/__schema9"
},
"reasoningEffort": {
"$ref": "#/$defs/__schema10"
},
"mode": {
"$ref": "#/$defs/__schema16"
},
"id": {
"$ref": "#/$defs/__schema0"
},
"destination": {
"type": "string",
"enum": [
"local",
"worktree"
]
},
"executionEnvironment": {
"description": "env",
"type": "string",
"enum": [
"worktree",
"local"
]
},
"localEnvironmentConfigPath": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "null"
}
]
}
},
"required": [
"name",
"prompt",
"rrule",
"status",
"kind",
"projectId",
"model",
"reasoningEffort",
"mode",
"id",
"executionEnvironment"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/__schema2"
},
"prompt": {
"$ref": "#/$defs/__schema3"
},
"rrule": {
"$ref": "#/$defs/__schema15"
},
"status": {
"$ref": "#/$defs/__schema5"
},
"notificationPolicy": {
"$ref": "#/$defs/__schema6"
},
"kind": {
"$ref": "#/$defs/__schema12"
},
"destination": {
"$ref": "#/$defs/__schema13"
},
"targetThreadId": {
"$ref": "#/$defs/__schema14"
},
"mode": {
"$ref": "#/$defs/__schema16"
},
"id": {
"$ref": "#/$defs/__schema0"
}
},
"required": [
"name",
"prompt",
"rrule",
"status",
"kind",
"mode",
"id"
],
"additionalProperties": false
}
]
},
{
"type": "object",
"properties": {
"mode": {
"type": "string",
"const": "delete"
},
"id": {
"$ref": "#/$defs/__schema0"
}
},
"required": [
"mode",
"id"
],
"additionalProperties": false
}
],
"$defs": {
"__schema0": {
"description": "Automation id.",
"$ref": "#/$defs/__schema1"
},
"__schema1": {
"type": "string",
"minLength": 1
},
"__schema2": {
"description": "name",
"$ref": "#/$defs/__schema1"
},
"__schema3": {
"description": "prompt",
"$ref": "#/$defs/__schema1"
},
"__schema4": {
"description": "rrule create",
"$ref": "#/$defs/__schema1"
},
"__schema5": {
"description": "status",
"type": "string",
"enum": [
"ACTIVE",
"PAUSED"
]
},
"__schema6": {
"description": "np",
"anyOf": [
{
"type": "string",
"enum": [
"all",
"failed_runs_only"
]
},
{
"type": "null"
}
]
},
"__schema7": {
"description": "cron",
"type": "string",
"const": "cron"
},
"__schema8": {
"description": "project",
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "null"
}
]
},
"__schema9": {
"description": "model",
"$ref": "#/$defs/__schema1"
},
"__schema10": {
"description": "effort",
"type": "string",
"enum": [
"none",
"minimal",
"low",
"medium",
"high",
"xhigh",
"max",
"ultra"
]
},
"__schema11": {
"type": "string",
"enum": [
"create",
"suggested_create"
]
},
"__schema12": {
"description": "hb",
"type": "string",
"const": "heartbeat"
},
"__schema13": {
"description": "dest",
"type": "string",
"enum": [
"local",
"thread"
]
},
"__schema14": {
"format": "uuid",
"description": "tt",
"$ref": "#/$defs/__schema1"
},
"__schema15": {
"description": "rrule",
"$ref": "#/$defs/__schema1"
},
"__schema16": {
"type": "string",
"enum": [
"update",
"suggested_update"
]
}
}
}