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
Scale the Patrol readiness advisor budget with the configured provider timeout
rcourtman4a516ae79bce
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.goindex a2da74afe0..2f7e2777b5 100644--- a/internal/api/ai_handlers.go+++ b/internal/api/ai_handlers.go@@ -6059,6 +6059,21 @@ func (h *AISettingsHandler) HandlePatrolPreflight(w http.ResponseWriter, r *http}}+// patrolModelReadinessBudget bounds a full advisor run: four streaming turns+// at the operator-configured provider request timeout plus slack for the two+// light management calls, floored at two minutes. A fixed envelope shorter+// than the operator's own timeout would cut slow local runtimes off mid-run+// during legitimate prompt processing.+func patrolModelReadinessBudget(cfg *config.AIConfig) time.Duration {+ budget := 2 * time.Minute+ if cfg != nil {+ if scaled := 4*cfg.GetRequestTimeout() + time.Minute; scaled > budget {+ budget = scaled+ }+ }+ return budget+}+// HandlePatrolModelReadiness runs the explicit, multi-scenario Patrol model// advisor. Unlike the startup preflight, this uses Patrol's streaming// transport, exact typed arguments, two context fixtures, and a multi-turn tool@@ -6095,10 +6110,7 @@ func (h *AISettingsHandler) HandlePatrolModelReadiness(w http.ResponseWriter, rreturn}- // An advisor run contains four streaming turns. Keep a firm total budget so- // slow local hardware cannot pin an HTTP handler indefinitely; provider-level- // request timeouts still apply inside this envelope.- ctx, cancel := context.WithTimeout(r.Context(), 2*time.Minute)+ ctx, cancel := context.WithTimeout(r.Context(), patrolModelReadinessBudget(aiService.GetConfig()))defer cancel()result := aiService.RunPatrolModelReadiness(ctx, body.Provider, body.Model)response := patrolModelReadinessSnapshot(&result, time.Now())diff --git a/internal/api/ai_handlers_test.go b/internal/api/ai_handlers_test.goindex df90718c1c..710d7eb833 100644--- a/internal/api/ai_handlers_test.go+++ b/internal/api/ai_handlers_test.go@@ -3586,6 +3586,18 @@ func TestAISettingsHandler_PatrolModelReadiness_RejectsInvalidProviderName(t *teassert.Equal(t, http.StatusBadRequest, rec.Code)}+func TestPatrolModelReadinessBudgetScalesWithRequestTimeout(t *testing.T) {+ t.Parallel()++ assert.Equal(t, 2*time.Minute, patrolModelReadinessBudget(nil))+ // A short configured timeout keeps the two-minute floor.+ assert.Equal(t, 2*time.Minute, patrolModelReadinessBudget(&config.AIConfig{RequestTimeoutSeconds: 10}))+ // Four streaming turns at the configured timeout plus slack: slow local+ // runtimes get the per-request patience the operator already granted+ // instead of being cut off by a fixed envelope (#1571).+ assert.Equal(t, 4*600*time.Second+time.Minute, patrolModelReadinessBudget(&config.AIConfig{RequestTimeoutSeconds: 600}))+}+// TestOrchestratorAndChatAdaptersMapTheSameMessageFields keeps the deliberate// GetMessages mirror between orchestratorChatAdapter (ai_handlers.go) and// chatServiceAdapter (chat_service_adapter.go) honest: both convert the same