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
Honor topology limits for investigations
rcourtmanaaacfcc73f33
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex bce0537d98..5ecfa03cb3 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -4521,6 +4521,16 @@ Otherwise a model can faithfully copy Pulse-provided evidence into a Patrolfinding and still mis-link that finding to a source record instead of thecanonical resource selected by the operator or scorer.+The shared `pulse_query` limit is authoritative for topology as well as list+and search. When a topology call supplies `limit` without a more precise+`max_*` bound, the executor applies that limit to each included nested+collection rather than silently reverting to its smaller default. Explicit+`max_*` values still take precedence. Every Docker host topology result exposes+both the total and returned container counts plus an explicit truncation flag,+so a model can distinguish complete topology evidence from a bounded preview+and continue with a larger bound or paginated list instead of inventing a root+cause from missing resources.+When the model runs tools but returns no final narrative, the deterministicfallback summary (`buildAutomaticFallbackSummary` in`internal/ai/chat/agentic_final.go`) must read as a clean operator message, not adiff --git a/internal/ai/tools/data_types.go b/internal/ai/tools/data_types.goindex ffb9fdf8df..88b947ef65 100644--- a/internal/ai/tools/data_types.go+++ b/internal/ai/tools/data_types.go@@ -543,6 +543,8 @@ type DockerHostTopology struct {CanExecute bool `json:"can_execute"` // True if commands can be executed on this hostContainers []DockerContainerSummary `json:"containers"`ContainerCount int `json:"container_count"`+ ReturnedCount int `json:"returned_container_count"`+ Truncated bool `json:"containers_truncated"`RunningCount int `json:"running_count"`}diff --git a/internal/ai/tools/tools_query.go b/internal/ai/tools/tools_query.goindex 561f49f04d..3bec2b20d3 100644--- a/internal/ai/tools/tools_query.go+++ b/internal/ai/tools/tools_query.go@@ -2237,7 +2237,7 @@ func (e *PulseToolExecutor) registerQueryTools() {},"limit": {Type: "integer",- Description: "Maximum number of results (default: 100)",+ Description: "Maximum number of results (default: 100). For topology, this is the fallback cap for every omitted max_* field; an explicit max_* field takes precedence.",},"offset": {Type: "integer",@@ -4467,6 +4467,8 @@ func BuildTopologyResponseFromReadState(rs unifiedresources.ReadState, options TCanExecute: hasAgent && options.ControlEnabled,Containers: containers,ContainerCount: len(hostContainers),+ ReturnedCount: len(containers),+ Truncated: len(containers) < len(hostContainers),RunningCount: runningCount,})}@@ -4679,11 +4681,34 @@ func (e *PulseToolExecutor) executeGetTopology(_ context.Context, args map[strin_, maxK8sNodesProvided := args["max_k8s_nodes_per_cluster"]_, maxK8sDeploymentsProvided := args["max_k8s_deployments_per_cluster"]_, maxK8sPodsProvided := args["max_k8s_pods_per_cluster"]+ topologyLimit := intArg(args, "limit", 0)+ _, topologyLimitProvided := args["limit"]+ if topologyLimit <= 0 {+ topologyLimitProvided = false+ }if !summaryProvided {summaryOnly = false}if !summaryOnly {+ // `limit` is the shared query bound the model naturally reaches for.+ // Honor it for topology whenever a more precise max_* bound was not+ // provided, rather than silently falling back to five nested resources.+ applySharedLimit := func(value *int, provided *bool) {+ if topologyLimitProvided && !*provided {+ *value = topologyLimit+ *provided = true+ }+ }+ applySharedLimit(&maxProxmoxNodes, &maxProxmoxNodesProvided)+ applySharedLimit(&maxVMsPerNode, &maxVMsProvided)+ applySharedLimit(&maxContainersPerNode, &maxContainersProvided)+ applySharedLimit(&maxDockerHosts, &maxDockerHostsProvided)+ applySharedLimit(&maxDockerContainersPerHost, &maxDockerContainersProvided)+ applySharedLimit(&maxK8sClusters, &maxK8sClustersProvided)+ applySharedLimit(&maxK8sNodesPerCluster, &maxK8sNodesProvided)+ applySharedLimit(&maxK8sDeploymentsPerCluster, &maxK8sDeploymentsProvided)+ applySharedLimit(&maxK8sPodsPerCluster, &maxK8sPodsProvided)if !maxProxmoxNodesProvided {maxProxmoxNodes = defaultMaxTopologyNodes}diff --git a/internal/ai/tools/tools_query_test.go b/internal/ai/tools/tools_query_test.goindex b4044d8304..b199aba296 100644--- a/internal/ai/tools/tools_query_test.go+++ b/internal/ai/tools/tools_query_test.go@@ -3,6 +3,7 @@ package toolsimport ("context""encoding/json"+ "fmt""strings""testing""time"@@ -641,6 +642,55 @@ func TestExecuteGetTopology_UsesCanonicalMaxProxmoxNodesInput(t *testing.T) {}}+func TestExecuteGetTopologyHonorsSharedLimitAndDisclosesDockerTruncation(t *testing.T) {+ containers := make([]models.DockerContainer, 8)+ for i := range containers {+ containers[i] = models.DockerContainer{+ ID: fmt.Sprintf("container-%d", i),+ Name: fmt.Sprintf("service-%d", i),+ State: "running",+ }+ }+ executor := NewPulseToolExecutor(ExecutorConfig{StateProvider: &mockStateProvider{state: models.StateSnapshot{+ DockerHosts: []models.DockerHost{{ID: "host-1", Hostname: "docker-1", Containers: containers}},+ }}})++ tests := []struct {+ name string+ args map[string]interface{}+ wantReturned int+ wantTruncated bool+ }{+ {name: "default topology remains bounded and explicit", args: map[string]interface{}{"include": "app-containers"}, wantReturned: 5, wantTruncated: true},+ {name: "shared limit expands topology", args: map[string]interface{}{"include": "app-containers", "limit": 20}, wantReturned: 8, wantTruncated: false},+ {name: "explicit docker cap takes precedence", args: map[string]interface{}{"include": "app-containers", "limit": 20, "max_docker_containers_per_host": 3}, wantReturned: 3, wantTruncated: true},+ }++ for _, tt := range tests {+ testCase := tt+ t.Run(testCase.name, func(t *testing.T) {+ result, err := executor.executeGetTopology(context.Background(), testCase.args)+ if err != nil {+ t.Fatalf("execute topology: %v", err)+ }+ var topology TopologyResponse+ if err := json.Unmarshal([]byte(result.Content[0].Text), &topology); err != nil {+ t.Fatalf("decode topology: %v", err)+ }+ if len(topology.Docker.Hosts) != 1 {+ t.Fatalf("docker hosts = %d, want 1", len(topology.Docker.Hosts))+ }+ host := topology.Docker.Hosts[0]+ if len(host.Containers) != testCase.wantReturned || host.ReturnedCount != testCase.wantReturned || host.Truncated != testCase.wantTruncated {+ t.Fatalf("topology host = %+v, want returned=%d truncated=%t", host, testCase.wantReturned, testCase.wantTruncated)+ }+ if host.ContainerCount != len(containers) {+ t.Fatalf("container_count = %d, want %d", host.ContainerCount, len(containers))+ }+ })+ }+}+func TestExecuteGetTopology_RejectsLegacyDockerIncludeAlias(t *testing.T) {executor := NewPulseToolExecutor(ExecutorConfig{})result, _ := executor.executeGetTopology(context.Background(), map[string]interface{}{