Task tool agents crash with 'classifyHandoffIfNeeded is not defined' after completing work

Resolved 💬 3 comments Opened Feb 12, 2026 by KCW89 Closed Feb 16, 2026

Bug Description

Task tool subagents (spawned via the Task tool) crash with classifyHandoffIfNeeded is not defined after successfully completing their work. The agent produces its full output, but the parent conversation receives a "failed" status notification instead of the result.

Environment

  • Claude Code version: 2.1.39
  • OS: macOS 15 (Darwin 25.2.0 arm64)
  • Node.js: v20.19.0
  • Model (parent): claude-opus-4-6
  • Model (subagent): claude-haiku-4-5-20251001

Steps to Reproduce

  1. Use the Task tool to spawn an Explore agent (or other subagent type)
  2. Let the agent complete its work (read files, search code, produce analysis)
  3. Agent finishes and generates its final text response
  4. Crash occurs on the return path — parent receives:
<task-notification>
<task-id>a6944db</task-id>
<status>failed</status>
<summary>Agent "Explore 3-panel layout structure" failed: classifyHandoffIfNeeded is not defined</summary>
</task-notification>

Expected Behavior

The agent should return its completed result to the parent conversation with status: completed.

Actual Behavior

  • The agent completes all its work (file reads, analysis, final text output)
  • On the return/handoff path back to the parent, it crashes with classifyHandoffIfNeeded is not defined
  • Parent receives a failed status notification
  • The agent's full output is available in the task output file despite the "failed" status

Workaround

The agent's work products are already applied/saved before the crash. Reading the task output file (/private/tmp/claude-501/.../tasks/<agent-id>.output) reveals the complete result. This is a cosmetic failure — the work is done, but the orchestration layer reports it as failed.

Agent Log Excerpt

From the task output JSONL (a6944db.output):

{
  "version": "2.1.39",
  "agentId": "a6944db",
  "slug": "greedy-squishing-kurzweil",
  "isSidechain": true,
  "message": {
    "model": "claude-haiku-4-5-20251001",
    "role": "assistant",
    "content": [{"type": "text", "text": "Perfect! I have enough information now..."}],
    "stop_reason": null
  }
}

The agent successfully produced ~2500 words of analysis, then crashed before the result could be delivered to the parent.

Frequency

Occurs intermittently. Not every agent invocation fails — some complete and return normally. The same agent type (Explore with haiku) sometimes succeeds and sometimes hits this error. Reproducible across multiple sessions.

Additional Context

  • The function name classifyHandoffIfNeeded suggests it's part of the agent orchestration/handoff system
  • The crash always happens after the agent's final assistant message, never during tool use
  • stop_reason: null in the last message may be relevant — possibly the response was still streaming when the handoff was attempted

View original on GitHub ↗

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