[FEATURE] Output schema for subagent definitions (unknown key outputSchema is silently ignored)

Status Open
Reported on v2.1.289
Maintainer reply None cached
Activity 0 comments · opened Oct 5, 2026

Summary

Subagent definitions (plugin agents, .claude/agents/*.md, --agents) cannot declare an output schema, and an unknown key such as outputSchema is accepted silently and ignored. Workflow agent(prompt, {schema}) already enforces output natively through StructuredOutput, so the capability exists; it is just not reachable from an agent definition spawned with the Agent tool.

This re-raises #20625 (closed as stale, now locked), with a concrete repro and a use case.

Repro (Claude Code 2.1.289)

claude -p --agents '{"echoer":{"description":"test","prompt":"Reply with the word hello.","outputSchema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"],"additionalProperties":false}}}' \
  "Use the echoer agent and show me exactly what it returned."
  • Expected: the agent's result is validated against the schema (as in a workflow agent(..., {schema})), or the CLI warns that outputSchema is not a supported key.
  • Actual: no warning; the agent returns hello.

Use case

A subagent that fronts external work, for example dispatching a job to another tool and handing back a reference, must return an exact set of fields, never its own paraphrase. In our measurements, instruction-only compliance was 8 of 33 replies; the rest were prose, and some contained invented content.

Inside workflows the schema fixes this natively. For Agent-tool spawns the only way we found is a pair of hooks:

  • SubagentStop that blocks until the final message equals the expected fields;
  • PreToolUse on SubagentHandback, because in auto mode an agent ends with a handback and a SubagentStop block after it has no effect.

With those hooks in place, compliance was 31 of 31. A native schema on the agent definition would make both hooks unnecessary.

Request

  1. Support an output schema in agent definitions (frontmatter, --agents JSON, plugin agents), enforced the same way as workflow agent(..., {schema}).
  2. Warn on unknown keys in agent definitions instead of ignoring them silently.

View original on GitHub ↗