Task tool: agent crashes with 'classifyHandoffIfNeeded is not defined'
Bug description
When using the Task tool with a custom subagent_type (defined via project configuration), the spawned agent intermittently crashes with:
classifyHandoffIfNeeded is not defined
This is not a one-off — it happens regularly across different conversations and agent types.
Steps to reproduce
- Configure custom agent types in the project (e.g.,
TX Architect) - Spawn an agent via the
Tasktool withsubagent_typeset to a custom agent - The agent starts working (makes several tool calls successfully)
- At some point, it crashes with the above error
Expected behavior
The agent completes its task without crashing on an internal runtime error.
Actual behavior
The agent fails with status failed and error classifyHandoffIfNeeded is not defined. The agent had already made progress (72 tool calls, 99K tokens) before the crash, confirming this is a runtime error in the agent orchestration layer, not a config issue.
Environment
- Claude Code CLI (latest)
- Model: claude-opus-4-6
- OS: Linux (openSUSE Leap 16.0)
- Custom subagent types configured via
.claude/project settings
Frequency
~10-20% of agent spawns with custom subagent types. Significant workflow disruption.
Workaround
Re-running the same task or falling back to manual tool calls.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗