Task tool subagent fails with 'classifyHandoffIfNeeded is not defined'

Resolved 💬 5 comments Opened Feb 1, 2026 by Beaulewis1977 Closed Mar 5, 2026

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

  1. Install a plugin that registers a custom subagent type:

``bash
/plugin marketplace add /path/to/plugin
/plugin install plugin-name
``

  1. Restart Claude Code to load the plugin
  1. 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..."

```

  1. 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

  1. Reproducible: Failed on two consecutive attempts with identical error
  2. Partial execution: Agent does work before crashing (skills load, files read)
  3. Error location: Appears to be in handoff/completion logic, not tool execution
  4. Function undefined: classifyHandoffIfNeeded is 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:

  1. A function is being called that isn't imported/available in the current scope
  2. This may be a module bundling issue where custom subagent execution paths don't have access to all required internal functions
  3. 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 /plugin commands 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.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗