Task tool subagent fails with 'classifyHandoffIfNeeded is not defined'
Bug Report: Task tool subagent fails with "classifyHandoffIfNeeded is not defined"
Summary
When using the Task tool to spawn a custom subagent (registered via plugin), the agent crashes with the error classifyHandoffIfNeeded is not defined. The error is consistent and reproducible.
Environment
- Claude Code version: 2.1.29
- OS: Linux (WSL2) - 6.6.87.2-microsoft-standard-WSL2
- Node.js: v22.21.1
- npm: 10.9.4
- Platform: x86_64 GNU/Linux
Steps to Reproduce
- Install a plugin that registers a custom subagent type:
``bash``
/plugin marketplace add /path/to/plugin
/plugin install plugin-name
- Restart Claude Code to load the plugin
- Use the Task tool to invoke the custom subagent:
```
Task tool with:
- subagent_type: "project-tooling-planner" # custom type from plugin
- prompt: "Analyze project and create tooling..."
```
- The agent starts, may perform some work (e.g., invoke skills), then crashes
Expected Behavior
The custom subagent should execute to completion and return results.
Actual Behavior
The agent fails with:
Agent "..." failed: classifyHandoffIfNeeded is not defined
The error occurs consistently on retry. The agent does begin execution - it can:
- Read files
- Invoke skills (skill-forge was successfully loaded)
- Use other tools
But crashes before completing, suggesting the error occurs during handoff/completion phase.
Observations
- Reproducible: Failed on two consecutive attempts with identical error
- Partial execution: Agent does work before crashing (skills load, files read)
- Error location: Appears to be in handoff/completion logic, not tool execution
- Function undefined:
classifyHandoffIfNeededis called but not defined in scope - suggests a missing import or module resolution issue
Relevant Log Excerpts
Task notification received:
<task-notification>
<task-id>a792d81</task-id>
<status>failed</status>
<summary>Agent "Retry project tooling minimal" failed: classifyHandoffIfNeeded is not defined</summary>
</task-notification>
The agent output file shows the agent was actively working - it loaded the skill-forge skill and was processing it when the crash occurred.
Workaround
None found. The error occurs with any custom subagent type registered via plugin.
Built-in subagent types (Explore, Plan, Bash, etc.) work correctly.
Possible Cause
The error classifyHandoffIfNeeded is not defined suggests:
- A function is being called that isn't imported/available in the current scope
- This may be a module bundling issue where custom subagent execution paths don't have access to all required internal functions
- The function name suggests it's related to determining how to hand off results from the subagent back to the caller
Additional Context
- Plugin system: Using
/plugincommands to install custom subagents - The plugin successfully installs and registers the subagent type
- The subagent type appears in available types and can be invoked
- Built-in Task tool subagent types work fine
Impact
This blocks the ability to use custom subagent orchestrators via plugins, which is a key extensibility feature.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗