Repository navigation
docs(count_tokens): document TOKEN_COUNTER_MAX_EXACT_CHARS and off-loop local counting - #1259
Merged
mateo-berri merged 4 commits intoSep 10, 2026
Merged
Conversation
…op local counting
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
bugbot run |
7 tasks done
Contributor
|
bugbot run |
Contributor
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6e8e368. Configure here.
mateo-berri
deleted the
litellm_lit_5546_token_counter_max_exact_chars
branch
September 10, 2026 02:29
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
docs/proxy/config_settings.mdgains theTOKEN_COUNTER_MAX_EXACT_CHARSrow in the environment variable table, anddocs/count_tokens.mdexplains that local token counting on the proxy runs off the event loop and that strings longer than that many characters (default 4,000,000, roughly a million tokens) are counted from 16 evenly spaced samples adding up to that many characters and scaled to the full lengthWhy
Pairs with the LiteLLM change for LIT-5546, where one very large count_tokens payload could stall every other request on the gateway. The setting is new in that PR and needs to be discoverable from the settings reference and the token counting page
Linear ticket
Resolves LIT-5546
Link to Devin session: https://app.devin.ai/sessions/ea3d050c61f64334a5474e411af182a9
Open in Devin Desktop: https://app.devin.ai/desktop/session/ea3d050c61f64334a5474e411af182a9?variant=devin
Requested by: @mateo-berri
Note
Low Risk
Documentation-only changes with no runtime or configuration behavior modified in this PR.
Overview
Documents proxy-side local token counting safeguards that pair with the runtime fix for large
count_tokenspayloads (LIT-5546).docs/count_tokens.mdnow states that local counting on the proxy runs off the event loop (worker thread), caps concurrent counts per worker viaTOKEN_COUNTER_MAX_CONCURRENT_COUNTS(default 4, with queuing beyond that), and for strings longer thanTOKEN_COUNTER_MAX_EXACT_CHARS(default 4,000,000) uses 16 evenly spaced samples scaled to full length instead of full exact tokenization.docs/proxy/config_settings.mdadds reference rows for both environment variables so operators can discover and tune them.Reviewed by Cursor Bugbot for commit 6e8e368. Bugbot is set up for automated code reviews on this repo. Configure here.