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
Bound discovery AI response size
rcourtman3e09fd44935c
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex d93474c171..71649f96d1 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -90,6 +90,11 @@ runtime cost control, and shared AI transport surfaces.acceleration on activated or trial-backed installs with server-authoritativerun inventory, not a general hosted chat entitlement or a replacement forBYOK once Patrol leaves the quickstart path.+8. Keep discovery-analysis prompt bounds and response budgets aligned across+ `internal/ai/service.go` and the shared service-discovery prompt builders:+ the runtime must reserve enough output tokens for structured discovery JSON,+ and discovery prompts must cap fact/path/port fan-out explicitly instead of+ relying on providers to truncate oversized infrastructure inventories.## Current Statediff --git a/internal/ai/service.go b/internal/ai/service.goindex 5d1ab6819b..0f7632bd1d 100644--- a/internal/ai/service.go+++ b/internal/ai/service.go@@ -3520,11 +3520,13 @@ func (s *Service) AnalyzeForDiscovery(ctx context.Context, prompt string) (strinreturn "", fmt.Errorf("AI provider not configured")}+ const discoveryResponseTokenBudget = 8192+// Make the API callresp, err := provider.Chat(ctx, providers.ChatRequest{Messages: messages,Model: model,- MaxTokens: 4096, // Discovery responses need room for detailed JSON+ MaxTokens: discoveryResponseTokenBudget, // Discovery responses need room for structured JSON})// If the primary provider fails (e.g., rate limited), try other configured providers@@ -3559,7 +3561,7 @@ func (s *Service) AnalyzeForDiscovery(ctx context.Context, prompt string) (strinresp, err = altProvider.Chat(ctx, providers.ChatRequest{Messages: messages,Model: altModel,- MaxTokens: 4096,+ MaxTokens: discoveryResponseTokenBudget,})if err == nil {model = altModeldiff --git a/internal/ai/service_coverage_imp_test.go b/internal/ai/service_coverage_imp_test.goindex 6e99867962..a3869e7cbf 100644--- a/internal/ai/service_coverage_imp_test.go+++ b/internal/ai/service_coverage_imp_test.go@@ -85,6 +85,9 @@ func TestService_AnalyzeForDiscovery(t *testing.T) {// Case 3: Success with cost trackingmockProv := &mockProvider{chatFunc: func(ctx context.Context, req providers.ChatRequest) (*providers.ChatResponse, error) {+ if req.MaxTokens != 8192 {+ t.Fatalf("expected discovery max tokens 8192, got %d", req.MaxTokens)+ }return &providers.ChatResponse{Content: "Discovery Result",InputTokens: 10,diff --git a/internal/servicediscovery/service.go b/internal/servicediscovery/service.goindex 05db2edfc7..6937a4a98b 100644--- a/internal/servicediscovery/service.go+++ b/internal/servicediscovery/service.go@@ -2382,6 +2382,9 @@ Important:- List Docker containers, VMs, or other services as facts with category "service"- Include storage information (disks, pools, arrays) as facts with category "storage"- Include hardware info (CPU, RAM) as facts with category "hardware"+- Keep the response concise: include only the most important facts+- Limit output to at most 12 facts, 6 config_paths, 6 data_paths, 6 log_paths, and 12 ports+- Do not enumerate every package, service, mount, or file when a summarized representative set is enoughRespond with ONLY valid JSON.`, strings.Join(sections, "\n\n"))}@@ -2425,6 +2428,9 @@ Important:- Note any special hardware like Coral TPU, NVIDIA GPU- For LXC/VM, the CLI access should use pct exec or qm guest exec- For Docker, use docker exec+- Keep the response concise: include only the most important facts+- Limit output to at most 12 facts, 6 config_paths, 6 data_paths, 6 log_paths, and 12 ports+- Do not enumerate every package, service, mount, or file when a summarized representative set is enoughRespond with ONLY valid JSON.`, strings.Join(sections, "\n\n"))}diff --git a/internal/servicediscovery/service_test.go b/internal/servicediscovery/service_test.goindex 07c70c285e..4f6dc2b5fc 100644--- a/internal/servicediscovery/service_test.go+++ b/internal/servicediscovery/service_test.go@@ -883,6 +883,23 @@ func TestService_PromptsAndDiscoveryLoop(t *testing.T) {if !strings.Contains(deepPrompt, "(truncated)") || !strings.Contains(deepPrompt, "Metadata:") {t.Fatalf("unexpected deep prompt")}+ if !strings.Contains(deepPrompt, "Limit output to at most 12 facts") {+ t.Fatalf("expected deep prompt to limit response size")+ }++ hostPrompt := service.buildDeepAnalysisPrompt(AIAnalysisRequest{+ ResourceType: ResourceTypeAgent,+ ResourceID: "host1",+ TargetID: "host1",+ Hostname: "pve01",+ Metadata: map[string]any{"platform": "proxmox"},+ })+ if !strings.Contains(hostPrompt, "HOST OS") {+ t.Fatalf("expected host prompt variant")+ }+ if !strings.Contains(hostPrompt, "Limit output to at most 12 facts") {+ t.Fatalf("expected host prompt to limit response size")+ }ctx, cancel := context.WithCancel(context.Background())cancel()