Skip to content

fix: server handling of budget and reasoning params#23673

Open
thiswillbeyourgithub wants to merge 6 commits into
ggml-org:masterfrom
thiswillbeyourgithub:fix-server-reasoning-handling
Open

fix: server handling of budget and reasoning params#23673
thiswillbeyourgithub wants to merge 6 commits into
ggml-org:masterfrom
thiswillbeyourgithub:fix-server-reasoning-handling

Conversation

@thiswillbeyourgithub

@thiswillbeyourgithub thiswillbeyourgithub commented May 25, 2026

Copy link
Copy Markdown

Overview

When bumping into walls for using budget tokens argument in wllama I found out that I had had bugs like this in the past months ago when trying to use Qwen3 or 3.5 models without reasoning. At the time I couldn't make sense of how to invoke the reasoning budget arguments. Turns out that it was a llamacpp issue: IMO the server doc is quite confusing about the distinction between reasoning-budget and thinking_budget. This PR clarifies it with an admin-wins-when-set rule:

  • if --reasoning-budget-message was supplied at startup, that value is always used but the chat endpoint still accepts thinking_budget_message from the request body.
  • if both values are set: the CLI value is a hard ceiling and the request value is now only able to lower it.
    This PR also fix the issue where if the user launching the server set a reasoning-budget value then thinking_budget_tokens couldn't be used.
    Lastly, thinking_budget_message at request time was not honoured.

While doing this, I also noticed that the doc of the reasoning-format mentioned its default as "auto" but was actually "COMMON_REASONING_FORMAT_DEEPSEEK" so I put it back to "COMMON_REASONING_FORMAT_AUTO".

Additional information

This is related to this PR on wllama

Possibly related to:

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES. Claude Code was used extensively to use wllama and improve it as I'm a python dev and am not familiar with lower level languages I had to use it, including when I found this long standing issue in llamacpp's server.

Comment thread common/common.h Outdated
Comment thread tools/server/README.md Outdated
@thiswillbeyourgithub thiswillbeyourgithub marked this pull request as ready for review May 26, 2026 13:46
@thiswillbeyourgithub thiswillbeyourgithub requested review from a team as code owners May 26, 2026 13:46

@0cc4m 0cc4m left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the behaviour for server-set thinking budget to be an upper limit is a good change.

Comment thread tools/server/server-common.cpp Outdated
@allozaur

Copy link
Copy Markdown
Contributor

Self note - related to #23434

@0cc4m

0cc4m commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Please rebase to resolve the conflicts.

thiswillbeyourgithub and others added 5 commits June 6, 2026 09:46
The `common_params` default was `COMMON_REASONING_FORMAT_DEEPSEEK` while the
CLI help text, README, and the enum's own "in most cases, use AUTO" comment
all said the default was `auto`. Switch the default to `AUTO` so the docs
match the behavior, and list `auto` explicitly in the option enumeration in
both the CLI help and the server README (it was a valid input but missing
from the listed values).
…oint

The chat endpoint previously ignored `thinking_budget_tokens` in the request
body whenever `--reasoning-budget` had been set, and accepted it without any
cap when the CLI was at the default. Both behaviors are wrong: an admin needs
the CLI flag to act as an upper bound that clients cannot escape (so
`--reasoning-budget 0` reliably forbids thinking), and a client should still
be able to lower the budget for an individual request.

Treat the CLI value as a permission ceiling: the body field may lower it but
never raise it, with -1 meaning unrestricted on both sides. Document the
behavior in both the CLI flag entry and the chat-completions body field, and
point users at the raw `/completion` field names since that endpoint has no
Jinja template to introspect for thinking tags.
…et one

The budget exhaustion message is a quality knob (it primes the model with a
graceful "wrap it up" phrase before the end-of-thinking tag, leading to
better final answers than an abrupt cut) rather than a policy lever, so the
ceiling rule used for the numeric budget doesn't translate. Use a simpler
"admin-wins-when-set" rule instead: if `--reasoning-budget-message` was
supplied at startup, that value is always respected; otherwise the chat
endpoint accepts `thinking_budget_message` from the request body and uses
it. Document the rule in the CLI flag entry and the body-field paragraph.
Per code review feedback, keep COMMON_REASONING_FORMAT_DEEPSEEK as the default
and instead align the CLI help to say `(default: deepseek)`. Also revert all
edits inside the auto-generated `<\!-- HELP_START --> ... <\!-- HELP_END -->`
block in tools/server/README.md, which is produced by llama-gen-docs and must
not be hand-edited; only the hand-written API-parameters prose outside that
block stays.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thiswillbeyourgithub thiswillbeyourgithub force-pushed the fix-server-reasoning-handling branch from aabc7a9 to 7624f40 Compare June 6, 2026 09:52
Comment thread tools/server/server-common.cpp

@aldehir aldehir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if both values are set: the CLI value is a hard ceiling and the request value is now only able to lower it.

I don't really view reasoning as some sort of resource that necessitates a hard constraint. I suspect users will open issues claiming they can't use the request provided parameter as an escape hatch for their default setting.

That said, I don't care enough.

…recedence

Upstream PR ggml-org#24517 (ggerganov) made the per-request thinking_budget_tokens
take precedence over the CLI / model.ini --reasoning-budget default, with
the CLI value as a fallback. That is the opposite of this branch's earlier
hard-ceiling behaviour, so this resolution drops the ceiling clamp and
adopts the upstream precedence for the budget value itself.

The additive per-request thinking_budget_message fallback from this branch
is kept: it does not touch the precedence change. The block comment is
updated to describe the new precedence instead of the removed ceiling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thiswillbeyourgithub

Copy link
Copy Markdown
Author

I don't really view reasoning as some sort of resource that necessitates a hard constraint.

My reasoning was that setting a very high reasoning budget and asking the model to think deeply about whatever sounds a bit DDOS-y. But admins worried about that should just set the max_tokens anyways so it's not really real.

I looked at #24517 that went the opposite direction so I resolved the conflict by following ggerganov's need (not capping the budget over the query).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants