Workflow agent(): agentType with restricted tools blocks StructuredOutput when schema is set

Open 💬 0 comments Opened Jun 13, 2026 by sam-fakhreddine

Bug

When using agent() in a Workflow script with both agentType (custom agent definition) and schema (structured output), the subagent fails:

subagent completed without calling StructuredOutput (after 2 in-conversation nudges)

Root cause

Custom agent definitions restrict available tools via tools: in YAML frontmatter (e.g., tools: Read). When schema is also specified, the workflow runtime appends a StructuredOutput instruction to the prompt but does not inject the StructuredOutput tool into the restricted tool list. The agent sees the instruction but physically cannot call the tool.

Repro

Agent definition (.claude/agents/my-reader.md):

---
name: my-reader
tools: Read
model: haiku
---
Read files and return JSON.

Workflow script:

const result = await agent(
  'Read file.json and return contents',
  { schema: { type: 'object', properties: { data: { type: 'string' } }, required: ['data'] }, agentType: 'my-reader' }
)
// Fails: agent nudged twice, then returns null

Expected

StructuredOutput should be auto-injected into the agent's tool list when schema is present, regardless of the tools: restriction. The tools: field restricts user-facing tools, not platform-internal tools.

Workaround

Either drop agentType (lose token savings) or drop schema (lose structured output, parse text manually).

Related

  • #68093 — StructuredOutput loops forever in parallel() subagent
  • #67311 — Infinite retry loop on StructuredOutput validation
  • #63742 — StructuredOutput as control-channel field notes

Environment

  • Claude Code: latest (2026-06-13)
  • macOS Darwin 25.5.0
  • Custom agents defined in .claude/agents/*.md with restricted tools: lists

View original on GitHub ↗