[BUG] "classifyHandoffIfNeeded is not defined" error when sub-agent returns result to main agent
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When a sub-agent (launched via the Task tool with subagent_type=general-purpose) completes its task and attempts to return its final response to the main agent, the handoff fails with the following error:
classifyHandoffIfNeeded is not defined
The sub-agent itself executes successfully — it runs a bash command (docker run --rm with a Python script), produces correct output, and generates a final summary. The error only occurs at the point where the result is handed back to the main agent.
This appears to be a bug in the sub-agent → main agent handoff logic, where the classifyHandoffIfNeeded function is referenced but not defined.
What Should Happen?
The sub-agent's final response should be returned to the main agent without errors. Since the sub-agent's task completes successfully and the result is ready, the handoff should proceed normally.
Error Messages/Logs
Steps to Reproduce
- Launch a sub-agent using the Task tool with
subagent_type=general-purposein the background - Have the sub-agent execute a Bash command (e.g.,
docker run --rmrunning a Python script) — this completes successfully - Have the sub-agent generate a final response (e.g., a data summary) — this also completes successfully
- When the sub-agent attempts to return its response to the main agent, the error
classifyHandoffIfNeeded is not definedis thrown
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.42
Platform
Anthropic API
Operating System
Other
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
- Agent ID:
abadd71 - The sub-agent's actual work (data extraction, bash execution, result aggregation) all completed without issues. Only the final handoff step fails.
- This suggests the
classifyHandoffIfNeededfunction is missing from the handoff processing code path in v2.1.42, possibly a regression or an incomplete deployment of a new feature.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗