[BUG] Agent/Explore subagent crashes with "Cannot read properties of undefined (reading 'input_tokens')"
Status Closed — not planned
Reported on v2.1.76
Maintainer reply None cached
Workaround ✓ Mentioned in description ↑
Activity 11 comments · opened Mar 16, 2026 · closed May 10, 2026
Bug Description
When using the Agent tool (with subagent_type: Explore or general-purpose), the call consistently fails with:
Error: Cannot read properties of undefined (reading 'input_tokens')
All basic tools (Glob, Grep, Read, Bash, Edit, Write) work fine. Only the Agent/subagent invocations are affected.
Steps to Reproduce
- Start a Claude Code CLI session (v2.1.76)
- Trigger any task that invokes the Agent tool, e.g.:
subagent_type: Explore— for codebase explorationsubagent_type: general-purpose— for multi-step research
- The agent call fails immediately with the error above
- Retrying produces the same error every time
Expected Behavior
The subagent should launch, perform its task, and return results.
Actual Behavior
The subagent call fails instantly with:
Error: Cannot read properties of undefined (reading 'input_tokens')
No partial results are returned. The error appears to originate from response parsing logic where the API response object's usage or usage.input_tokens field is undefined.
Environment
- Claude Code version: 2.1.76 (latest on npm as of 2025-03-16)
- OS: Windows 11 Home China (10.0.26200)
- Node.js: v22.22.1
- Shell: Git Bash (MINGW64)
- Model: claude-opus-4-6
Workaround
Avoid using Agent/Explore subagents entirely. Use Glob, Grep, and Read tools directly for codebase searches. This works but loses the parallelism and autonomy benefits of subagents.
Additional Context
- The error is 100% reproducible — every Agent call fails, not intermittent.
- Network connectivity is fine (all other API calls succeed).
- This may be related to how subagent API responses are parsed — possibly a missing null check on
response.usagebefore accessinginput_tokens.
11 Comments
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Is there any solution for this already? It also happens when running claude code with minimax2.7 through openrouter
was happening to me after switching to minimax2.7, switched back to 2.5 and it seems to be working fine.
+1, I also encountered this problem; my model is GLM5.
+1, and it seems to occur more often when execute complex tasks.
+1, exactly same for me, minimax 2.7 keeps breaking
same for me as well, minimax 2.7 keeps breaking
I am also getting the same when using subagents within a session. I am on MacOS Tahoe, so it's not exclusive to Windows.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
Solution that worked for me
Use a proxy. this is the script I used:
And then, in my
.zshrcI am using a custom command:This way, it worked perfectly fine.
NOTE: i have shifted to using kimi 2.6 using Ollama, and this is what worked for me before moving to ollama. Overall, no issues in Ollama. Posting it here for folks who still wanna use Open Router, or something else that might be causing the same error message for them.
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.