From 383f12bab51bff6796f867f234ddc93e9a75def7 Mon Sep 17 00:00:00 2001 From: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Date: Sat, 19 Sep 2026 15:19:18 -0700 Subject: [PATCH] Allow llama.cpp --reasoning flag in runtime flag allowlist Motivation: llama.cpp's llama-server exposes a --reasoning [on|off|auto] flag that toggles reasoning/thinking mode in the chat template, but Docker Model Runner rejects it because it is missing from LlamaCppAllowedFlags. The map already allows the related --reasoning-format and --reasoning-budget flags. Without --reasoning, the only way to pin a hybrid thinking model non-thinking is --chat-template-kwargs '{"enable_thinking": false}', which current llama.cpp builds flag as deprecated in favor of --reasoning on / --reasoning off. Approach: Add "--reasoning" to the LlamaCppAllowedFlags map in pkg/inference/runtime_flags_allowlist.go, following the same enum-flag pattern already used for --pooling and --reasoning-format (no argument value is validated beyond the existing path-safety and flag-injection checks, which apply uniformly to all allowed flags). Added a "reasoning" category to the table-driven allowlist category test and a new scenario case in the runtime flag validation test. Validation: - go build ./pkg/inference/... - go vet ./pkg/inference/... - gofmt -l on the changed files (no output) - golangci-lint run ./pkg/inference/... (0 issues) - go test ./pkg/inference/... and go test -race ./pkg/inference/... (all pass) - Confirmed the new test is a genuine regression test: with only the allowlist map entry reverted, the new "llama.cpp: reasoning flag allowed" case fails with `runtime flag "--reasoning" is not allowed for backend "llama.cpp"`; restoring the entry makes it pass. Report: https://github.com/docker/model-runner/issues/1064 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-sonnet-5 (via Claude Code) --- pkg/inference/runtime_flags_allowlist.go | 1 + pkg/inference/runtime_flags_allowlist_test.go | 3 +++ pkg/inference/runtime_flags_test.go | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/pkg/inference/runtime_flags_allowlist.go b/pkg/inference/runtime_flags_allowlist.go index 7b3d7d3a8..e92dc63c5 100644 --- a/pkg/inference/runtime_flags_allowlist.go +++ b/pkg/inference/runtime_flags_allowlist.go @@ -171,6 +171,7 @@ var LlamaCppAllowedFlags = map[string]bool{ "--chat-template-kwargs": true, "--jinja": true, "--no-jinja": true, "--pooling": true, + "--reasoning": true, "--reasoning-format": true, "--reasoning-budget": true, "--prefill-assistant": true, diff --git a/pkg/inference/runtime_flags_allowlist_test.go b/pkg/inference/runtime_flags_allowlist_test.go index a73ec3890..3e22f3e92 100644 --- a/pkg/inference/runtime_flags_allowlist_test.go +++ b/pkg/inference/runtime_flags_allowlist_test.go @@ -161,6 +161,9 @@ func TestLlamaCppAllowedFlags_Categories(t *testing.T) { "--embeddings", "--embedding", "--reranking", "--rerank", "--metrics", "--no-metrics", "--jinja", "--no-jinja", }, + "reasoning": { + "--reasoning", "--reasoning-format", "--reasoning-budget", + }, "speculative": { "--spec-draft-n-max", "--draft-n-max", "--draft-max", "--spec-draft-n-min", "--draft-n-min", "--draft-min", "--spec-draft-p-min", "--draft-p-min", diff --git a/pkg/inference/runtime_flags_test.go b/pkg/inference/runtime_flags_test.go index 78fb84a39..d0fce6b4a 100644 --- a/pkg/inference/runtime_flags_test.go +++ b/pkg/inference/runtime_flags_test.go @@ -91,6 +91,13 @@ func TestValidateRuntimeFlags(t *testing.T) { expectError: false, description: "Sampling flags should be allowed", }, + { + name: "llama.cpp: reasoning flag allowed", + backend: "llama.cpp", + flags: []string{"--reasoning", "off"}, + expectError: false, + description: "Reasoning flag should be allowed", + }, { name: "llama.cpp: real-world flags from issue 515", backend: "llama.cpp",