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
Require successful Patrol investigation evidence
rcourtmanb3a9edd313a2
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 779a025f17..2dfa39cbcc 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -63,13 +63,19 @@ initial proposal when evidence confirms the operational symptom; capabilityvalidation, approval floors, tenant mode, emergency stop, dispatch, andverification remain core-owned and fail closed.An investigation cannot complete or submit a typed action proposal before the-model has made at least one structured call to an advertised evidence tool.-Until then, core withholds proposal authority while leaving evidence-tool-selection model-owned. The side-effect-free action-capability lookup is planning+model has received at least one successful structured result from an advertised+evidence tool. Until then, core withholds proposal authority while leaving+evidence-tool selection model-owned. Failed, policy-blocked, loop-blocked, and+otherwise rejected calls still consume the bounded evidence-attempt budget but+cannot satisfy grounding. If that budget is exhausted without a successful+result, the run fails closed before proposal or completed-investigation+persistence. An unset attempt ceiling does not weaken that rule: reaching the+independent model-turn limit with no successful result fails closed before the+generic final-summary fallback. The side-effect-free action-capability lookup is planningmetadata, not infrastructure evidence: it neither consumes the evidence budgetnor satisfies this grounding gate. If the provider returns prose without a tool call, coremust discard that prose as a durable conclusion and allow one bounded repair-turn that requires a structured call from the same advertised evidence+turn that requires a successful structured result from the same advertised evidencemanifest. The repair is generic and carries no platform-, incident-, ormodel-specific diagnosis. A second tool-free response fails the investigationclosed instead of recording narrated or simulated tool use as completed work.@@ -7457,7 +7463,10 @@ projection, so a deployment without an agent-routed or native `pulse_read`adapter still investigates from canonical query and subsystem evidence. Atleast one structured evidence tool plus both the capability lookup and proposalsink remain mandatory; missing proposal authority or a zero-evidence manifest-fails before inference. This keeps focused Patrol+fails before inference. Runtime completion and proposal authority additionally+require at least one of those evidence calls to succeed; attempted calls remain+visible for budget accounting and forensics, but failed or blocked results are+not grounding. This keeps focused Patrolusable with smaller local models without replacing model judgment with adiagnostic script or weakening proposal, policy, approval, execution, orverification boundaries.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex ebe80a9595..13d5f1af78 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -9516,6 +9516,11 @@ investigation boundary. Investigations carry their finding `resource_type` overthe public Pulse/Enterprise orchestrator dependency contract and use the companioninvestigation projection. That projection intersects optional evidence toolswith the runtime-available governed profile, while requiring at least one-evidence tool plus the capability lookup and typed proposal sink. Both paths-are reductions after execution-profile projection; neither external clients nor-model output can select or widen the surface.+evidence tool plus the capability lookup and typed proposal sink. The bridge's+`evidence_calls` value remains attempted-call budget accounting; the core chat+runtime separately requires a successful evidence result before it exposes the+proposal sink or accepts a completed investigation. Failed and policy-blocked+calls consume budget without becoming evidence, and exhausting the budget with+no success fails the run closed. Both paths are reductions after+execution-profile projection; neither external clients nor model output can+select or widen the surface.diff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.goindex b091e3dbe2..990edb7fe0 100644--- a/internal/ai/chat/agentic.go+++ b/internal/ai/chat/agentic.go@@ -801,11 +801,12 @@ type AgenticLoop struct {modelName string// Token accumulation across all turns- totalInputTokens int- totalOutputTokens int- totalToolCalls int- totalModelTurns int- totalEvidenceCalls int+ totalInputTokens int+ totalOutputTokens int+ totalToolCalls int+ totalModelTurns int+ totalEvidenceCalls int+ successfulEvidenceCalls int// State for ongoing executionsmu sync.Mutex@@ -1208,12 +1209,17 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, metextOnlySafetyBrake = truereq.System += investigationProposalCompletedSystemPromptcase a.maxEvidenceCalls > 0 && a.totalEvidenceCalls >= a.maxEvidenceCalls:- req.Tools = investigationTerminalTools(tools)+ if a.successfulEvidenceCalls > 0 {+ req.Tools = investigationTerminalTools(tools)+ } else {+ req.Tools = nil+ }textOnlySafetyBrake = len(req.Tools) == 0req.System += investigationEvidenceBudgetExhaustedSystemPrompt- case a.totalEvidenceCalls == 0:+ case a.successfulEvidenceCalls == 0:// A proposal cannot be grounded before any evidence capability has- // actually been invoked. Keep the model free to choose the best read.+ // returned a successful result. Failed and policy-blocked attempts still+ // consume budget, but cannot unlock proposal authority.req.Tools = investigationEvidenceTools(tools)}}@@ -1719,15 +1725,18 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, mecontinue}- if isPatrolInvestigationExecution(a.currentExecutionProfile()) && a.totalEvidenceCalls == 0 {+ if isPatrolInvestigationExecution(a.currentExecutionProfile()) && a.successfulEvidenceCalls == 0 {// Prose about intended tool use is not evidence. Preserve it only in// provider context for one bounded correction turn, never as the// durable investigation conclusion.if len(resultMessages) > 0 {resultMessages[len(resultMessages)-1].Content = ""}+ if a.maxEvidenceCalls > 0 && a.totalEvidenceCalls >= a.maxEvidenceCalls {+ return resultMessages, fmt.Errorf("Patrol investigation exhausted its evidence-call budget without a successful structured evidence result")+ }if investigationEvidenceStartRepairAttempted {- return resultMessages, fmt.Errorf("Patrol investigation completed twice without a structured evidence tool call")+ return resultMessages, fmt.Errorf("Patrol investigation completed twice without a successful structured evidence result")}investigationEvidenceStartRepairPending = trueturn++@@ -2494,6 +2503,9 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meif !isError {anyToolSucceededThisTurn = true+ if isPatrolInvestigationExecution(a.currentExecutionProfile()) && isInvestigationEvidenceTool(tc.Name) {+ a.successfulEvidenceCalls+++ }if isPatrolDetectionExecution(a.currentExecutionProfile()) && tc.Name == agentcapabilities.PatrolGetFindingsToolName {patrolFindingsReadCompleted = true}@@ -2622,6 +2634,9 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meinvestigationBudgetWarningFired = true}}+ if a.totalEvidenceCalls >= a.maxEvidenceCalls && a.successfulEvidenceCalls == 0 {+ return resultMessages, fmt.Errorf("Patrol investigation exhausted its evidence-call budget without a successful structured evidence result")+ }}if patrolFindingLifecycleCompletedThisTurn < patrolFindingLifecycleCallsThisTurn {@@ -2708,6 +2723,9 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me}log.Warn().Int("max_turns", maxTurns).Str("session_id", sessionID).Msg("agentic loop hit max turns limit")+ if isPatrolInvestigationExecution(a.currentExecutionProfile()) && a.successfulEvidenceCalls == 0 {+ return resultMessages, fmt.Errorf("Patrol investigation reached its model-turn limit without a successful structured evidence result")+ }if patrolFindingSummaryPending {resultMessages = a.ensureFinalTextResponseWithSystemPrompt(ctx, sessionID, resultMessages, providerMessages, callback, patrolFindingLifecycleSummarySystemPrompt)} else {diff --git a/internal/ai/chat/agentic_additional_test.go b/internal/ai/chat/agentic_additional_test.goindex 926637a19a..56200d924e 100644--- a/internal/ai/chat/agentic_additional_test.go+++ b/internal/ai/chat/agentic_additional_test.go@@ -157,7 +157,7 @@ func TestAgenticLoopPatrolInvestigationRepairsToolFreeStart(t *testing.T) {callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "I will now call a made-up tool in prose."}})callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{}})case 2:- callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{ID: "evidence", Name: agentcapabilities.PulseQueryToolName, Input: map[string]interface{}{"query": "containers"}}}}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{ID: "evidence", Name: agentcapabilities.PulseQueryToolName, Input: map[string]interface{}{"action": "search", "query": "containers"}}}}})default:callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "grounded conclusion"}})callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{}})@@ -165,7 +165,7 @@ func TestAgenticLoopPatrolInvestigationRepairsToolFreeStart(t *testing.T) {return nil}- executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})+ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{StateProvider: &mockStateProvider{}})executor.ApplyExecutionProfile(tools.ProfilePatrolInvestigation)loop := NewAgenticLoop(provider, executor, "system")loop.SetExecutionProfile(tools.ProfilePatrolInvestigation)@@ -226,7 +226,7 @@ func TestAgenticLoopPatrolInvestigationFailsClosedAfterToolFreeRepair(t *testingloop.SetMaxTurns(1)result, err := loop.ExecuteWithTools(context.Background(), "grounding-fail-closed", []Message{{Role: "user", Content: "investigate"}}, []providers.Tool{{Name: agentcapabilities.PulseQueryToolName}}, func(StreamEvent) {})- if err == nil || !strings.Contains(err.Error(), "completed twice without a structured evidence tool call") {+ if err == nil || !strings.Contains(err.Error(), "completed twice without a successful structured evidence result") {t.Fatalf("ExecuteWithTools error = %v, want fail-closed grounding error", err)}if len(requests) != 2 {@@ -253,7 +253,7 @@ func TestAgenticLoopPatrolInvestigationRejectsUnadvertisedToolBeforeFSM(t *testicase 1:callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{ID: "invented", Name: "container_state", Input: map[string]interface{}{"resource_id": "container-1"}}}}})case 2:- callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{ID: "evidence", Name: agentcapabilities.PulseQueryToolName, Input: map[string]interface{}{"query": "containers"}}}}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{ID: "evidence", Name: agentcapabilities.PulseQueryToolName, Input: map[string]interface{}{"action": "search", "query": "containers"}}}}})default:callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "grounded conclusion"}})callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{}})@@ -261,7 +261,7 @@ func TestAgenticLoopPatrolInvestigationRejectsUnadvertisedToolBeforeFSM(t *testireturn nil}- executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})+ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{StateProvider: &mockStateProvider{}})executor.ApplyExecutionProfile(tools.ProfilePatrolInvestigation)loop := NewAgenticLoop(provider, executor, "system")loop.SetExecutionProfile(tools.ProfilePatrolInvestigation)@@ -310,7 +310,7 @@ func TestAgenticLoopPatrolInvestigationEnforcesEvidenceBudget(t *testing.T) {turn++switch turn {case 1:- callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{ID: "evidence-1", Name: agentcapabilities.PulseQueryToolName, Input: map[string]interface{}{"query": "containers"}}}}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{ID: "evidence-1", Name: agentcapabilities.PulseQueryToolName, Input: map[string]interface{}{"action": "search", "query": "containers"}}}}})case 2:callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{ID: "evidence-2", Name: agentcapabilities.PulseReadToolName, Input: map[string]interface{}{"operation": "resource"}}}}})default:@@ -320,7 +320,7 @@ func TestAgenticLoopPatrolInvestigationEnforcesEvidenceBudget(t *testing.T) {return nil}- executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})+ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{StateProvider: &mockStateProvider{}})executor.ApplyExecutionProfile(tools.ProfilePatrolInvestigation)loop := NewAgenticLoop(provider, executor, "system")loop.SetExecutionProfile(tools.ProfilePatrolInvestigation)@@ -359,6 +359,139 @@ func TestAgenticLoopPatrolInvestigationEnforcesEvidenceBudget(t *testing.T) {}}+func TestAgenticLoopPatrolInvestigationFailedEvidenceDoesNotUnlockProposal(t *testing.T) {+ provider := &stubStreamingProvider{}+ var requests []providers.ChatRequest+ turn := 0+ provider.chatStream = func(_ context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {+ requests = append(requests, req)+ turn+++ switch turn {+ case 1:+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{+ ID: "failed-evidence", Name: agentcapabilities.PulseQueryToolName,+ Input: map[string]interface{}{"action": "unsupported"},+ }}}})+ case 2:+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{+ ID: "successful-evidence", Name: agentcapabilities.PulseQueryToolName,+ Input: map[string]interface{}{"action": "search", "query": "containers"},+ }}}})+ default:+ callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "grounded conclusion"}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{}})+ }+ return nil+ }++ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{StateProvider: &mockStateProvider{}})+ executor.ApplyExecutionProfile(tools.ProfilePatrolInvestigation)+ loop := NewAgenticLoop(provider, executor, "system")+ loop.SetExecutionProfile(tools.ProfilePatrolInvestigation)+ loop.SetMaxEvidenceCalls(3)+ loop.SetMaxTurns(4)++ available := []providers.Tool{+ {Name: agentcapabilities.PulseQueryToolName},+ {Name: agentcapabilities.PatrolProposeActionToolName},+ }+ result, err := loop.ExecuteWithTools(context.Background(), "failed-evidence-repair", []Message{{Role: "user", Content: "investigate"}}, available, func(StreamEvent) {})+ if err != nil {+ t.Fatalf("ExecuteWithTools: %v", err)+ }+ if len(requests) != 3 {+ t.Fatalf("provider requests = %d, want 3", len(requests))+ }+ for _, requestIndex := range []int{0, 1} {+ if names := advertisedProviderToolNames(requests[requestIndex].Tools); len(names) != 1 || names[0] != agentcapabilities.PulseQueryToolName {+ t.Fatalf("request %d tools = %v, want evidence only", requestIndex, names)+ }+ }+ if !providerToolIsAdvertised(requests[2].Tools, agentcapabilities.PatrolProposeActionToolName) {+ t.Fatalf("successful evidence did not unlock proposal authority: %+v", requests[2].Tools)+ }+ if loop.GetTotalEvidenceCalls() != 2 || loop.successfulEvidenceCalls != 1 {+ t.Fatalf("evidence attempts=%d successes=%d, want 2/1", loop.GetTotalEvidenceCalls(), loop.successfulEvidenceCalls)+ }+ if len(result) == 0 || result[len(result)-1].Content != "grounded conclusion" {+ t.Fatalf("result = %+v, want grounded conclusion", result)+ }+}++func TestAgenticLoopPatrolInvestigationFailsClosedWhenEvidenceBudgetHasNoSuccess(t *testing.T) {+ provider := &stubStreamingProvider{}+ providerCalls := 0+ provider.chatStream = func(_ context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {+ providerCalls+++ if providerToolIsAdvertised(req.Tools, agentcapabilities.PatrolProposeActionToolName) {+ t.Fatalf("proposal authority exposed before successful evidence: %+v", req.Tools)+ }+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{+ ID: "failed-evidence", Name: agentcapabilities.PulseQueryToolName,+ Input: map[string]interface{}{"action": "unsupported"},+ }}}})+ return nil+ }++ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{StateProvider: &mockStateProvider{}})+ executor.ApplyExecutionProfile(tools.ProfilePatrolInvestigation)+ loop := NewAgenticLoop(provider, executor, "system")+ loop.SetExecutionProfile(tools.ProfilePatrolInvestigation)+ loop.SetMaxEvidenceCalls(1)+ loop.SetMaxTurns(3)++ result, err := loop.ExecuteWithTools(+ context.Background(),+ "failed-evidence-budget",+ []Message{{Role: "user", Content: "investigate"}},+ []providers.Tool{{Name: agentcapabilities.PulseQueryToolName}, {Name: agentcapabilities.PatrolProposeActionToolName}},+ func(StreamEvent) {},+ )+ if err == nil || !strings.Contains(err.Error(), "exhausted its evidence-call budget without a successful structured evidence result") {+ t.Fatalf("ExecuteWithTools error = %v, want failed-grounding budget error", err)+ }+ if providerCalls != 1 {+ t.Fatalf("provider calls = %d, want fail closed immediately after exhausted attempt", providerCalls)+ }+ if loop.GetTotalEvidenceCalls() != 1 || loop.successfulEvidenceCalls != 0 {+ t.Fatalf("evidence attempts=%d successes=%d, want 1/0", loop.GetTotalEvidenceCalls(), loop.successfulEvidenceCalls)+ }+ if len(result) == 0 || result[len(result)-1].ToolResult == nil || !result[len(result)-1].ToolResult.IsError {+ t.Fatalf("failed evidence result was not preserved: %+v", result)+ }+}++func TestAgenticLoopPatrolInvestigationTurnLimitCannotBypassSuccessfulEvidence(t *testing.T) {+ provider := &stubStreamingProvider{}+ provider.chatStream = func(_ context.Context, _ providers.ChatRequest, callback providers.StreamCallback) error {+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{+ ID: "failed-evidence", Name: agentcapabilities.PulseQueryToolName,+ Input: map[string]interface{}{"action": "unsupported"},+ }}}})+ return nil+ }++ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{StateProvider: &mockStateProvider{}})+ executor.ApplyExecutionProfile(tools.ProfilePatrolInvestigation)+ loop := NewAgenticLoop(provider, executor, "system")+ loop.SetExecutionProfile(tools.ProfilePatrolInvestigation)+ loop.SetMaxTurns(1)++ result, err := loop.ExecuteWithTools(+ context.Background(),+ "failed-evidence-turn-limit",+ []Message{{Role: "user", Content: "investigate"}},+ []providers.Tool{{Name: agentcapabilities.PulseQueryToolName}},+ func(StreamEvent) {},+ )+ if err == nil || !strings.Contains(err.Error(), "reached its model-turn limit without a successful structured evidence result") {+ t.Fatalf("ExecuteWithTools error = %v, want failed-grounding turn-limit error", err)+ }+ if len(result) == 0 || result[len(result)-1].ToolResult == nil || !result[len(result)-1].ToolResult.IsError {+ t.Fatalf("failed evidence result was not preserved: %+v", result)+ }+}+func TestIsPatrolFindingLifecycleWrite(t *testing.T) {for _, toolName := range []string{agentcapabilities.PatrolReportFindingToolName,@@ -2302,6 +2435,7 @@ func TestAgenticLoop_RecoversTruncatedInvestigationConclusionFromExistingEvidencloop.SetExecutionProfile(tools.ProfilePatrolInvestigation)loop.SetMaxTurns(1)loop.totalEvidenceCalls = 1+ loop.successfulEvidenceCalls = 1providerCalls := 0var recoveryRequest providers.ChatRequestdiff --git a/internal/ai/chat/agentic_control.go b/internal/ai/chat/agentic_control.goindex 98c209d314..abbdd3cb9c 100644--- a/internal/ai/chat/agentic_control.go+++ b/internal/ai/chat/agentic_control.go@@ -192,8 +192,9 @@ func (a *AgenticLoop) GetTotalModelTurns() int {return a.totalModelTurns}-// GetTotalEvidenceCalls returns model-selected Patrol investigation calls-// other than the terminal typed action proposal.+// GetTotalEvidenceCalls returns attempted model-selected Patrol investigation+// evidence calls. Failed and policy-blocked calls consume this budget but do+// not satisfy the separate successful-evidence grounding gate.func (a *AgenticLoop) GetTotalEvidenceCalls() int {return a.totalEvidenceCalls}diff --git a/internal/ai/chat/agentic_investigation_budget.go b/internal/ai/chat/agentic_investigation_budget.goindex 2479375100..57eb7edf92 100644--- a/internal/ai/chat/agentic_investigation_budget.go+++ b/internal/ai/chat/agentic_investigation_budget.go@@ -20,7 +20,7 @@ INVESTIGATION COMPLETION: A typed action proposal has already been accepted forconst investigationEvidenceStartRepairSystemPrompt = `-INVESTIGATION GROUNDING: Pulse cannot accept a completed investigation until you make at least one structured call to an advertised evidence tool. Choose the most relevant available tool and arguments from the exact finding and resource identity already supplied. Call the tool now through the structured tool interface. Do not narrate, simulate, or place a hypothetical tool call in prose.`+INVESTIGATION GROUNDING: Pulse cannot accept a completed investigation until at least one structured call to an advertised evidence tool succeeds. Choose the most relevant available tool and arguments from the exact finding and resource identity already supplied. Call the tool now through the structured tool interface. Do not narrate, simulate, or place a hypothetical tool call in prose. A failed or policy-blocked call is not evidence.`const investigationEvidenceBudgetExhaustedSystemPrompt = `diff --git a/internal/ai/chat/service_tooling_test.go b/internal/ai/chat/service_tooling_test.goindex 073be2f615..a0d4830725 100644--- a/internal/ai/chat/service_tooling_test.go+++ b/internal/ai/chat/service_tooling_test.go@@ -1208,6 +1208,7 @@ func TestInvestigationLoopRedactsProposalParamsEverywhereDurable(t *testing.T) {loop := NewAgenticLoop(provider, exec, "base prompt")loop.SetExecutionProfile(tools.ProfilePatrolInvestigation)loop.totalEvidenceCalls = 1+ loop.successfulEvidenceCalls = 1var streamedRawParam boolmessages, err := loop.ExecuteWithTools(