BUG: classifyHandoffIfNeeded is not defined - SubagentStop hook failure
Resolved 💬 26 comments Opened Jan 31, 2026 by christauff Closed Feb 15, 2026
💡 Likely answer: A maintainer (ashwin-ant, collaborator)
responded on this thread — see the highlighted reply below.
Bug Description
When using the Task tool to spawn subagents (background or foreground), the SubagentStop event fails with error:
classifyHandoffIfNeeded is not defined
The error occurs after the subagent completes its work and after any custom SubagentStop hooks run successfully. This appears to be an internal Claude Code function that is referenced but not defined.
Environment
- Claude Code Version: 2.1.27
- Platform: Linux (Ubuntu)
- Discovered by: @christauff and Aineko (Claude Opus 4.5 AI assistant)
Reproduction Steps
- Use the Task tool to spawn any subagent:
Task({
subagent_type: "GrokResearcher", // or any agent type
description: "Test task",
prompt: "Do a simple search for X"
})
- Wait for the agent to complete its work
- Observe error in task notification:
Agent "X/Twitter correlation for christauff" failed: classifyHandoffIfNeeded is not defined
Observed Behavior
- The subagent completes its work successfully
- Custom SubagentStop hooks (if configured) run successfully
- Then Claude Code's internal SubagentStop handler throws
classifyHandoffIfNeeded is not defined - The task is marked as "failed" even though all work completed
Expected Behavior
- SubagentStop should complete without error
- Task should be marked as "completed" (not "failed") when work finished successfully
Evidence
Debug log from custom SubagentStop hook shows successful execution before the error:
[2026-01-31T03:02:25.814Z] 🔍 SubagentStop hook started
[2026-01-31T03:02:25.819Z] Input received: {"session_id":"...
[2026-01-31T03:02:25.820Z] Transcript path: /home/...
[2026-01-31T03:02:25.820Z] Starting findTaskResult...
[2026-01-31T03:02:25.839Z] Task output found, length: 412
[2026-01-31T03:02:25.839Z] Instance metadata: {"agent_type":"GrokResearcher"}
The hook completes successfully, then Claude Code's internal processing fails.
Impact
- Severity: Low (cosmetic - work completes fine)
- Frequency: 100% reproducible on every Task completion
- Workaround: None needed - results are captured despite "failed" status
Additional Context
This was observed across multiple agent types:
- GrokResearcher
- ClaudeResearcher
- GeminiResearcher
- general-purpose
All exhibit the same classifyHandoffIfNeeded is not defined error after successful completion.
---
Discovered during OSINT research session, 2026-01-30
Investigation and bug report by Aineko (Claude Opus 4.5) with @christauff
27 Comments
same here
Same here also
Same here
same here
Additional report: Critical workflow blocker
Environment
Impact: HIGH — All Task tool agents affected
Today I experienced this error on 6 consecutive Task tool invocations:
| Agent ID | Task Description | Result |
|----------|------------------|--------|
|
a702c75| Check ACS monitoring | ❌ Failed ||
aa6b342| Check Conductor conflicts | ❌ Failed ||
a6e55df| Remove budget config | ❌ Failed ||
a29ab83| Create parse-agent-tokens.sh | ❌ Failed ||
ad51a9e| Create parse-agent-worktime.sh | ❌ Failed ||
a15254f| Create agent-metrics-report.sh | ❌ Failed |Critical observation
The agents complete their work successfully — files are created, Redis data is written, code executes properly — but then fail on the handoff/completion step with:
This suggests the error occurs in the agent termination phase, not during execution.
Workaround (partial)
Since agents complete their tasks before failing:
However, this is not sustainable — we cannot rely on background agents for any workflow automation.
Request
This bug is blocking production workflows that depend on multi-agent orchestration.
Questions:
Thank you for investigating.
Same Issue here
same
Came here to report this issue. Experiencing on MacOS.
Bug Report: Oracle Agent Dependency Assumptions
### Problem
The oracle agent assumes external Perplexity research scripts exist and fails with JavaScript errors when they don't.
### Expected Behavior
### Actual Behavior
scripts/perplexity_ask.pyModuleNotFoundError: No module named 'runtime'classifyHandoffIfNeeded is not definedJavaScript error### Steps to Reproduce
architecture...")`
uv run python -m runtime.harness scripts/perplexity_ask.py### Environment
### Error Log
Agent attempted:
uv run python -m runtime.harness scripts/perplexity_ask.py --query "..."
Error: ModuleNotFoundError: No module named 'runtime'
Final error: classifyHandoffIfNeeded is not defined
Agent ID: a82119e
### Suggested Fix
classifyHandoffIfNeededundefined JavaScript error### Workaround
Use WebSearch/WebFetch directly or general-purpose agents instead of oracle agent.
### Impact
I am getting this issue on MacOS.
Root Cause Analysis (v2.1.31)
I had Claude trace through the minified source to understand exactly when this error occurs.
In the following, all line numbers are relative to the cli.js file after being run through
prettier.The Bug
The function
classifyHandoffIfNeededis called but never defined in the codebase:The function appears to have been intended for classifying/tagging agent output when completion happens in background (perhaps to determine if a "handoff" notification to user is needed), but the implementation was never added.
When This Code Path Executes
The call is inside the "moved-to-background" completion handler (lines 421966-422035). Based on my code trace, this path is entered when:
run_in_background: true(synchronous start)backgroundSignalpromise resolves (line 421963)isBackgroundedflag is true (line 421968)The
backgroundSignalis created byq54()and stored in a Map (w$6). It's resolved byK54(), which is called by$$6(), which is triggered by thetask:backgroundkeybinding (ctrl+b).Control Flow
Discrepancy with Reports
The analysis suggests the bug requires explicit ctrl+b to background an agent mid-execution. However, many reports (including this thread) describe it happening on routine Task tool usage without mentioning ctrl+b.
Possible explanations:
Key Code Locations (v2.1.31)
| Function | Line | Purpose |
|----------|------|---------|
|
classifyHandoffIfNeeded| 421994 | Called but undefined (the bug) ||
q54| 296212 | Creates task with backgroundSignal promise ||
K54| 296245 | Backgrounds agent: sets flag + resolves signal ||
$$6| 296704 | Backgrounds all eligible agents (ctrl+b handler) ||
w$6| 296272 | Map storing background signal resolvers |Version History
| Version | References to
classifyHandoff||---------|--------------------------------|
| v2.1.25 | 0 |
| v2.1.26 | 1 (introduced) |
| v2.1.27+ | 1 (persists) |
What Changed in v2.1.26
Comparing the background completion handler between versions:
v2.1.25 (working) - lines 426810-426816:
v2.1.26 (broken) - same location:
The function call was added to prepend classification text to the agent output, but the function implementation was never included. This is a classic incomplete refactoring bug.
Suggested Fix
Either:
``
javascript
``const E1 = typeof classifyHandoffIfNeeded === 'function'
? await classifyHandoffIfNeeded({...})
: null;
Workaround
Downgrade to v2.1.25 if you frequently use ctrl+b to background agents:
Or avoid pressing ctrl+b while agents are running.
---
Question for anyone hitting this bug
Are you using tmux?
The code shows ctrl+b triggers backgrounding, and in tmux, ctrl+b is the prefix key. If you're running Claude Code inside tmux and press ctrl+b (even for tmux commands), it might inadvertently trigger the background action.
The code has tmux awareness (line 549035:
xA.terminal === "tmux" && D === "ctrl+b"), but there may be edge cases.Please reply if you can confirm:
This would help the team identify whether the trigger is always ctrl+b or if there's another code path.
I see platform:linux in the labels, but I want to add a note that I am also seeing on windows.
It happens when I interrupt a tool cool to add more info (Interrupted · What should Claude do instead?), meaning replying 'No' and add some comments
Update: Still broken on v2.1.34 (2026-02-07)
5 days since our last report. Bug persists across 3 more versions (2.1.27 → 2.1.34).
Today's failures (2026-02-07)
| Agent ID | Task | Result |
|----------|------|--------|
|
a46b3b0| Analyze all hook scripts | ❌ classifyHandoffIfNeeded ||
a250101| Audit scripts and hooks integrity | ❌ classifyHandoffIfNeeded ||
a959426| Audit MD docs and references | ❌ classifyHandoffIfNeeded ||
aac2607| Check session startup and role switching | ❌ classifyHandoffIfNeeded |Total affected agents across our sessions: 10+
Observation
The
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1flag is set. All Task tool invocations withsubagent_type: Explorefail at completion. The agents do their work, collect data, then crash on the handoff step.Impact
We cannot use multi-agent workflows reliably. Every Task tool call results in a "failed" status despite successful execution, which:
Priority request
This issue has 17 thumbs-up, 11 comments from different users, zero response from Anthropic. Could a team member please acknowledge and provide an ETA?
Environment: Claude Code 2.1.34, Linux, Ubuntu
Additional Data Point: 100% Reproduction with Explore Agents (v2.1.37)
Environment
opusplan(Opus for planning, Sonnet for execution)Test Case
Testing sub-agent model selection with Explore agent type across 3 different model configurations.
Results: 100% Failure Rate (3/3 agents)
| Agent ID | Model Requested | Model Used | Duration | Error |
|----------|----------------|------------|----------|-------|
| a8f510b |
haiku|claude-haiku-4-5-20251001✅ | ~50s |classifyHandoffIfNeeded is not defined|| a93cf41 |
sonnet|claude-haiku-4-5-20251001| ~45s |classifyHandoffIfNeeded is not defined|| ad59a46 |
opus|claude-haiku-4-5-20251001| ~50s |classifyHandoffIfNeeded is not defined|Note: Explore agents ignore the
modelparameter and always use Haiku (appears intentional for optimization).Key Observations
Error Pattern
classifyHandoffIfNeededmatches the pattern described in earlier commentsNo Hooks Configured
.claude/settings.jsonopusplanmodel setting in CLAUDE.mdImpact
Session Artifacts
Session transcripts available showing:
Confirms Earlier Findings
This data point confirms:
---
Workaround Status: Avoiding all sub-agents until fix is released.
Would be helpful to know:
Still a problem, still wasting my time, tokens, and patience. Anthropic, please fix this. Also, could you please do a little bit of testing at your end in the future, or charge less money to the paying customers you're using as beta testers? I spend more time and money fighting your bugs than I spend doing my actual work or fighting my own bugs... every day this feels more and more like obstacles with a fee.
The workaround I'm using is explicitly telling the subagents to write their final output/handoff message to a file before attempting the actual handoff... still wastes tokens, but not as many as having to redo the entire subagent session.
Just had 20+ sub-agents fail because of this
2.1.39...Anthropic, you're really digging your own grave with stuff like this. Go on Hacker News, on Reddit - developers that used to love your product are starting to turn away due to a never-ending stream of bugs in Claude Code. Unless you fundamentally change something, you're going to loose your momentum to the competition.
same here
Agent "Create AQA test scenarios" failed: classifyHandoffIfNeeded is not defined2.1.39Claude Code itself says: "Wait for the Claude Code fix. The error is cosmetic — agents complete their work successfully, they're just marked "failed." You can live with it."
oh wow I'm not alone here, can this get fixed it's annoying to say the least
Still failing in 2.1.41 (with Sonnet 4.5 subagents, does not happen in Opus subagents)
Hi, I reviewed 'BUG: classifyHandoffIfNeeded is not defined - SubagentStop hook failure' and can start immediately. I can deliver a first usable version quickly and iterate based on your feedback. If this scope still matches your priority, I can proceed right away.
Yes, please
On Fri, Feb 13, 2026, 5:43 AM michaellinhq @.***> wrote:
fail
Fix coming in next release
i already blocked plan mode tools forever, and i guess i am done with built-in subagents now.
All dispatched subagents sooner or later error with
classifyHandoffIfNeeded is not definedfor me.Claude Code 2.1.44
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.