[BUG] `--agent <unknown-name>` is silently ignored instead of erroring
Resolved 💬 2 comments Opened Jun 7, 2026 by garochee33 Closed Jun 11, 2026
Environment
- Claude Code: 2.1.168
- OS: macOS 15.7.7 (Intel, Darwin 24.6.0)
Steps to reproduce
claude -p "Reply with exactly OK" --model haiku --agent nonexistent-agent-xyz
echo $?
Expected
A hard error (or at minimum a warning on stderr) that the agent nonexistent-agent-xyz is not defined — matching the behavior of other flags that validate their values (e.g. --permission-mode rejects invalid choices).
Actual
Exit code 0, the prompt runs against the default session configuration, and no warning is emitted. The flag is silently ignored.
Working comparison
claude -p "Reply with exactly OK" --model haiku \
--agents "{\"reviewer\": {\"description\": \"Reviews code\", \"prompt\": \"You are a code reviewer\"}}" \
--agent reviewer # works as documented
Why it matters
A typo in --agent (or a missing --agents/settings definition in CI) silently runs with the wrong system prompt and toolset instead of failing — exactly the kind of misconfiguration that should fail loudly in scripted -p usage.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗