Task() subagent fails intermittently with 'classifyHandoffIfNeeded is not defined'
Description
When launching subagents via Task() (concurrent isolated agents), the call intermittently fails with:
classifyHandoffIfNeeded is not defined
The error occurs before the agent's own code executes - it's in the Claude Code agent runtime bootstrap.
Reproduction
- Launch two
Task()calls in parallel (same message, concurrent execution) - Both agents fail with
classifyHandoffIfNeeded is not defined - Retry the same calls → both succeed on second attempt
Context
- Platform: Windows 11
- Trigger: Parallel
Task()calls with customsubagent_type(skill-based agents) - Frequency: Intermittent (not every time, but reproducible across sessions)
- Workaround: Retry succeeds reliably on second attempt
Expected Behavior
Task() calls should succeed on first invocation without requiring retries.
Actual Behavior
First invocation fails with classifyHandoffIfNeeded is not defined. The function appears to not be defined/imported in certain execution contexts, possibly related to parallel agent initialization timing.
Hypothesis
Likely a race condition in the agent runtime initialization when multiple subagents are spawned simultaneously. The classifyHandoffIfNeeded function may not be available yet when the agent bootstrap tries to call it.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗