Skip to content

Commit a041882

Browse files
committed
feat(llm-services): make the thinking budget a first-class knob
llama.cpp leaves --reasoning-budget unrestricted. A memory prompt already reaches ~15K of the served window, so an unbounded thinking trace competes with the transcript and tool results the agent still has to read. LLAMA_ARG_THINK_BUDGET joins the other server knobs: llama.cpp's own -1 in the default profile, bounded at 2000 for the Qwen text-agent profile, and surfaced in the setup summary beside flash attention and KV cache. This is the layout these settings already have — env vars written by init.py and read by compose. It existed for flash attention, KV cache type, parallel slots and the vision projector, but not for this one, which is why a node that needed it had to hand-edit its committed docker-compose.yml instead.
1 parent c1d4abc commit a041882

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎extras/llm-services/docker-compose.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ services:
3030
LLAMA_ARG_CACHE_TYPE_K: ${LLAMA_ARG_CACHE_TYPE_K:-f16}
3131
LLAMA_ARG_CACHE_TYPE_V: ${LLAMA_ARG_CACHE_TYPE_V:-f16}
3232
LLAMA_ARG_MMPROJ_AUTO: ${LLAMA_ARG_MMPROJ_AUTO:-true}
33+
# `--reasoning-budget`: -1 is llama.cpp's unrestricted default. Bound it for a
34+
# thinking model so a runaway trace cannot eat the context the caller needs.
35+
LLAMA_ARG_THINK_BUDGET: ${LLAMA_ARG_THINK_BUDGET:--1}
3336
LLAMA_ARG_HOST: "0.0.0.0"
3437
entrypoint:
3538
- /bin/sh

‎extras/llm-services/init.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"LLAMA_ARG_CACHE_TYPE_K": "f16",
8787
"LLAMA_ARG_CACHE_TYPE_V": "f16",
8888
"LLAMA_ARG_MMPROJ_AUTO": "true",
89+
"LLAMA_ARG_THINK_BUDGET": "-1",
8990
}
9091
QWEN_TEXT_SERVER_PROFILE = {
9192
**DEFAULT_SERVER_PROFILE,
@@ -96,6 +97,10 @@
9697
# `-hf` otherwise auto-downloads and loads Qwen's ~0.93GB vision projector.
9798
# Chronicle's local memory service is text-only.
9899
"LLAMA_ARG_MMPROJ_AUTO": "false",
100+
# Thinking is unrestricted by default, and a memory prompt already reaches ~15K
101+
# of the served window. Cap the trace so an unbounded one cannot crowd out the
102+
# transcript and tool results the agent still has to read.
103+
"LLAMA_ARG_THINK_BUDGET": "2000",
99104
}
100105

101106
# Embedding model options
@@ -611,6 +616,11 @@ def show_summary(self, llm_info, embed_info):
611616
f"K={self.config.get('LLAMA_ARG_CACHE_TYPE_K', 'f16')}, "
612617
f"V={self.config.get('LLAMA_ARG_CACHE_TYPE_V', 'f16')}",
613618
)
619+
think_budget = str(self.config.get("LLAMA_ARG_THINK_BUDGET", "-1"))
620+
table.add_row(
621+
"Thinking Budget",
622+
"unrestricted" if think_budget == "-1" else f"{think_budget} tokens",
623+
)
614624
table.add_row(
615625
"Vision Projector",
616626
(

‎extras/llm-services/tests/test_init.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ def test_qwen_uses_a30_text_agent_server_profile(init_module):
403403
"LLAMA_ARG_CACHE_TYPE_K": "q8_0",
404404
"LLAMA_ARG_CACHE_TYPE_V": "q8_0",
405405
"LLAMA_ARG_MMPROJ_AUTO": "false",
406+
# Bounded so a runaway thinking trace cannot crowd the served window.
407+
"LLAMA_ARG_THINK_BUDGET": "2000",
406408
}
407409

408410

@@ -420,6 +422,8 @@ def test_non_qwen_profile_restores_safe_llamacpp_defaults(init_module):
420422
"LLAMA_ARG_CACHE_TYPE_K": "f16",
421423
"LLAMA_ARG_CACHE_TYPE_V": "f16",
422424
"LLAMA_ARG_MMPROJ_AUTO": "true",
425+
# llama.cpp's own default: unrestricted.
426+
"LLAMA_ARG_THINK_BUDGET": "-1",
423427
}
424428

425429

0 commit comments

Comments
 (0)