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
Make Assistant tool selection model-owned; remove the prompt-keyword tool-scope router
rcourtman36b9b2a53d4b
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 18ec1f4f4a..54453ec3a5 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -1262,33 +1262,33 @@ deriving an older display status from `workflowStatusHistory`.surfacing failed-turn recovery, but a stalled route must not leave the userin an opaque first-token or mid-answer wait for the full provider timeout.Assistant turn tool exposure is backend-owned runtime behavior, not a- provider whim or frontend polish concern. Normal diagnostic, log, command,- repair, and governed-action prompts keep the full governed tool manifest so- the selected model owns investigation and action choice inside Pulse policy.- Direct text turns such as exact-reply diagnostics must withhold tools and- use a scoped system prompt that does not advertise unavailable tools.- Short alert and finding prompts are not direct-text turns: prompts such as- "Alerts count", "active alerts", or "findings count" must keep the full- governed manifest, including `pulse_alerts`, so the selected model can- choose the canonical Pulse alert/finding tool instead of receiving a- no-tools system prompt and asking the operator to paste context Pulse- already owns.- Inventory, count, overview, status, list, and breakdown prompts that only- need canonical Pulse resource state must expose the canonical- query/clarification path instead of shell/read/control tools, so prompts- like "how many devices in this" and "give me an inventory breakdown by node"- route toward Pulse inventory rather than `/dev` inspection. Those query-only- turns may prefetch canonical topology context before the model request,- including aggregate counts plus per-node and workload detail where available,- and then withhold tools so the first visible answer is fast and cannot drift- into shell inspection. The prefetch contract must tell the provider whether- the topology detail is complete or context-truncated, and should pass a- compact user-visible inventory payload rather than raw governed tool JSON so- policy metadata cannot cause providers to hide ordinary topology labels.- Deterministic count-only inventory prompts are a stricter case of that same- contract: when canonical topology state already carries the complete- aggregate counts, `internal/ai/chat` should answer locally by streaming- normal typed assistant content and `done` before provider attempt creation.+ provider whim or frontend polish concern, and it is model-owned at the+ manifest boundary: every interactive turn that reaches the selected model+ carries the full governed tool manifest from `toolsForExecutionMode`, and+ the model decides whether to answer directly, ask a clarification, or call+ tools inside Pulse policy. Pulse must not classify prompt wording into+ text-only or query-only tool scopes — greetings, exact-reply diagnostics,+ "no tools"/"before using tools" phrasing, inventory/count/list/breakdown+ wording, alert/finding wording, and prompt length are all model-visible+ text, not Pulse routing signals. The former `assistantToolScopeForPrompt`+ keyword router, its query-only manifest filter, its conversational/+ direct-text text-only scopes, and its query-only topology prefetch (inject+ compact inventory into the user message, then withhold tools) are removed+ and must not be reintroduced; that family withheld tools from real lookups+ ("hows esphome") and zeroed the manifest on false-positive phrases+ ("before using any tools, tell me your plan"). The only manifest-boundary+ exception is the contract-sanctioned context-only resource handoff turn+ (see Completion Obligations). `TestService_ExecuteStream_ToolManifestIsModelOwned`+ (`internal/ai/chat/service_tooling_test.go`) and+ `TestService_ExecuteStream_InventoryBreakdownIsModelOwned`+ (`internal/ai/chat/service_execute_additional_test.go`) are the regression+ proofs that previously-scoped prompt families all reach the model with the+ same governed manifest and an unmodified user message.+ Deterministic count-only inventory prompts remain the single Pulse-owned+ local answer shortcut, and it is an answer path, not tool selection: when+ canonical topology state already carries the complete aggregate counts,+ `internal/ai/chat` should answer locally by streaming normal typed+ assistant content and `done` before provider attempt creation.This adapts the referenced OpenCode `message.ts` and `processor.ts` typedpart/delta model at commit `fa2b63f850fc0a23bec2bdff9e660450d3fe7913`:locally owned text is still transcript text, but it must not wait on a@@ -1296,31 +1296,26 @@ deriving an older display status from `workflowStatusHistory`.The completion metadata for that path should identify the effective routeas `pulse:local-inventory` so the transcript label reflects Pulse-ownedlocal runtime output instead of the operator's selected remote model.- Explicit operator tool intent is the escape hatch from this shortcut, not a- Pulse-authored tool choice: prompts that ask to use tools, request a- read-only attempt, or provide a shell/read command or path such as- `ls /dev | wc -l` must keep the full governed Assistant tool manifest and- reach the selected model/provider instead of answering from local inventory.- Pulse may classify that turn as full-manifest, but the selected model still- decides whether to call `pulse_read`, answer directly, or ask a- clarification. This adapts the referenced OpenCode source at fetched+ Explicit or qualified operator intent is the escape hatch from this+ shortcut, not a Pulse-authored tool choice: prompts that ask to use tools,+ request a read-only attempt, provide a shell/read command or path such as+ `ls /dev | wc -l`, or qualify the count beyond pure inventory ("how many+ vms have errors") must reach the selected model/provider with the full+ governed Assistant tool manifest instead of answering from local+ inventory. Prompt classification+ (`assistantPromptQualifiesForLocalInventoryCount` in+ `internal/ai/chat/service.go`) may only suppress the shortcut and send the+ turn to the model — its false positives fail safe, to the model — and the+ selected model still decides whether to call `pulse_read`, answer+ directly, or ask a clarification. This adapts the referenced OpenCode+ source at fetched`origin/dev` commit `4519a1da329c1a4fc384054e7203ba7d06928205`, where`packages/core/src/session/message-updater.ts` mutates tool input, called,progress, success, and failed states as typed session events (lines247-318), by preserving the operator's explicit tool intent until Pulse canstream a visible `tool_start` / `tool_progress` / `tool_end` path instead ofcollapsing the turn into unrelated inventory prose.- The compact payload must include exact `answer_label` fields for nodes and- workloads; the provider-facing instruction must tell the model to copy those- labels exactly instead of substituting generic labels like `Node 1`, `VM- 100`, or `CT 101`. For external model routes, only this exact- Pulse-generated compact inventory context may bypass resource-label text- redaction; operator prompts, handoff text, tool payloads, raw IDs, IPs,- config, and secret-like text remain governed by the model-bound sanitizer.- The normal inventory fast-path prompt must not seed provider output with- redaction vocabulary; raw secrets, config values, IP addresses, routing- metadata, provider internals, and shell command claims remain out of scope- for normal inventory answers. The Assistant transcript should show compact+ The Assistant transcript should show compactactivity as work happens: local context reads, governed tool names, providerrouting, fallback, and first-token waiting must appear as the latestreplacing live status/header status rather than a dead-looking wait state, a@@ -1333,11 +1328,11 @@ deriving an older display status from `workflowStatusHistory`.invoking a governed tool, or waiting on a provider. Stream-idle heartbeatsmust inherit the selected provider/model route when Pulse has that route, sothe visible row reads as route-specific liveness instead of falling back to- generic Assistant waiting copy. If a query-only- turn still reaches a model-owned `pulse_query` topology call, omitting- `summary_only` must default to summary-only before execution; detailed- topology remains available in the full governed path or when the model- explicitly asks for detail. Assistant answer style should stay operational+ generic Assistant waiting copy. Pulse must not rewrite the inputs of a+ model-chosen tool call (the former summary-only `pulse_query` topology+ input default is removed with the query-only scope); `pulse_query`+ defaults are owned by the tool definition the model sees, not by+ post-hoc input mutation. Assistant answer style should stay operationaland must not use emoji, warning icons, or decorative symbols unless the userexplicitly asks for that tone.The system prompt for a turn must describe only the tools actually offered to the@@ -2383,17 +2378,21 @@ message) rather than `chat.isLoading()` so it persists for the whole turn:`isLoading` flips false at visible-turn-complete, which previously made the dockflash its status for a frame and vanish.-Prompt length must not gate tool availability. `assistantPromptLooksConversational`-(`internal/ai/chat/service.go`) classifies only explicit greeting/meta prompts-("hi", "thanks", "who are you") as conversational/text-only; it must not withhold-tools from a turn merely because the prompt is short. Short prompts are usually-resource lookups ("hows esphome", "check frigate", "grafana cpu") that need the-query/read/metrics tools to answer from Pulse data — withholding tools by word-count made the Assistant tell the user it had "no infrastructure context or-diagnostic tools" and ask them to run `docker ps` themselves, for a resource-Pulse already inventories. Tool selection stays model-owned: offer the tools and-let the model decide whether to use them, rather than pre-deciding from prompt-keywords/length that no tools are needed.+Prompt wording must not gate tool availability at all. The greeting/meta+text-only classifier (`assistantPromptLooksConversational`) is removed along+with the rest of the `assistantToolScopeForPrompt` keyword router: even "hi"+or "thanks" turns carry the full governed manifest, because tools offered is+not tools used — the model answers a greeting without calling anything, while+short prompts that look conversational to a keyword list are usually resource+lookups ("hows esphome", "check frigate", "grafana cpu") that need the+query/read/metrics tools to answer from Pulse data. Withholding tools by word+count or greeting keywords made the Assistant tell the user it had "no+infrastructure context or diagnostic tools" and ask them to run `docker ps`+themselves, for a resource Pulse already inventories. Tool selection stays+model-owned: offer the tools and let the model decide whether to use them,+rather than pre-deciding from prompt keywords/length that no tools are+needed. `TestService_ExecuteStream_ToolManifestIsModelOwned` is the+regression proof.The `pulse_query` `get` action (`executeGetResource` in`internal/ai/tools/tools_query.go`) must accept a canonical resource handlediff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.goindex deb670af11..5219690767 100644--- a/internal/ai/chat/agentic.go+++ b/internal/ai/chat/agentic.go@@ -263,25 +263,6 @@ func markToolStartMap(values map[string]bool, id, name string) {}}-func normalizeSummaryOnlyPulseQueryInput(prefer bool, name string, input map[string]interface{}) map[string]interface{} {- if !prefer || name != "pulse_query" || len(input) == 0 {- return input- }- action, _ := input["action"].(string)- if strings.ToLower(strings.TrimSpace(action)) != "topology" {- return input- }- if _, exists := input["summary_only"]; exists {- return input- }- normalized := make(map[string]interface{}, len(input)+1)- for key, value := range input {- normalized[key] = value- }- normalized["summary_only"] = true- return normalized-}-func emitToolStartEvent(callback StreamCallback, id, name string, input map[string]interface{}) {if callback == nil {return@@ -557,10 +538,6 @@ type AgenticLoop struct {// emitting a stream error event. The chat service uses this to centralize// terminal provider error presentation at the stream boundary.suppressProviderErrorEvents bool-- // Query-only count/overview turns should not let a provider accidentally- // expand a topology request into the full infrastructure tree.- preferSummaryOnlyQueries bool}// NewAgenticLoop creates a new agentic loop@@ -604,12 +581,6 @@ func (a *AgenticLoop) SetSuppressProviderErrorEvents(suppress bool) {a.suppressProviderErrorEvents = suppress}-func (a *AgenticLoop) SetPreferSummaryOnlyQueries(prefer bool) {- a.mu.Lock()- defer a.mu.Unlock()- a.preferSummaryOnlyQueries = prefer-}-// SetOrgID sets the org scope used when validating approval decisions.func (a *AgenticLoop) SetOrgID(orgID string) {a.mu.Lock()@@ -700,7 +671,6 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meproviderName := a.providerNamemodelName := a.modelNamerequestSanitizer := a.requestSanitizer- preferSummaryOnlyQueries := a.preferSummaryOnlyQueriesa.mu.Unlock()// Record telemetry for loop iteration@@ -931,7 +901,6 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meif data.Name == pulseQuestionToolName {return}- data.Input = normalizeSummaryOnlyPulseQueryInput(preferSummaryOnlyQueries, data.Name, data.Input)key := toolStartKey(data.ID, data.Name)if len(data.Input) == 0 {if key != "" && !toolStartMapHas(visibleToolStarts, data.ID, data.Name) && !toolStartMapHas(suppressedToolStarts, data.ID, data.Name) {@@ -960,7 +929,6 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meif data.Name == pulseQuestionToolName {return}- data.Input = normalizeSummaryOnlyPulseQueryInput(preferSummaryOnlyQueries, data.Name, data.Input)if toolStartMapHas(suppressedToolStarts, data.ID, data.Name) {return}@@ -996,11 +964,6 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meif data, ok := event.Data.(providers.DoneEvent); ok {attemptSawDone = truetoolCalls = data.ToolCalls- if preferSummaryOnlyQueries {- for i := range toolCalls {- toolCalls[i].Input = normalizeSummaryOnlyPulseQueryInput(true, toolCalls[i].Name, toolCalls[i].Input)- }- }a.totalInputTokens += data.InputTokensa.totalOutputTokens += data.OutputTokenslog.Info().diff --git a/internal/ai/chat/agentic_additional_test.go b/internal/ai/chat/agentic_additional_test.goindex dcdc011b88..2a9b8bcdcf 100644--- a/internal/ai/chat/agentic_additional_test.go+++ b/internal/ai/chat/agentic_additional_test.go@@ -397,29 +397,6 @@ func TestExecuteToolSafely_RecoversPanic(t *testing.T) {}}-func TestNormalizeSummaryOnlyPulseQueryInput_DefaultsTopologyForQueryOnlyTurns(t *testing.T) {- input := map[string]interface{}{"action": "topology", "include": "all"}-- got := normalizeSummaryOnlyPulseQueryInput(true, "pulse_query", input)-- if got["summary_only"] != true {- t.Fatalf("expected summary_only=true, got %#v", got)- }- if _, exists := input["summary_only"]; exists {- t.Fatalf("normalization must not mutate provider-owned input map: %#v", input)- }-}--func TestNormalizeSummaryOnlyPulseQueryInput_PreservesExplicitTopologyChoice(t *testing.T) {- input := map[string]interface{}{"action": "topology", "summary_only": false}-- got := normalizeSummaryOnlyPulseQueryInput(true, "pulse_query", input)-- if got["summary_only"] != false {- t.Fatalf("expected summary_only=false to remain explicit, got %#v", got)- }-}-func TestAgenticLoop_RetriesProviderStreamBeforeEvents(t *testing.T) {provider := &stubStreamingProvider{}executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.goindex a7501a324c..763f27fe74 100644--- a/internal/ai/chat/service.go+++ b/internal/ai/chat/service.go@@ -663,7 +663,6 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbaclen(handoffActions) > 0 ||handoffFindingID != "" ||!handoffMetadataEmpty(handoffMetadata)- assistantToolScope := assistantToolScopeForPrompt(req.Prompt, hasModelHandoffContext)// Proactively gather context for mentioned resourcess.mu.RLock()@@ -747,7 +746,7 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbac// context with its provider-safe prompt rewrite// (injectPlainTextResourceContextIntoLatestUserMessage replaces the user// message content), and the model loses the prefetched context entirely.- if assistantToolScope == assistantTurnToolScopeFull && !mentionsFound {+ if !mentionsFound {if attachPlainTextAssistantResourceContext(session.ID, messages, sessions, unifiedResourceProvider, readState, req.Prompt) {mentionsFound = true}@@ -774,11 +773,15 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbacMsg("[ChatService] Advanced FSM to READING — prefetched mentions count as resolution")}- // Run agentic loop- modelBoundaryAllowedInventoryContext := ""- if assistantToolScope == assistantTurnToolScopeQueryOnly {- emitWorkflowState(streamCallback, "context", "Reading current Pulse inventory with pulse_query.", "", "pulse_query")- if assistantPromptRequestsDeterministicInventoryCount(normalizeAssistantToolRoutingPrompt(req.Prompt)) {+ // Deterministic count-only inventory prompts answer locally from canonical+ // state (route pulse:local-inventory) before any provider attempt. This is+ // a Pulse-owned answer shortcut, not tool selection: every turn that+ // reaches the model carries the full governed manifest. The+ // needs-full-manifest check only suppresses the shortcut — its false+ // positives fail safe, to the selected model.+ if !hasModelHandoffContext {+ if assistantPromptQualifiesForLocalInventoryCount(normalizeAssistantToolRoutingPrompt(req.Prompt)) {+ emitWorkflowState(streamCallback, "context", "Reading current Pulse inventory with pulse_query.", "", "pulse_query")if answer, ok := s.directAssistantInventoryCountAnswer(ctx, baseExecutor); ok {emitWorkflowState(streamCallback, "context_ready", "Counted current Pulse inventory.", "", "pulse_query")s.streamDirectAssistantAnswer(sessions, session.ID, answer, streamCallback)@@ -788,20 +791,14 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbacreturn nil}}- if summaryContext := s.prefetchAssistantInventoryTopologyContext(ctx, baseExecutor); summaryContext != "" {- modelBoundaryAllowedInventoryContext = summaryContext- injectHandoffContextIntoLatestUserMessage(messages, summaryContext)- assistantToolScope = assistantTurnToolScopeTextOnly- emitWorkflowState(streamCallback, "context_ready", "Built compact inventory context for the model.", "", "pulse_query")- log.Debug().- Str("session_id", session.ID).- Msg("[ChatService] Prefetched canonical inventory summary for query-only Assistant turn")- }}- filteredTools := s.toolsForAssistantTurnWithScope(assistantToolScope, autonomousMode, false)+ // Run agentic loop. Tool selection is model-owned: the turn always carries+ // the full governed manifest, and the selected model decides whether to+ // answer directly, ask, or call tools. The only manifest-boundary+ // exception is the contract-sanctioned context-only resource handoff turn.+ filteredTools := s.toolsForExecutionMode(autonomousMode, false)if resourceContextTurnIsContextOnly(req.Prompt, handoffResources, handoffMetadata) {filteredTools = []providers.Tool{}- assistantToolScope = assistantTurnToolScopeTextOnlylog.Debug().Str("session_id", session.ID).Msg("[ChatService] Withholding tools for context-only resource handoff turn")@@ -859,11 +856,7 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbacloop := NewAgenticLoop(attemptProvider, executor, systemPrompt)loop.SetOrgID(s.orgID)loop.SetAutonomousMode(autonomousMode)- loop.SetPreferSummaryOnlyQueries(assistantToolScope == assistantTurnToolScopeQueryOnly)sanitizerOptions := []modelboundary.RequestSanitizerOption{}- if modelBoundaryAllowedInventoryContext != "" {- sanitizerOptions = append(sanitizerOptions, modelboundary.AllowResourcePolicyText(modelBoundaryAllowedInventoryContext))- }// Preserve the PII-free operational context injected for opted-in cloud// turns so the resource-policy sanitizer does not re-strip it as if it// were a raw identifier. FormatCloudSafeContext already excludes PII.@@ -994,49 +987,6 @@ func injectHandoffContextIntoLatestUserMessage(messages []Message, handoffContex}}-func (s *Service) prefetchAssistantInventoryTopologyContext(ctx context.Context, executor *tools.PulseToolExecutor) string {- if contextText := strings.TrimSpace(s.prefetchAssistantInventoryTopologyContextFromReadState()); contextText != "" {- return assistantInventoryTopologyContextPreamble(contextText) + "\n" +- truncateToolResultForModel(contextText)- }- if executor == nil {- return ""- }- result, err := executor.ExecuteTool(ctx, "pulse_query", map[string]interface{}{- "action": "topology",- "summary_only": false,- "max_proxmox_nodes": 0,- "max_vms_per_node": 0,- "max_containers_per_node": 0,- "max_docker_hosts": 0,- "max_docker_containers_per_host": 0,- "max_k8s_clusters": 0,- "max_k8s_nodes_per_cluster": 0,- "max_k8s_deployments_per_cluster": 0,- "max_k8s_pods_per_cluster": 0,- })- if err != nil || result.IsError {- log.Debug().- Err(err).- Bool("tool_error", result.IsError).- Msg("[ChatService] Unable to prefetch Assistant inventory summary")- return ""- }- resultText := strings.TrimSpace(FormatToolResult(result))- if resultText == "" {- return ""- }- contextText := resultText- var topology tools.TopologyResponse- if err := json.Unmarshal([]byte(resultText), &topology); err == nil {- if inventoryText, marshalErr := marshalAssistantInventoryTopologyContext(topology.NormalizeCollections()); marshalErr == nil && strings.TrimSpace(inventoryText) != "" {- contextText = inventoryText- }- }- return assistantInventoryTopologyContextPreamble(contextText) + "\n" +- truncateToolResultForModel(contextText)-}-func (s *Service) prefetchAssistantInventoryTopologyContextFromReadState() string {if s == nil || s.readState == nil {return ""@@ -1244,6 +1194,18 @@ func assistantInventoryIncludedContextTotal(context assistantInventoryTopologyCocounts.k8sPods}+type assistantInventoryTopologyCounts struct {+ proxmoxNodes int+ vms int+ systemContainers int+ dockerHosts int+ dockerContainers int+ k8sClusters int+ k8sNodes int+ k8sDeployments int+ k8sPods int+}+func assistantInventoryIncludedContextCounts(context assistantInventoryTopologyContext) assistantInventoryTopologyCounts {counts := assistantInventoryTopologyCounts{proxmoxNodes: len(context.Proxmox.Nodes),@@ -1543,60 +1505,6 @@ type assistantInventoryKubernetesPod struct {OwnerName string `json:"owner_name,omitempty"`}-func assistantInventoryTopologyContextPreamble(resultText string) string {- var lines []string- lines = append(lines,- "Pulse inventory summary from current canonical resource state, including per-node and workload detail where available.",- "Use this context to answer the user's count, overview, status, list, or inventory-breakdown question. Do not claim shell inspection or host command execution.",- "The answer_label fields are UI-visible inventory labels. Copy answer_label exactly when listing nodes, VMs, system containers, Docker containers, Kubernetes nodes, deployments, or pods.",- "Do not shorten answer_label values or substitute generic labels like Node 1, VM 100, or CT 101 when an answer_label is available.",- "Do not include raw secrets, config values, IP addresses, routing metadata, provider internals, or shell command claims in the answer.",- )-- var topology tools.TopologyResponse- if err := json.Unmarshal([]byte(resultText), &topology); err != nil {- lines = append(lines, "Completeness: The topology detail could not be counted before the model request; if the payload is marked TRUNCATED, say which details may be omitted instead of claiming every workload is listed.")- return strings.Join(lines, "\n")- }- topology = topology.NormalizeCollections()- included := assistantInventoryIncludedTopologyCounts(topology)- complete := !toolResultWouldTruncateForModel(resultText) &&- included.proxmoxNodes >= topology.Summary.TotalNodes &&- included.vms >= topology.Summary.TotalVMs &&- included.systemContainers >= topology.Summary.TotalSystemContainers &&- included.dockerHosts >= topology.Summary.TotalDockerHosts &&- included.dockerContainers >= topology.Summary.TotalDockerContainers &&- included.k8sClusters >= topology.Summary.TotalK8sClusters &&- included.k8sNodes >= topology.Summary.TotalK8sNodes &&- included.k8sDeployments >= topology.Summary.TotalK8sDeployments &&- included.k8sPods >= topology.Summary.TotalK8sPods- if complete {- lines = append(lines, "Completeness: The topology detail below includes every Proxmox node, VM, system container, Docker host/container, and Kubernetes resource currently visible in Pulse.")- } else {- lines = append(lines, fmt.Sprintf("Completeness: The topology detail below may be capped or context-truncated. Included detail counts are nodes=%d/%d, VMs=%d/%d, system_containers=%d/%d, docker_hosts=%d/%d, docker_containers=%d/%d, k8s_clusters=%d/%d, k8s_nodes=%d/%d, k8s_deployments=%d/%d, k8s_pods=%d/%d. If included counts do not match totals or a TRUNCATED marker appears, say what may be omitted instead of claiming every workload is listed.",- included.proxmoxNodes,- topology.Summary.TotalNodes,- included.vms,- topology.Summary.TotalVMs,- included.systemContainers,- topology.Summary.TotalSystemContainers,- included.dockerHosts,- topology.Summary.TotalDockerHosts,- included.dockerContainers,- topology.Summary.TotalDockerContainers,- included.k8sClusters,- topology.Summary.TotalK8sClusters,- included.k8sNodes,- topology.Summary.TotalK8sNodes,- included.k8sDeployments,- topology.Summary.TotalK8sDeployments,- included.k8sPods,- topology.Summary.TotalK8sPods,- ))- }- return strings.Join(lines, "\n")-}-func assistantInventoryNodeAnswerLabel(name string) string {name = strings.TrimSpace(name)if name == "" {@@ -1636,43 +1544,6 @@ func statusIsRunningOrOnline(status string) bool {}}-type assistantInventoryTopologyCounts struct {- proxmoxNodes int- vms int- systemContainers int- dockerHosts int- dockerContainers int- k8sClusters int- k8sNodes int- k8sDeployments int- k8sPods int-}--func assistantInventoryIncludedTopologyCounts(topology tools.TopologyResponse) assistantInventoryTopologyCounts {- counts := assistantInventoryTopologyCounts{- proxmoxNodes: len(topology.Proxmox.Nodes),- dockerHosts: len(topology.Docker.Hosts),- k8sClusters: len(topology.Kubernetes.Clusters),- }- for _, node := range topology.Proxmox.Nodes {- counts.vms += len(node.VMs)- counts.systemContainers += len(node.Containers)- }- for _, host := range topology.Docker.Hosts {- counts.dockerContainers += len(host.Containers)- }- for _, cluster := range topology.Kubernetes.Clusters {- counts.k8sNodes += len(cluster.Nodes)- counts.k8sDeployments += len(cluster.Deployments)- counts.k8sPods += len(cluster.Pods)- }- return counts-}--func toolResultWouldTruncateForModel(text string) bool {- return MaxToolResultCharsLimit > 0 && len(text) > MaxToolResultCharsLimit-}-func sanitizeHandoffContextForResourcePolicy(handoffContext string, handoffResources []HandoffResource, provider tools.UnifiedResourceProvider) string {return sanitizeTextForHandoffResourcePolicy(handoffContext, handoffResources, provider)}@@ -4133,86 +4004,15 @@ func (s *Service) toolsForExecutionMode(autonomousMode bool, patrolMode bool) []return filtered}-type assistantTurnToolScope string--const (- assistantTurnToolScopeFull assistantTurnToolScope = "full"- assistantTurnToolScopeQueryOnly assistantTurnToolScope = "query-only"- assistantTurnToolScopeTextOnly assistantTurnToolScope = "text-only"-)-const assistantLocalInventoryModelRoute = "pulse:local-inventory"-func (s *Service) toolsForAssistantTurn(prompt string, autonomousMode bool, patrolMode bool, hasModelContext bool) []providers.Tool {- scope := assistantToolScopeForPrompt(prompt, hasModelContext)- return s.toolsForAssistantTurnWithScope(scope, autonomousMode, patrolMode)-}--func (s *Service) toolsForAssistantTurnWithScope(scope assistantTurnToolScope, autonomousMode bool, patrolMode bool) []providers.Tool {- fullTools := s.toolsForExecutionMode(autonomousMode, patrolMode)- if patrolMode {- return fullTools- }-- switch scope {- case assistantTurnToolScopeTextOnly:- log.Debug().- Str("tool_scope", string(scope)).- Bool("autonomous", autonomousMode).- Msg("[toolsForAssistantTurn] Withholding tools for direct text turn")- return []providers.Tool{}- case assistantTurnToolScopeQueryOnly:- allowed := map[string]bool{"pulse_query": true}- if !autonomousMode {- allowed[pulseQuestionToolName] = true- }- filtered := filterProviderToolsByName(fullTools, allowed)- log.Debug().- Str("tool_scope", string(scope)).- Int("tool_manifest_count", len(filtered)).- Bool("autonomous", autonomousMode).- Msg("[toolsForAssistantTurn] Scoped Assistant turn to canonical query tools")- return filtered- default:- return fullTools- }-}--func filterProviderToolsByName(providerTools []providers.Tool, allowed map[string]bool) []providers.Tool {- if len(providerTools) == 0 || len(allowed) == 0 {- return []providers.Tool{}- }- filtered := make([]providers.Tool, 0, len(providerTools))- for _, tool := range providerTools {- if allowed[tool.Name] {- filtered = append(filtered, tool)- }- }- return filtered-}--func assistantToolScopeForPrompt(prompt string, hasModelContext bool) assistantTurnToolScope {- if hasModelContext {- return assistantTurnToolScopeFull- }- normalized := normalizeAssistantToolRoutingPrompt(prompt)- if normalized == "" {- return assistantTurnToolScopeTextOnly- }- if assistantPromptRequestsDirectText(normalized) || assistantPromptDisallowsToolUse(normalized) {- return assistantTurnToolScopeTextOnly- }- if assistantPromptNeedsFullToolManifest(normalized) {- return assistantTurnToolScopeFull- }- if assistantPromptIsInventoryQuery(normalized) {- return assistantTurnToolScopeQueryOnly- }- if assistantPromptLooksConversational(normalized) {- return assistantTurnToolScopeTextOnly- }- return assistantTurnToolScopeFull-}+// Tool selection is model-owned: interactive Assistant turns always carry the+// full governed manifest from toolsForExecutionMode, and the selected model+// decides whether to answer directly, ask, or call tools. The prompt+// classifiers below survive ONLY to gate the deterministic count-only+// inventory shortcut (pulse:local-inventory), which answers before any+// provider attempt — they must never be used to withhold or filter tools on a+// turn that reaches the model.func normalizeAssistantToolRoutingPrompt(prompt string) string {normalized := strings.ToLower(strings.TrimSpace(prompt))@@ -4242,39 +4042,21 @@ func normalizeAssistantToolRoutingPrompt(prompt string) string {return " " + strings.Join(strings.Fields(replacer.Replace(normalized)), " ") + " "}-func assistantPromptRequestsDirectText(normalized string) bool {- return assistantPromptContainsAny(normalized, []string{- " reply exactly ",- " respond exactly ",- " answer exactly ",- " say exactly ",- " output exactly ",- " print exactly ",- " echo exactly ",- " repeat exactly ",- " just say ",- " say only ",- " reply only ",- " respond only ",- })-}--func assistantPromptDisallowsToolUse(normalized string) bool {- return assistantPromptContainsAny(normalized, []string{- " no tools ",- " without tools ",- " without using tools ",- " do not use tools ",- " don't use tools ",- " dont use tools ",- " before using tools ",- " before using any tools ",- " before you use tools ",- " before calling tools ",- " before you call tools ",- })+// assistantPromptQualifiesForLocalInventoryCount gates the deterministic+// count-only inventory shortcut. It must stay conservative: any hint of+// intent beyond a pure inventory count (commands, logs, metrics, actions,+// explicit tool requests, qualifiers like "errors") sends the turn to the+// selected model with the full governed manifest instead.+func assistantPromptQualifiesForLocalInventoryCount(normalized string) bool {+ return !assistantPromptNeedsFullToolManifest(normalized) &&+ assistantPromptRequestsDeterministicInventoryCount(normalized)}+// assistantPromptNeedsFullToolManifest reports that a prompt carries intent+// beyond a pure inventory count (commands, logs, metrics, actions, explicit+// tool requests) and therefore must reach the selected model instead of the+// local count shortcut. A false positive here just sends the turn to the+// model with full tools — the safe direction.func assistantPromptNeedsFullToolManifest(normalized string) bool {if assistantPromptExplicitlyRequestsToolUse(normalized) || assistantPromptLooksLikeShellRead(normalized) {return true@@ -4492,31 +4274,6 @@ func assistantPromptRequestsDeterministicInventoryCount(normalized string) bool})}-func assistantPromptLooksConversational(normalized string) bool {- trimmed := strings.TrimSpace(normalized)- if trimmed == "" {- return true- }- if assistantPromptContainsAny(normalized, []string{- " hello ",- " hi ",- " hey ",- " thanks ",- " thank you ",- " who are you ",- " what can you do ",- }) {- return true- }- // Do NOT treat a prompt as conversational just because it is short. Short- // prompts are usually resource lookups ("hows esphome", "check frigate",- // "grafana cpu") that NEED tools — withholding tools by word count made the- // Assistant tell the user it had no way to inspect their infrastructure.- // Only the explicit greeting/meta patterns above are conversational; let the- // model decide whether to actually use the tools it is offered.- return false-}-func assistantPromptContainsAny(normalized string, needles []string) bool {for _, needle := range needles {if strings.Contains(normalized, needle) {diff --git a/internal/ai/chat/service_execute_additional_test.go b/internal/ai/chat/service_execute_additional_test.goindex db8ccdf4ac..4e63bfcaf1 100644--- a/internal/ai/chat/service_execute_additional_test.go+++ b/internal/ai/chat/service_execute_additional_test.go@@ -1436,7 +1436,7 @@ func TestService_ExecuteStream_InventoryCountAnswersFromCanonicalStateWithoutPro}}-func TestService_ExecuteStream_PrefetchedInventoryIncludesCompleteTopologyDetail(t *testing.T) {+func TestService_ExecuteStream_InventoryBreakdownIsModelOwned(t *testing.T) {tmpDir := t.TempDir()store, err := NewSessionStore(tmpDir)if err != nil {@@ -1530,45 +1530,27 @@ func TestService_ExecuteStream_PrefetchedInventoryIncludesCompleteTopologyDetailif err != nil {t.Fatalf("ExecuteStream failed: %v", err)}- if len(capturedReq.Tools) != 0 {- t.Fatalf("expected prefetched inventory detail turn to withhold tools, got %d", len(capturedReq.Tools))+ // Tool selection is model-owned: inventory detail/breakdown prompts reach+ // the selected model with the full governed manifest and an unmodified+ // user message. Pulse must not prefetch topology into the prompt or+ // withhold tools — the model calls pulse_query itself.+ if len(capturedReq.Tools) == 0 {+ t.Fatal("expected inventory breakdown turn to carry the full governed manifest")}if len(capturedReq.Messages) == 0 {t.Fatal("expected provider request messages")}lastMessage := capturedReq.Messages[len(capturedReq.Messages)-1].Content- for _, want := range []string{- "per-node and workload detail",- "answer_label fields are UI-visible inventory labels",- "Do not shorten answer_label values",- "includes every Proxmox node, VM, system container",- `"proxmox":{"nodes":[`,- `"nodes":[`,- `"answer_label":"Node node1"`,- `"name":"node1"`,- `"vms":[`,- `"answer_label":"VM 100 vm1"`,- `"name":"vm1"`,- `"containers":[`,- `"answer_label":"CT 201 ct1"`,- `"name":"ct1"`,- `"answer_label":"CT 213 ct13"`,- `"name":"ct13"`,- "User message: give me a detailed inventory breakdown by node",- } {- if !strings.Contains(lastMessage, want) {- t.Fatalf("expected prefetched inventory context to contain %q, got %q", want, lastMessage)- }+ if !strings.Contains(lastMessage, "give me a detailed inventory breakdown by node") {+ t.Fatalf("expected user prompt to reach the model, got %q", lastMessage)}for _, forbidden := range []string{- `"policy":`,- `"ai_safe_summary"`,- `"routing":`,- `"sensitivity":`,- `redacted`,+ "per-node and workload detail",+ `"proxmox":{"nodes":[`,+ `"answer_label":`,} {if strings.Contains(lastMessage, forbidden) {- t.Fatalf("expected prefetched inventory context to omit policy metadata %q, got %q", forbidden, lastMessage)+ t.Fatalf("expected no Pulse-injected topology prefetch in the user message, found %q in %q", forbidden, lastMessage)}}}diff --git a/internal/ai/chat/service_tooling_test.go b/internal/ai/chat/service_tooling_test.goindex dc5c7ecc90..02ca01093d 100644--- a/internal/ai/chat/service_tooling_test.go+++ b/internal/ai/chat/service_tooling_test.go@@ -3,6 +3,7 @@ package chatimport ("context""encoding/json"+ "fmt""strings""testing""time"@@ -123,202 +124,103 @@ func TestToolsForExecutionMode_InteractiveExposesGovernedTools(t *testing.T) {}}-func TestToolsForAssistantTurn_DirectTextWithholdsTools(t *testing.T) {- exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{- StateProvider: fakeStateProvider{},- AgentServer: fakeAgentServer{},- ReadState: &fakeCanonicalReadState{},- ControlLevel: tools.ControlLevelControlled,- })-- svc := &Service{executor: exec}- toolsList := svc.toolsForAssistantTurn("Reply exactly: PULSE_CHAT_OK", false, false, false)-- if len(toolsList) != 0 {- t.Fatalf("expected direct text turn to withhold tools, got %#v", toolNameSet(toolsList))- }- prompt := svc.buildSystemPromptForOfferedTools(toolsList)- if strings.Contains(prompt, "pulse_query") || strings.Contains(prompt, "pulse_read") {- t.Fatalf("expected text-only system prompt not to advertise tools, got %q", prompt)- }- if !strings.Contains(prompt, "No Pulse tools are offered for this turn") {- t.Fatalf("expected text-only system prompt to state the tool boundary, got %q", prompt)- }-}--func TestToolsForAssistantTurn_InventoryCountUsesQueryOnly(t *testing.T) {- exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{- StateProvider: fakeStateProvider{},- AgentServer: fakeAgentServer{},- ReadState: &fakeCanonicalReadState{},- ControlLevel: tools.ControlLevelControlled,- })-- svc := &Service{executor: exec}- toolsList := svc.toolsForAssistantTurn("how many devices in this", false, false, false)- set := toolNameSet(toolsList)-- if !set["pulse_query"] {- t.Fatalf("expected inventory count prompt to expose pulse_query, got %#v", set)- }- if !set[pulseQuestionToolName] {- t.Fatalf("expected interactive inventory prompt to keep clarification available, got %#v", set)- }- for _, blocked := range []string{"pulse_read", "pulse_control", "pulse_file_edit", "pulse_docker"} {- if set[blocked] {- t.Fatalf("expected inventory count prompt not to expose %s, got %#v", blocked, set)- }- }-- prompt := svc.buildSystemPromptForOfferedTools(toolsList)- if !strings.Contains(prompt, "pulse_query: mode=read") {- t.Fatalf("expected query-only system prompt to advertise pulse_query, got %q", prompt)- }- if strings.Contains(prompt, "pulse_read") || strings.Contains(prompt, "pulse_control") {- t.Fatalf("expected query-only system prompt not to advertise shell/control tools, got %q", prompt)+func TestService_ExecuteStream_ToolManifestIsModelOwned(t *testing.T) {+ // Tool selection is model-owned: every interactive turn that reaches the+ // selected model carries the same full governed manifest, regardless of+ // prompt wording. These prompts were previously keyword-scoped to+ // text-only or query-only manifests (greetings, exact-reply diagnostics,+ // "before using tools" phrasing, inventory breakdown wording, short+ // lookups) — the model now sees the same tools as diagnostic/action+ // prompts and decides for itself whether to use them.+ tmpDir := t.TempDir()+ store, err := NewSessionStore(tmpDir)+ if err != nil {+ t.Fatalf("failed to create session store: %v", err)}-}--func TestToolsForAssistantTurn_ExplicitCommandCountKeepsFullManifest(t *testing.T) {- exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{- StateProvider: fakeStateProvider{},- AgentServer: fakeAgentServer{},- ReadState: &fakeCanonicalReadState{},- ControlLevel: tools.ControlLevelControlled,- })- svc := &Service{executor: exec}- toolsList := svc.toolsForAssistantTurn("Use read-only tools only. On node delly, count entries in /dev with `ls /dev | wc -l`; answer with the number only.", false, false, false)- set := toolNameSet(toolsList)-- for _, required := range []string{"pulse_read", "pulse_query", pulseQuestionToolName} {- if !set[required] {- t.Fatalf("expected explicit command count prompt to expose %s, got %#v", required, set)- }+ var toolCounts []int+ provider := &stubServiceProvider{+ streamFn: func(ctx context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {+ toolCounts = append(toolCounts, len(req.Tools))+ callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "ok"}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{InputTokens: 1, OutputTokens: 1}})+ return nil+ },}-}-func TestToolsForAssistantTurn_InventoryBreakdownUsesQueryOnly(t *testing.T) {- exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{- StateProvider: fakeStateProvider{},- AgentServer: fakeAgentServer{},- ReadState: &fakeCanonicalReadState{},- ControlLevel: tools.ControlLevelControlled,+ service := NewService(Config{+ AIConfig: &config.AIConfig{ControlLevel: config.ControlLevelControlled},+ StateProvider: &mockStateProvider{},+ AgentServer: &mockAgentServer{},})-- svc := &Service{executor: exec}- toolsList := svc.toolsForAssistantTurn("give me a detailed inventory breakdown by node", false, false, false)- set := toolNameSet(toolsList)-- if !set["pulse_query"] {- t.Fatalf("expected inventory breakdown prompt to expose pulse_query, got %#v", set)+ service.sessions = store+ service.provider = provider+ service.started = true++ prompts := []string{+ "hi",+ "thanks",+ "Reply exactly: PULSE_CHAT_OK",+ "Before using any tools, tell me your plan.",+ "give me a detailed inventory breakdown by node",+ "hows esphome",+ "Alerts count",+ "show me the logs for vm 100",}- for _, blocked := range []string{"pulse_read", "pulse_control", "pulse_file_edit", "pulse_docker"} {- if set[blocked] {- t.Fatalf("expected inventory breakdown prompt not to expose %s, got %#v", blocked, set)+ for i, prompt := range prompts {+ if err := service.ExecuteStream(context.Background(), ExecuteRequest{+ SessionID: fmt.Sprintf("model-owned-manifest-%d", i),+ Prompt: prompt,+ }, func(StreamEvent) {}); err != nil {+ t.Fatalf("ExecuteStream(%q) failed: %v", prompt, err)}}-}--func TestToolsForAssistantTurn_ActionAndDiagnosticsKeepFullManifest(t *testing.T) {- exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{- StateProvider: fakeStateProvider{},- AgentServer: fakeAgentServer{},- ReadState: &fakeCanonicalReadState{},- ControlLevel: tools.ControlLevelControlled,- })- svc := &Service{executor: exec}- for _, prompt := range []string{- "show me the logs for vm 100",- "restart vm 100",- "diagnose high cpu on minipc",- } {- toolsList := svc.toolsForAssistantTurn(prompt, false, false, false)- set := toolNameSet(toolsList)- if !set["pulse_read"] || !set["pulse_control"] || !set["pulse_query"] {- t.Fatalf("expected full manifest for %q, got %#v", prompt, set)- }+ if len(toolCounts) != len(prompts) {+ t.Fatalf("toolCounts = %#v, want %d provider calls", toolCounts, len(prompts))}-}--func TestToolsForAssistantTurn_AlertPromptsKeepFullManifest(t *testing.T) {- exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{- StateProvider: fakeStateProvider{},- AgentServer: fakeAgentServer{},- ReadState: &fakeCanonicalReadState{},- ControlLevel: tools.ControlLevelControlled,- })-- svc := &Service{executor: exec}- for _, prompt := range []string{- "Alerts count",- "active alerts",- "findings count",- } {- toolsList := svc.toolsForAssistantTurn(prompt, false, false, false)- set := toolNameSet(toolsList)- if !set["pulse_alerts"] || !set["pulse_query"] {- t.Fatalf("expected full manifest for %q, got %#v", prompt, set)- }- promptText := svc.buildSystemPromptForOfferedTools(toolsList)- if strings.Contains(promptText, "No Pulse tools are offered for this turn") {- t.Fatalf("expected alert prompt to avoid text-only tool boundary, got %q", promptText)+ for i, count := range toolCounts {+ if count == 0 {+ t.Fatalf("prompt %q reached the model with no tools; the manifest must be model-owned", prompts[i])}- if !strings.Contains(promptText, "pulse_alerts: mode=mixed") {- t.Fatalf("expected alert prompt system prompt to advertise pulse_alerts, got %q", promptText)+ if count != toolCounts[0] {+ t.Fatalf("prompt %q got %d tools, want the same governed manifest (%d) for every turn", prompts[i], count, toolCounts[0])}}}-func TestToolsForAssistantTurn_ShortResourceLookupGetsTools(t *testing.T) {- exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{- StateProvider: fakeStateProvider{},- AgentServer: fakeAgentServer{},- ReadState: &fakeCanonicalReadState{},- ControlLevel: tools.ControlLevelControlled,- })- svc := &Service{executor: exec}-- // Short prompts that name a resource are lookups, not chit-chat. They must be- // offered tools so the Assistant can inspect the resource from Pulse data- // instead of telling the user it has no way to check.- for _, prompt := range []string{"hows esphome", "check frigate", "grafana cpu", "esphome status"} {- toolsList := svc.toolsForAssistantTurn(prompt, false, false, false)- if len(toolsList) == 0 {- t.Fatalf("short resource lookup %q was offered no tools", prompt)- }- promptText := svc.buildSystemPromptForOfferedTools(toolsList)- if strings.Contains(promptText, "No Pulse tools are offered for this turn") {- t.Fatalf("short resource lookup %q got the text-only tool boundary, got %q", prompt, promptText)- }- }-- // Explicit greetings / meta-questions remain text-only.- for _, prompt := range []string{"hi", "hello there", "thanks", "who are you"} {- toolsList := svc.toolsForAssistantTurn(prompt, false, false, false)- if len(toolsList) != 0 {- t.Fatalf("conversational prompt %q should be text-only, got %d tools", prompt, len(toolsList))+func TestAssistantPromptQualifiesForLocalInventoryCount(t *testing.T) {+ // The deterministic count-only inventory shortcut is the single surviving+ // prompt-classified path, and it only answers locally — it never decides+ // what tools the model sees. The gate must stay conservative: any hint of+ // intent beyond a pure count sends the turn to the model.+ tests := []struct {+ prompt string+ want bool+ }{+ {"how many devices in this", true},+ {"how many vms do i have", true},+ {"container count", true},+ // Qualified counts must reach the model with full tools.+ {"how many vms have errors", false},+ {"how many containers are using high cpu", false},+ // Explicit operator tool intent is the contract escape hatch.+ {"Use read-only tools only. On node delly, count entries in /dev with `ls /dev | wc -l`; answer with the number only.", false},+ // Detail/breakdown prompts are not count-only.+ {"give me a detailed inventory breakdown by node", false},+ // Not inventory counts at all.+ {"hows esphome", false},+ {"hi", false},+ {"Alerts count", false},+ }+ for _, tt := range tests {+ normalized := normalizeAssistantToolRoutingPrompt(tt.prompt)+ if got := assistantPromptQualifiesForLocalInventoryCount(normalized); got != tt.want {+ t.Fatalf("assistantPromptQualifiesForLocalInventoryCount(%q) = %v, want %v", tt.prompt, got, tt.want)}}}-func TestToolsForAssistantTurn_ModelHandoffKeepsFullManifest(t *testing.T) {- exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{- StateProvider: fakeStateProvider{},- AgentServer: fakeAgentServer{},- ReadState: &fakeCanonicalReadState{},- ControlLevel: tools.ControlLevelControlled,- })-- svc := &Service{executor: exec}- toolsList := svc.toolsForAssistantTurn("Reply exactly: PULSE_CHAT_OK", false, false, true)- set := toolNameSet(toolsList)- if !set["pulse_read"] || !set["pulse_control"] || !set["pulse_query"] {- t.Fatalf("expected model handoff turns to keep full manifest, got %#v", set)- }-}-func TestToolsForExecutionMode_AutonomousNonPatrolExposesGovernedTools(t *testing.T) {exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{StateProvider: fakeStateProvider{},