Refuse max_tokens above the real 4096 Ollama cap - #23
Merged
Merged
Conversation
8192 used to pass inspect_payload and then be silently clamped in chat(); the POST now sends the requested num_predict or raises max_tokens_too_large. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
inspect_payloadadvertisedMAX_TOKENS=8192whilechat()silentlymin()-clampednum_predicttoMAX_TOKENS_CAP=4096.num_predict;8192raisesmax_tokens_too_largeand never hits Ollama.MAX_BYTES) is untouched. No A8/A9, downstairs GPU, or Halo 4 work.Test plan
test_chat_num_predict_equals_requestedcaptures POSToptions.num_predictand asserts it equals the requested valuetest_chat_max_tokens_above_cap_raises_without_postassertsmax_tokens=8192raisesmax_tokens_too_largeand does not POSTtest_max_tokens_8192_is_too_largeasserts the payload gate refuses 8192 and accepts 4096testsjob greenMade with Cursor