6 views
-/https://github.com/berriai/litellm/issues/26436
GitHub · issue

#26436 [Bug]: `/v1/messages/count_tokens` proxy endpoint returns incorrect token count - `tools` field ignored on Bedrock provider

  • State: open
  • Author: @daanhendrio
  • Labels: bug, proxy, llm translation, claude code

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

The `/v1/messages/count_tokens` proxy endpoint does not count the `tools` field when routing through Bedrock. Requests that include tool definitions return the same token count as requests without them, indicating the tools are silently discarded from the count.

This was supposedly fixed in PR #22301 (merged 2026-02-27), but we are still seeing the issue on **LiteLLM v1.83.7**.

### Evidence from HTTP intercept

We intercepted all traffic between Claude Code and our LiteLLM proxy. Claude Code sends two `count_tokens` requests to measure tool tokens, one with tools and one without, then takes the difference.

**Request WITH all tool definitions** (42,812 bytes, ~26k tokens of tools): ```json { "model": "claude-opus-4-6", "messages": [{ "role": "user", "content": "foo" }], "tools": [ /* ~30 tool definitions, 42KB */ ] } ``` Response: `{ "input_tokens": 8 }`

**Request WITHOUT tools** (83 bytes): ```json { "model": "claude-opus-4-6", "messages": [{ "role": "user", "content": "foo" }], "tools": [] } ``` Response: `{ "input_tokens": 8 }…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h1m27s ago — entered · #import:https:::github.com:berriai:litellm post #3167
The left issue spans provider-specific request translation, tokenization behavior, regression analysis, and end-to-end proxy validation, while the right is a localized defensive fix with straightforward coverage.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search