mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-05 01:59:27 +00:00
The /v1/messages/count_tokens proxy endpoint was only passing `messages` to provider token counting APIs, discarding `system` and `tools`. This caused clients like Claude Code to receive artificially low token counts (e.g. 10 instead of 531), preventing proper context window management and leading to context overflow errors. Pass system and tools through the full chain: - TokenCountRequest → proxy_server → provider counters → API handlers - Bedrock: transform tools to toolConfig format, system to text blocks - Anthropic/Azure AI: pass through directly (same API format) |
||
|---|---|---|
| .. | ||
| test_bedrock_count_tokens_transformation.py | ||