Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Map low reasoning effort to Ollama thinking control
rcourtman5cffa54620ab
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex c0879d2e54..9aca2ef037 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -4218,9 +4218,14 @@ receive at most 1,024, and the remaining allowance is projected on everyprovider request without aborting the final decision when prior usage runshigh. Providers with native output limits enforce `max_tokens`; local Codex andClaude subscription transports additionally receive a low reasoning-effort-control. This economy posture is detection-only. Interactive Assistant and Pro-investigation retain their normal reasoning depth and model-led diagnostic-freedom. Non-interactive tool-turn prose remains available in provider context+control. Ollama maps that same provider-neutral hint onto its native `think`+field: low effort selects the fast non-thinking path for hybrid-thinking+models, GPT-OSS receives its required named `low` level, and an absent hint+omits the field so the model keeps its own default. The brief Patrol tool-call+preflight uses low effort because it verifies protocol transport rather than+diagnostic depth. This economy posture is detection-only. Interactive+Assistant and Pro investigation retain their normal reasoning depth and+model-led diagnostic freedom. Non-interactive tool-turn prose remains available in provider contextbut is not concatenated into the persisted Patrol run analysis; the boundedterminal summary is the sole operator conclusion.diff --git a/internal/ai/patrol_preflight.go b/internal/ai/patrol_preflight.goindex 9994c711db..11bffee481 100644--- a/internal/ai/patrol_preflight.go+++ b/internal/ai/patrol_preflight.go@@ -284,7 +284,8 @@ func (s *Service) runPatrolToolPreflight(ctx context.Context, providerName, mode},},},- MaxTokens: 256,+ MaxTokens: 256,+ ReasoningEffort: providers.ReasoningEffortLow,}if parsedProvider == config.AIProviderGemini {req.ToolChoice = &providers.ToolChoice{Type: providers.ToolChoiceRequired}diff --git a/internal/ai/providers/issue1624_ollama_probe_options_test.go b/internal/ai/providers/issue1624_ollama_probe_options_test.goindex d149812ce7..8970a96a74 100644--- a/internal/ai/providers/issue1624_ollama_probe_options_test.go+++ b/internal/ai/providers/issue1624_ollama_probe_options_test.go@@ -130,6 +130,76 @@ func TestIssue1624OllamaUnpinnedZeroTemperatureStaysServerDefault(t *testing.T)}}+func TestOllamaReasoningEffortMapsToNativeThinkControl(t *testing.T) {+ tests := []struct {+ name string+ model string+ effort ReasoningEffort+ want any+ }{+ {name: "model default remains absent", model: "qwen3:8b", want: nil},+ {name: "qwen low disables thinking", model: "qwen3:8b", effort: ReasoningEffortLow, want: false},+ {name: "qwen medium retains thinking", model: "qwen3:8b", effort: ReasoningEffortMedium, want: true},+ {name: "qwen high retains thinking", model: "qwen3:8b", effort: ReasoningEffortHigh, want: true},+ {name: "gpt oss low uses named level", model: "gpt-oss:20b", effort: ReasoningEffortLow, want: "low"},+ {name: "gpt oss high uses named level", model: "gpt-oss:20b", effort: ReasoningEffortHigh, want: "high"},+ {name: "invalid hint stays absent", model: "qwen3:8b", effort: ReasoningEffort("unbounded"), want: nil},+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ if got := ollamaThinkingForRequest(tt.model, tt.effort); got != tt.want {+ t.Fatalf("ollamaThinkingForRequest(%q, %q) = %#v, want %#v", tt.model, tt.effort, got, tt.want)+ }+ })+ }+}++func TestOllamaReasoningEffortIsForwardedForChatAndStream(t *testing.T) {+ t.Run("chat", func(t *testing.T) {+ var captured []byte+ server := newCapturingOllamaServer(t,+ `{"message":{"role":"assistant","content":"ok"},"done":true,"done_reason":"stop"}`,+ &captured)+ defer server.Close()+ client, err := NewOllamaClient("qwen3:8b", server.URL, "", "", 30*time.Second)+ if err != nil {+ t.Fatalf("NewOllamaClient: %v", err)+ }+ if _, err := client.Chat(context.Background(), ChatRequest{+ Messages: []Message{{Role: "user", Content: "probe"}},+ ReasoningEffort: ReasoningEffortLow,+ }); err != nil {+ t.Fatalf("Chat: %v", err)+ }+ request := decodeCapturedOllamaRequest(t, captured)+ if got, present := request["think"]; !present || got != false {+ t.Fatalf("think = %#v (present=%v), want explicit false", got, present)+ }+ })++ t.Run("stream", func(t *testing.T) {+ var captured []byte+ server := newCapturingOllamaServer(t,+ `{"message":{"role":"assistant","content":"ok"},"done":true,"done_reason":"stop"}`+"\n",+ &captured)+ defer server.Close()+ client, err := NewOllamaClient("gpt-oss:20b", server.URL, "", "", 30*time.Second)+ if err != nil {+ t.Fatalf("NewOllamaClient: %v", err)+ }+ if err := client.ChatStream(context.Background(), ChatRequest{+ Messages: []Message{{Role: "user", Content: "probe"}},+ ReasoningEffort: ReasoningEffortLow,+ }, func(StreamEvent) {}); err != nil {+ t.Fatalf("ChatStream: %v", err)+ }+ request := decodeCapturedOllamaRequest(t, captured)+ if got := request["think"]; got != "low" {+ t.Fatalf("think = %#v, want %q", got, "low")+ }+ })+}+func TestIssue1624OllamaStreamSurfacesLengthDoneReason(t *testing.T) {var captured []byteserver := newCapturingOllamaServer(t,diff --git a/internal/ai/providers/ollama.go b/internal/ai/providers/ollama.goindex 82035f7b7e..9af1680933 100644--- a/internal/ai/providers/ollama.go+++ b/internal/ai/providers/ollama.go@@ -113,8 +113,12 @@ type ollamaRequest struct {Model string `json:"model"`Messages []ollamaMessage `json:"messages"`Stream bool `json:"stream"`- Options *ollamaOptions `json:"options,omitempty"`- Tools []ollamaTool `json:"tools,omitempty"` // Tool definitions for function calling+ // Think is separate from sampling options in Ollama's native API. Leave it+ // absent when callers do not express a reasoning-effort preference so the+ // selected model keeps its own default behavior.+ Think any `json:"think,omitempty"`+ Options *ollamaOptions `json:"options,omitempty"`+ Tools []ollamaTool `json:"tools,omitempty"` // Tool definitions for function calling// KeepAlive controls how long Ollama keeps the model loaded after the// request completes. Ollama's default is 5 minutes; without this field// every Pulse Chat call refreshes that 5-minute window, so a single@@ -126,6 +130,24 @@ type ollamaRequest struct {KeepAlive any `json:"keep_alive,omitempty"`}+// ollamaThinkingForRequest translates Pulse's provider-neutral reasoning hint+// into Ollama's native think control. For hybrid-thinking models, low effort is+// the explicit fast/non-thinking path; medium and high retain thinking. GPT-OSS+// is the exception documented by Ollama: it accepts named effort levels and+// does not support disabling thinking entirely.+func ollamaThinkingForRequest(model string, effort ReasoningEffort) any {+ if !effort.Valid() || effort == "" {+ return nil+ }+ if strings.Contains(strings.ToLower(model), "gpt-oss") {+ return string(effort)+ }+ if effort == ReasoningEffortLow {+ return false+ }+ return true+}+func ollamaKeepAliveRequestValue(value string) any {value = strings.TrimSpace(value)if value == "" {@@ -278,6 +300,7 @@ func (c *OllamaClient) Chat(ctx context.Context, req ChatRequest) (*ChatResponseModel: model,Messages: messages,Stream: false, // Non-streaming for now+ Think: ollamaThinkingForRequest(model, req.ReasoningEffort),KeepAlive: ollamaKeepAliveRequestValue(c.keepAlive),}@@ -444,6 +467,7 @@ func (c *OllamaClient) ChatStream(ctx context.Context, req ChatRequest, callbackModel: model,Messages: messages,Stream: true, // Enable streaming+ Think: ollamaThinkingForRequest(model, req.ReasoningEffort),KeepAlive: ollamaKeepAliveRequestValue(c.keepAlive),}