fix: distinguish vLLM 'at least' lower-bound from exact input token counts - #69045
Closed
jamesreader wants to merge 1 commit into
Closed
fix: distinguish vLLM 'at least' lower-bound from exact input token counts#69045jamesreader wants to merge 1 commit into
jamesreader wants to merge 1 commit into
Conversation
…ounts vLLM reports 'at least N input tokens' as an early tokenizer cutoff, not the actual prompt size. The existing regex captured both 'at least N' and exact N indistinguishably, causing parse_available_output_tokens_from_error() to treat the lower bound as exact and compute a retry budget. On a retry, lowering max_tokens made the lower bound rise by the same amount, looping forever at context_window + 1. Fix: - Use negative lookahead to skip 'at least' qualified matches in the vLLM input token regex — lower-bound errors now return None, routing to input compression instead of a futile output-cap reduction loop. - Add supports_tools to ProviderProfile for providers without function calling support (avoids sending tools to models that can't parse them). - Update test expectations: 'at least' messages route to compression, exact-count messages still provide a usable retry budget. Closes infinite retry loop with local vLLM backends.
Collaborator
Author
|
Duplicate of #58869 which already covers the vLLM lower-bound fix with additional context clamping. Closing to avoid noise. |
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.
Problem
vLLM reports context window errors in two forms:
your prompt contains at least 81921 input tokens— this is an early tokenizer cutoff, NOT the actual prompt size. vLLM stops counting once it determines N + requested_output exceeds the window.your prompt contains 81921 input tokens— this is the actual token count.The existing regex captured both indistinguishably:
r'prompt contains (?:at least )?(\d+)\s*input tokens'This caused
parse_available_output_tokens_from_error()to treat the lower bound as exact and compute a retry budget. On a retry, lowering max_tokens made the lower bound rise by the same amount, creating an infinite loop that always totals context_window + 1.Fix
Use a negative lookahead to skip 'at least' qualified matches:
r'prompt contains (?!at least )(\d+)\s*input tokens'at least N) now returnNonefromparse_available_output_tokens_from_error()andFalsefromis_output_cap_error(), routing correctly to input compression.Additional changes
supports_toolsfield toProviderProfilefor providers without function calling support (avoids sending tools to models that deadlock on unparseable schemas).Testing
Existing tests updated.
test\_vllm\_token\_based\_lower\_bound\_routes\_to\_compressionverifies that 'at least' messages route to compression, andtest\_vllm\_exact\_count\_retry\_fits\_inside\_windowconfirms exact-count messages still provide a retry budget.