docs(reasoning): document max_tokens budgeting for reasoning models#559
Open
dparkmit24 wants to merge 1 commit into
Open
docs(reasoning): document max_tokens budgeting for reasoning models#559dparkmit24 wants to merge 1 commit into
dparkmit24 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
docs(reasoning): document max_tokens budgeting for reasoning models
Problem
Several providers now return reasoning by default with no
thinkingorreasoning_effortin the request (DeepSeek, Moonshot AI, Z.AI; current Gemini models also default to thinking). Reasoning tokens count toward the completion budget, so a modestmax_tokenscan be consumed entirely by hidden reasoning: the call returnsfinish_reason: "length"withcontentempty or nearly empty, and the request is billed for the full completion. From the response alone this reads as ordinary truncation, which makes it a confusing first-contact failure with reasoning models.I hit this building a model-comparison app on litellm.
moonshot/kimi-k2.5atmax_tokens=200returnedfinish_reason: "length",content: '', andcompletion_tokens_details.reasoning_tokens: 199of 200, billed; the identical request at a higher cap finished cleanly with 623 reasoning plus 17 visible tokens. The same pattern reproduced on Z.AI glm models and ongemini/gemini-3.5-flash(112 of 116 completion tokens consumed by reasoning at a 120 token cap). litellm itself handles all of this correctly;reasoning_contentandreasoning_tokensare surfaced cleanly, which is exactly what makes the failure detectable.The behavior is technically implied by the
max_completion_tokensdefinition on the input params page ("including visible output tokens and reasoning tokens"), and the health check page acknowledges it for probes ("providers count reasoning tokens toward the completion budget"), but the trap itself and a detection recipe are not documented anywhere user-facing.What this adds
One section on the existing reasoning content page, "Budgeting
max_tokensfor reasoning models": the mechanism, the failure signature, detection viausage.completion_tokens_details.reasoning_tokensfor non-streaming calls andstream_options={"include_usage": True}with the final-chunk usage for streams, and sizing guidance, with links to the existing Streaming Usage page, the Geminireasoning_effortmapping (including its note that thinking cannot be fully disabled on Gemini 3), and the health check reasoning defaults.Why scoped here
The reasoning content page is where users land when a reasoning model misbehaves, so the budget interaction belongs there rather than on a new page. No sidebar change. No provider page is touched; the open zai (#530) and vertex (#509) docs PRs do not overlap this change.
Verified with
npm run build(passes; the three cross-page links resolve in the built HTML).Disclosure: built with my two-agent Claude workflow: Claude Code implemented against my written spec, verified with
npm run build(Docusaurus link check) and automated review; the finding, the live reproductions, the scope decisions, and the verification standards are mine.