[BUG] undefined is not an object (evaluating '$.input_tokens')

Resolved 💬 19 comments Opened Mar 28, 2026 by KissSheep-yq Closed May 29, 2026

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?

I asked Claude Code CLI a question. After a while, an error "undefined is not an object (evaluating '$.input_tokens')" appeared, and then the Claude Code CLI program terminated and stopped responding.

What Should Happen?

Continuously running

Error Messages/Logs

undefined is not an object (evaluating '$.input_tokens')

Steps to Reproduce

1.Ask questions to Claude Code CLI2. It responded for a while before terminating the response and displaying an error message.
undefined is not an object (evaluating '$.input_tokens')

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.86 (Claude Code)

Platform

Other

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

<img width="1233" height="220" alt="Image" src="https://github.com/user-attachments/assets/f645fe27-4c70-4089-8cd9-79a648527121" />

View original on GitHub ↗

19 Comments

github-actions[bot] · 3 months ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/34899

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

KissSheep-yq · 3 months ago

How can this be resolved?

TROYbaby · 3 months ago

How to solve this problem?

cipherpodliq1 · 3 months ago

Is this resolved?

Kk-Ling · 3 months ago

I switched model from sonnet to sonnet (1M context) then it fix. wtf??

jzl2001 · 3 months ago

确定你们使用的模型较好支持anthropic协议,我最近在做一套协议翻译机制,使用minimax 2.5没有问题,但是gemini3.1出问题了,最后排查下来还是协议翻译出错了,修改后OK了。所以该问题本质还是模型返回的结果有问题。

<img width="1182" height="722" alt="Image" src="https://github.com/user-attachments/assets/7bffab4c-e2ad-4b3e-bea8-8cbd05bc9456" />

visilica · 3 months ago

any solution?

elliejayliquid · 3 months ago

Have this issue, too.

andriihrachov · 3 months ago

upvote

chirsco · 3 months ago

Reproduced in 2.1.101

exhyy · 3 months ago

Reproduced in 2.1.104 with a custom provider

saidelike · 3 months ago

Reproduced it in 2.1.104 (I don't recall seeing it before). And it makes Claude stop what it is doing so you need to start prompting again from scratch, and you loose most of the work that was done on the last prompt...

ly3ke-code · 3 months ago

I just ran into the same problem. CC starts looking for a solution, but it always ends with the same error - "Error: undefined is not an object (evaluating 'H.input_tokens')".
The problem was resolved by instructing the system not to call on subagents when working with files. Text generated by the LLM: "The subagent did not send the file to the disk. I will read the files myself and perform semantic extraction...". No more errors were generated, and the task was completed...

wintertee · 2 months ago

In my case, the API provider doesn't support Haiku models, which Claude Code uses for session titles and sub-agents. Redirecting Haiku models to Sonnet models solves this issue.

bio-la · 2 months ago

using the sonnet models doesn't solve the issue for me, and before seeing this issue i had " API Error: 400 messages.1.content.0.type: Expected thinking or redacted_thinking, but found text. ..." tried disabling thinking mode and clearing conversation to no avail. i am not sure what the thinking mode may have to do with this error either.

akgnitd · 2 months ago

Reproducing on macOS, not just Linux.

  • Claude Code version: 2.1.114
  • OS: macOS (Darwin 25.4.0, Apple Silicon)
  • Shell: zsh
  • Custom proxy / ANTHROPIC_BASE_URL: none — direct to api.anthropic.com
  • Frequency: happens across multiple sessions in both the CLI and IDE extensions
  • Error: undefined is not an object (evaluating '_.input_tokens')

The original report tagged this platform:linux, but the crash path is platform-independent — it's triggered whenever a
response/stream arrives without a usage.input_tokens field. Please consider broadening the label and bumping priority.

Stack trace (from ~/.claude/debug/latest):
▎ 2026-04-20T18:30:07.519Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=b49c4321-4fcc-4fcf-86e4-8c95dffedfd3
▎ 2026-04-20T18:30:07.640Z [ERROR] TypeError: undefined is not an object (evaluating '_.input_tokens')
▎ at xD4 (/$bunfs/root/src/entrypoints/cli.js:253:395119)
▎ at DqH (/$bunfs/root/src/entrypoints/cli.js:253:395716)
▎ at Hc7 (/$bunfs/root/src/entrypoints/cli.js:8066:16753)
▎ at next (native:1:11)
▎ at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8064:11568)
▎ at n18 (/$bunfs/root/src/entrypoints/cli.js:4742:2314)
▎ at next (native:1:11)
▎ at ZIH (/$bunfs/root/src/entrypoints/cli.js:8064:11538)

▎ Observations
▎ - Crash fires ~120 ms after the POST /v1/messages — i.e., in the response/usage-parsing path, well before any tokens would
▎ normally stream.
▎ - The CLI doesn't exit; it swallows the error and continues writing .claude.json, but the turn is lost — looks like an
▎ unhandled rejection in the usage-metadata handler.
▎ - Strongly suggests the code assumes every response body contains usage.input_tokens; likely failing on error responses
▎ (overloaded/rate-limit/4xx) or non-streamed replies.

▎ Fix suggestion: guard the usage access (resp?.usage?.input_tokens ?? 0) and branch on response type before reading it.

@claude

thirking · 2 months ago

Encountered a similar issue. Simply canceling the ccswitch proxy resolved the problem.

<img width="576" height="94" alt="Image" src="https://github.com/user-attachments/assets/6f68509f-4fad-41a4-aefd-6a0707b05954" />

Jindequan · 2 months ago
Encountered a similar issue. Simply canceling the ccswitch proxy resolved the problem.

yep, it's cc-switch's fault, and you can fix it by switch auth-type, from ANTHROPIC_AUTH_TOKEN to ANTHROPIC_API_KEY

github-actions[bot] · 1 month ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.