Skip to content

fix(subagent): shrink worker toolsets and sanitize Grok schemas - #1309

Merged
TheGreatAxios merged 6 commits into
mainfrom
cl-9839-grok-workers-fail-first-infer-with-http-400-bad-request
Oct 3, 2026
Merged

TheGreatAxios merged 6 commits into
mainfrom
cl-9839-grok-workers-fail-first-infer-with-http-400-bad-request

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Workers advertise director-scoped tool presets plus discovery/reporting controls instead of every mount. Explorers are read-only; nested orchestrators retain mounted fleet tools and required tools are pinned from spawn.
  • Mounted deferred tools are discoverable/promotable without putting all MCP schemas on the initial wire; the system prompt matches the advertised definitions.
  • submit_result.result is typed. Grok sanitation removes schema metadata and types untyped/enum/const nodes without corrupting literal payloads; Muse/Kimi retain the acyclic present rewrite.

Verification

  • Full bun run check passes against integrated main: 8,275 tests, zero failures.
  • Failing-then-passing regressions cover enum/const/literal preservation, a test matcher polluting canonical schemas, and custom nested-orchestrator fleet advertisement.
  • Role/capability, discovery/promotion, required-tool pinning, provider isolation, and scrubbed worker diagnostics pass focused checks.
  • No live Grok smoke runs. General MCP $ref cycle elimination is not implemented; those CL-9839 outcomes remain open.

Refs CL-9839
Fixes CL-9841

Grok workers inherit the parent xAI profile then 400 on first infer
with an empty Bad Request. submit_result advertised an untyped
result property, which the Responses proxy rejects, and inherited
MCP schemas can carry $schema. Give result a JSON Schema type and
sanitize Grok wire schemas so one bad tool cannot kill the infer.
@linear-code

linear-code Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

CL-9839

CL-9841

Workers were putting every mounted tool on the wire, including all
inherited MCP schemas. Dispatch already uses a CORE+CATALOG prefix
and discovers the rest via tool_search. Give leaves the same shape:
a smaller preset than dispatch, tool_search, and promote-on-execute.
MCP stays mounted for execute but off the wire until search.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review · Comment

Workers advertise a smaller preset plus tool_search (MCP stays mounted for execute and is pinned when requires_tools names it); Grok advertise paths strip $schema/$id and type untyped properties; submit_result.result is a JSON Schema object.

Findings

  • PR title — the title describes only the Grok/submit_result commit. The branch also changes every worker's advertised prefix (advertisedToolNamesForWorker, promote-on-execute, requires_tools pin). CONTRIBUTING requires the title to describe the whole branch. Something like fix(subagent): shrink worker tool prefix and sanitize Grok schemas would match both commits.

Code on the wire path is otherwise sound: leaf prefix includes tool_search / ask_director / submit_result / skill_search and excludes fleet verbs, ask_operator, and MCP names; nested orchestrators add the fleet verbs they mount and still omit wait_agents (mailbox collection, matching ToolAvailability.waitAgentsMounted); requires_tools merge into pinnedTools so a required MCP name is on the wire from turn 1. Checked bun test ./src/subagent ./src/agent/tool-search.test.ts ./src/agent/tool-schema-normalize.test.ts.

The worker wire prefix is the director package allowlist plus
tool_search and the leaf reporting channel, not one shared preset.
Explorer is READ_TOOLS (no path writes). Coder/docs/orchestrator
keep their own envelopes. apply_patch still folds via tool profile.
@TheGreatAxios TheGreatAxios changed the title fix(subagent): type submit_result and sanitize Grok tool schemas fix(subagent): shrink worker toolsets and sanitize Grok schemas Oct 3, 2026

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial enum/const corruption is resolved, with literal metadata/property names preserved. The full-suite xAI diagnostic failure is traced to a Bun nested asymmetric matcher mutating the canonical tool_search schema; asserting against a copy fixes pollution without relaxing diagnostic assertions. Review includes the concurrent b5801c0 per-director update, plus a test-first repair for custom nested orchestrators losing fleet verbs from their initial prefix. Muse/Kimi/Grok normalization paths compose correctly. Full bun run check passes with 8,275 tests and zero failures; no remaining actionable findings in the shipped code. No live Grok API smoke or generic MCP reference-cycle elimination is claimed; CL-9839 remains partial.

@TheGreatAxios
TheGreatAxios merged commit 0f7e430 into main Oct 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant