claude-code - 💡(How to fix) Fix [Bug] Excessive token usage on prompt messages (42k tokens for 3 prompts) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47947Fetched 2026-04-15 06:37:47
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1

Error Message

[{"error":"MaxFileReadTokenExceededError: File content (10961 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n at ULK (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4666:12262)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async QLK (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4670:2638)\n at async Object.call (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4675:7235)\n at async hMY (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3954:8327)","timestamp":"2026-04-14T14:24:41.498Z"},{"error":"Error: Request was aborted.\n at jR.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:47:3448)\n at processTicksAndRejections (node:internal/process/task_queues:105:5)\n at runNextTicks (node:internal/process/task_queues:69:3)\n at process.processTimers (node:internal/timers:540:9)","timestamp":"2026-04-14T14:30:07.560Z"}]

Code Example

[{"error":"MaxFileReadTokenExceededError: File content (10961 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n    at ULK (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4666:12262)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async QLK (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4670:2638)\n    at async Object.call (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4675:7235)\n    at async hMY (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3954:8327)","timestamp":"2026-04-14T14:24:41.498Z"},{"error":"Error: Request was aborted.\n    at jR.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:47:3448)\n    at processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at runNextTicks (node:internal/process/task_queues:69:3)\n    at process.processTimers (node:internal/timers:540:9)","timestamp":"2026-04-14T14:30:07.560Z"}]
RAW_BUFFERClick to expand / collapse

Bug Description My messages token are 42k while I've just had three prompts in total

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 2.1.107
  • Feedback ID: 0075fc32-d923-45bc-b51d-c0dfc8b37d65

Errors

[{"error":"MaxFileReadTokenExceededError: File content (10961 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n    at ULK (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4666:12262)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async QLK (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4670:2638)\n    at async Object.call (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:4675:7235)\n    at async hMY (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3954:8327)","timestamp":"2026-04-14T14:24:41.498Z"},{"error":"Error: Request was aborted.\n    at jR.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:47:3448)\n    at processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at runNextTicks (node:internal/process/task_queues:69:3)\n    at process.processTimers (node:internal/timers:540:9)","timestamp":"2026-04-14T14:30:07.560Z"}]

extent analysis

TL;DR

Use the offset and limit parameters to read specific portions of the file, as the current file content exceeds the maximum allowed tokens.

Guidance

  • The error message indicates that the file content exceeds the maximum allowed tokens (10000), suggesting that the issue is related to the size of the file being read.
  • To mitigate this, use the offset and limit parameters to read specific portions of the file instead of reading the whole file at once.
  • Review the code at cli.js:4666:12262 to understand how the file is being read and modify it to implement pagination or partial reads.
  • Consider searching for specific content instead of reading the whole file to reduce the number of tokens being processed.

Example

No specific code example can be provided without more context, but the general approach would involve modifying the file reading logic to use offset and limit parameters, such as readFile(offset: 0, limit: 10000).

Notes

The provided error messages and stack traces suggest that the issue is related to the @anthropic-ai/claude-code library, but without more information about the specific use case and code, it's difficult to provide a more detailed solution.

Recommendation

Apply workaround: Use the offset and limit parameters to read specific portions of the file, as this is the suggested solution in the error message and is likely to resolve the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [Bug] Excessive token usage on prompt messages (42k tokens for 3 prompts) [1 comments, 2 participants]