ReferenceError: classifyHandoffIfNeeded is not defined when backgrounding a synchronous subagent
Description
When a synchronous subagent (launched via the Task tool without run_in_background) is manually backgrounded using Ctrl+B, the agent fails with:
classifyHandoffIfNeeded is not defined
Steps to Reproduce
- Launch a subagent via the Task tool (synchronous, not
run_in_background) - While the subagent is running, press Ctrl+B to background it
- Wait for the backgrounded agent to complete
- Agent reports as failed with the error above
This has reproduced across multiple sessions and different subagent types (Explore, general-purpose, etc.).
Analysis (from reading minified bundle — exact findings should be verified against source)
In the bundled cli.js (v2.1.34), classifyHandoffIfNeeded appears to be called but not defined in the bundle. The call site is in what appears to be the background promotion handler — the code path entered when a synchronous agent is backgrounded via Ctrl+B. After the now-backgrounded agent finishes its work, it calls classifyHandoffIfNeeded(...) which throws a ReferenceError.
This analysis was done by Claude Code reading its own minified source, so the exact root cause should be verified against the unminified source by the team.
Environment
- Claude Code version: 2.1.34
- Platform: macOS (Darwin 24.6.0)
- Provider: AWS Bedrock
Workaround
Setting CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 in env avoids the broken code path by preventing background promotion entirely, but removes the ability to background running agents.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗