[GH-ISSUE #2141] [Engine] serve: thinking_budget_tokens (llama-server's name) is ignored, so llama.cpp clients get unbounded thinking #858

Closed
opened 2026-11-04 01:46:31 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @xrip on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2141

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

Strata's server ignores thinking_budget_tokens, the name llama-server also accepts for a request's thinking budget. A client written for llama-server that sends it gets no thinking budget at all, and nothing in the log or the response says so.

Expected: the same as llama-server, which reads reasoning_budget_tokens and falls back to thinking_budget_tokens (tools/server/server-common.cpp):

int reasoning_budget = json_value(body, "reasoning_budget_tokens",
                       json_value(body, "thinking_budget_tokens", -1));

Actual: Service.reasoning_budget() (serve/server.py) reads only reasoning_budget_tokens. With thinking_budget_tokens alone the thinking is unbounded: it stops only at max_tokens or at the end of the context.

Re-test on 0.2.0-beta (f57c0adc), 2026-10-19: still the case. The regression test from #2140 (serve/test_server.py::...::test_llama_cpp_thinking_budget_tokens_is_the_same_budget, the server's own stub engine) fails on 0.2.0-beta's serve/server.py. A request with thinking_budget_tokens=20 gets the whole thought back instead of a thought cut at 20 tokens with the wrap-up line. With #2140's change, the same test passes.

Impact: any client that targets llama-server's API and relies on thinking_budget_tokens. For example, the pi coding agent's llama.cpp provider (pi-llama-cpp) sends it with every request: 8,192 tokens at pi's default medium level. What it cost on my box (first seen on 0.1.43, live; 2x CMP 50HX, Qwen3.8-Flash-Next IQ3_XXS):

  • The request: pi's automatic compaction, a summary of a 109,013-token serialized history. pi caps that answer at 0.8 x reserveTokens, 26,214 tokens here.
  • What happened: the model thought until that cap and never wrote the summary. pi retried the identical request five times, about 250 s each (21 minutes), and the session was not compacted.
  • Engine log, each attempt: prompt 109013 tokens = 109008 reused + 5 read ..., 26214 generated in ~250000 ms.

Reproduce (a live server):

curl -s localhost:8080/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "m", "max_tokens": 4000, "thinking_budget_tokens": 64,
  "messages": [{"role": "user", "content": "Think step by step: how many primes are below 200?"}]}'

The reasoning_content runs far past 64 tokens. With "reasoning_budget_tokens": 64 it is wrapped up at 64.

Fix: #2140. reasoning_budget() also reads thinking_budget_tokens, and reasoning_budget_tokens wins when both are set. It comes with a test.

Reproduction status

Reproduced locally

Strata version

Strata 0.2.0-beta (f57c0adc) · engine 0.1.45.3. First seen on 0.1.43.x.

Graphics card, memory and system

2x NVIDIA CMP 50HX 20 GB · 64 GB RAM · Ubuntu 24.04.4. The bug is in serve/server.py; the 0.2.0-beta re-test is the server's unit test (Windows 11, Python 3.14) and needs no GPU.

Logs

$ python -m pytest -q serve/test_server.py -k thinking_budget_tokens_is      # 0.2.0-beta serve/server.py
>       self.assertEqual(b["choices"][0]["message"]["reasoning_content"], ThinkingEngine.THOUGHT[:20] + wrap)
E       AssertionError: 'Let me think step by step about two plus two. Let me think st[119 chars]wo. ' != 'Let me think step by\n\nI have thought about this long enough[23 chars]r.\n'
1 failed, 1 passed, 340 deselected
Originally created by @xrip on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2141 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### What happened Strata's server ignores `thinking_budget_tokens`, the name llama-server also accepts for a request's thinking budget. A client written for llama-server that sends it gets **no thinking budget at all**, and nothing in the log or the response says so. **Expected:** the same as llama-server, which reads `reasoning_budget_tokens` and falls back to `thinking_budget_tokens` (`tools/server/server-common.cpp`): ```cpp int reasoning_budget = json_value(body, "reasoning_budget_tokens", json_value(body, "thinking_budget_tokens", -1)); ``` **Actual:** `Service.reasoning_budget()` (`serve/server.py`) reads only `reasoning_budget_tokens`. With `thinking_budget_tokens` alone the thinking is unbounded: it stops only at `max_tokens` or at the end of the context. **Re-test on 0.2.0-beta (`f57c0adc`), 2026-10-19:** still the case. The regression test from #2140 (`serve/test_server.py::...::test_llama_cpp_thinking_budget_tokens_is_the_same_budget`, the server's own stub engine) fails on 0.2.0-beta's `serve/server.py`. A request with `thinking_budget_tokens=20` gets the whole thought back instead of a thought cut at 20 tokens with the wrap-up line. With #2140's change, the same test passes. **Impact:** any client that targets llama-server's API and relies on `thinking_budget_tokens`. For example, the pi coding agent's llama.cpp provider ([pi-llama-cpp](https://github.com/gsanhueza/pi-llama-cpp)) sends it with every request: 8,192 tokens at pi's default `medium` level. What it cost on my box (first seen on 0.1.43, live; 2x CMP 50HX, Qwen3.8-Flash-Next IQ3_XXS): - **The request:** pi's automatic compaction, a summary of a 109,013-token serialized history. pi caps that answer at 0.8 x `reserveTokens`, 26,214 tokens here. - **What happened:** the model thought until that cap and never wrote the summary. pi retried the identical request five times, about 250 s each (21 minutes), and the session was not compacted. - **Engine log, each attempt:** `prompt 109013 tokens = 109008 reused + 5 read ..., 26214 generated in ~250000 ms`. **Reproduce** (a live server): ```sh curl -s localhost:8080/v1/chat/completions -H 'Content-Type: application/json' -d '{ "model": "m", "max_tokens": 4000, "thinking_budget_tokens": 64, "messages": [{"role": "user", "content": "Think step by step: how many primes are below 200?"}]}' ``` The `reasoning_content` runs far past 64 tokens. With `"reasoning_budget_tokens": 64` it is wrapped up at 64. **Fix:** #2140. `reasoning_budget()` also reads `thinking_budget_tokens`, and `reasoning_budget_tokens` wins when both are set. It comes with a test. ### Reproduction status Reproduced locally ### Strata version Strata 0.2.0-beta (`f57c0adc`) · engine 0.1.45.3. First seen on 0.1.43.x. ### Graphics card, memory and system 2x NVIDIA CMP 50HX 20 GB · 64 GB RAM · Ubuntu 24.04.4. The bug is in `serve/server.py`; the 0.2.0-beta re-test is the server's unit test (Windows 11, Python 3.14) and needs no GPU. ### Logs ```text $ python -m pytest -q serve/test_server.py -k thinking_budget_tokens_is # 0.2.0-beta serve/server.py > self.assertEqual(b["choices"][0]["message"]["reasoning_content"], ThinkingEngine.THOUGHT[:20] + wrap) E AssertionError: 'Let me think step by step about two plus two. Let me think st[119 chars]wo. ' != 'Let me think step by\n\nI have thought about this long enough[23 chars]r.\n' 1 failed, 1 passed, 340 deselected ```
Author
Owner

@Niko1221 commented on GitHub (Oct 19, 2026):

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6270840727 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Author
Owner

@xrip commented on GitHub (Oct 19, 2026):

/reopen

<!-- gh-comment-id:6274674537 --> @xrip commented on GitHub (Oct 19, 2026): /reopen
Author
Owner

@github-actions[bot] commented on GitHub (Oct 19, 2026):

Reopened, thank you. A maintainer will pick it up from here.

<!-- gh-comment-id:6274677923 --> @github-actions[bot] commented on GitHub (Oct 19, 2026): Reopened, thank you. A maintainer will pick it up from here.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#858
No description provided.