[BUG] Workflow agentType: custom-agent body compliance collapses vs Agent tool (same prompt: 100% vs 0/16)

Open 💬 0 comments Opened Jul 7, 2026 by chrisb4096-alt

Environment: Claude Code 2.1.202, Linux (Ubuntu 26.04), custom agent in ~/.claude/agents/.

Setup: A custom agent (model: haiku, tools: Bash) whose markdown body is a strict forwarder contract: parse directive lines from the prompt, run exactly one CLI command (codex exec wrapper), return its output verbatim with metadata footer lines. It must never answer the task itself.

Observed: For the same trivial prompt (directive header + "compute 6*7, output JSON"):

  • Agent tool (subagent_type: "codex-worker"): behaves per the body — runs the CLI, returns output with the mandated footers. Reproduced repeatedly (5 tool calls, ~31s, real CLI session id in output).
  • Workflow tool (agent() with agentType: 'codex-worker'): the agent answered the task directly. Signature: 2 agents, 0 tool calls total, 3.6s — no Bash invocation at all, no footers. In a larger run earlier the same day, 16/16 Workflow-spawned instances of this agent skipped the mandated CLI and did the work themselves (verified by grepping every agent-*.jsonl transcript for the CLI invocation: zero hits), while a different Workflow run showed partial compliance (3/5), so it is not a hard 100% failure — but the delta vs the Agent tool is drastic and reproducible.

The model: haiku frontmatter is honored in both lanes (progress shows claude-haiku-4-5), so the definition resolves — either the body is not attached (or is diluted) in the Workflow lane, or compliance collapses there for task shapes the model can answer directly.

Why it matters: any "wrapper/forwarder" agent pattern (delegating to an external CLI/model) silently degrades in Workflow fan-outs — results come back plausible-looking, produced by the wrong model, with 0 errors. Related: #68043 (registry caching at session start) made this harder to debug — mid-session fixes to the agent body don't apply.

Repro sketch:

  1. Create ~/.claude/agents/echo-runner.md: model: haiku, tools: Bash, body = "You are a forwarder. For ANY prompt, run echo FORWARDED-$(date +%s) via Bash and return its output verbatim. Never answer the prompt yourself."
  2. Restart. Ask the main agent to (a) spawn it via the Agent tool with prompt "compute 6*7", (b) run a Workflow: return await agent('compute 6*7', {agentType: 'echo-runner'}).
  3. Compare: (a) returns FORWARDED-…, (b) frequently returns "42" with zero tool calls.

Ask: attach the full agent body as the system prompt in the Workflow lane identically to the Agent tool lane (or document the difference), and consider surfacing per-agent tool_uses: 0 as a workflow warning — it is the reliable signature of this failure.

View original on GitHub ↗