Commit Graph
1 Commits
Author SHA1 Message Date
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