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 Patrol subscription continuation latency
rcourtmanf6aa8db93af8
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 3a02848073..9465701f0f 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -259,7 +259,11 @@ authority but does not force an immediate text-only conclusion. Watch retainsbounded report and assessment tools so a provider that emits independentfindings sequentially can finish the remaining structured decisions withoutrestarting collection; accepted lifecycle results are authoritative and may-not be repeated. A tool-free response ends that completion phase, while the+not be repeated. That optional continuation gets one provider attempt. If it+fails after an accepted lifecycle write, Watch preserves the durable result and+returns control to the deterministic unmatched-signal evaluation pass instead+of failing the whole run or replaying the stalled continuation. A tool-free+response ends that completion phase, while theexisting max-turn fallback still produces bounded text-only summary prose whenthe final allowed turn contains a write. When a real infrastructure write doesrequire another verification turn, the internal verification constraint is@@ -451,7 +455,11 @@ provider-neutral tool loop can execute anything. The normal registry, profile, aresource, action, and verification contracts remain the only infrastructureauthority. Calls are serialized per local subscription agent and bounded bythe configured request timeout and prompt/output size limits, with a two-minute-minimum request allowance for local subscription turns. Patrol tool-call+minimum configured request allowance for local subscription turns. Because the+CLI response is buffered and cannot expose intermediate chunks, a positive+provider `StreamIdleTimeout` is an earlier complete-turn deadline for this+transport; the configured minimum must not override that caller-owned Patrol+stall budget. Patrol tool-callpreflight owns one route-aware outer deadline: API providers retain the30-second budget, while local subscription agents receive a bounded two-minutebudget for CLI startup and complete structured-output assembly, and Ollama or adiff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.goindex 4c8eef9ebd..99517069a4 100644--- a/internal/ai/chat/agentic.go+++ b/internal/ai/chat/agentic.go@@ -990,7 +990,9 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meinvestigationBudgetWarningFired := falseconsecutiveToolOnlyTurns := 0consecutiveAllErrorTurns := 0+ patrolContinuationProviderFailed := false+agenticLoop:for turn < maxTurns ||(patrolFindingRepairPending && !patrolFindingRepairAttempted) ||(patrolOutputLimitRecoveryPending && !patrolOutputLimitRecoveryAttempted) ||@@ -1361,6 +1363,13 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me}maxProviderAttempts := 2+ if patrolFindingContinuationTurn {+ // This is an optional, decision-only continuation after at least one+ // finding lifecycle write already succeeded. A deterministic unmatched-+ // signal pass follows the main loop, so replaying a stalled continuation+ // only delays that stronger recovery path and can breach Watch latency.+ maxProviderAttempts = 1+ }err := error(nil)for attempt := 1; attempt <= maxProviderAttempts; attempt++ {attemptSawDone := false@@ -1588,6 +1597,14 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meMsg("[AgenticLoop] provider.ChatStream returned")if err != nil {+ if patrolFindingContinuationTurn && patrolFindingSummaryPending {+ log.Warn().+ Err(err).+ Str("session_id", sessionID).+ Msg("[AgenticLoop] Patrol finding continuation failed after an accepted lifecycle write — deferring remaining decisions to deterministic evaluation")+ patrolContinuationProviderFailed = true+ break agenticLoop+ }log.Error().Err(err).Str("session_id", sessionID).@@ -2743,7 +2760,9 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meturn++}- log.Warn().Int("max_turns", maxTurns).Str("session_id", sessionID).Msg("agentic loop hit max turns limit")+ if !patrolContinuationProviderFailed {+ 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")}diff --git a/internal/ai/chat/agentic_additional_test.go b/internal/ai/chat/agentic_additional_test.goindex 2269e51b99..a9ef20aa3e 100644--- a/internal/ai/chat/agentic_additional_test.go+++ b/internal/ai/chat/agentic_additional_test.go@@ -1743,6 +1743,78 @@ func TestAgenticLoopAllowsSequentialIndependentWatchFindings(t *testing.T) {}}+func TestAgenticLoopDefersFailedWatchContinuationToDeterministicEvaluation(t *testing.T) {+ provider := &stubStreamingProvider{}+ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})+ executor.ApplyExecutionProfile(tools.ProfilePatrolDetection)+ creator := &repairTestPatrolFindingCreator{}+ executor.SetPatrolFindingCreator(creator)+ loop := NewAgenticLoop(provider, executor, "full Patrol prompt")+ loop.SetExecutionProfile(tools.ProfilePatrolDetection)+ loop.SetMaxTurns(3)++ reportInput := map[string]interface{}{+ "key": "container-health-failed",+ "severity": "warning",+ "category": "reliability",+ "resource_id": "app-container-api",+ "resource_name": "api",+ "resource_type": "app-container",+ "title": "API health check failing",+ "description": "The API container is running but its health check is unhealthy.",+ "recommendation": "Inspect the health endpoint and recent logs.",+ "evidence": "Provider state reports running and unhealthy with zero restarts.",+ }++ providerCalls := 0+ provider.chatStream = func(_ context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {+ providerCalls+++ switch providerCalls {+ case 1:+ call := providers.ToolCall{ID: "get-findings", Name: agentcapabilities.PatrolGetFindingsToolName, Input: map[string]interface{}{}}+ callback(providers.StreamEvent{Type: "tool_start", Data: providers.ToolStartEvent{ID: call.ID, Name: call.Name, Input: call.Input}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{call}}})+ case 2:+ call := providers.ToolCall{ID: "report-api", Name: agentcapabilities.PatrolReportFindingToolName, Input: reportInput}+ callback(providers.StreamEvent{Type: "tool_start", Data: providers.ToolStartEvent{ID: call.ID, Name: call.Name, Input: call.Input}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{call}}})+ case 3:+ if req.System != patrolFindingLifecycleContinuationSystemPrompt {+ t.Fatalf("continuation system prompt = %q", req.System)+ }+ return context.DeadlineExceeded+ case 4:+ if req.System != patrolFindingLifecycleSummarySystemPrompt || len(req.Tools) != 0 {+ t.Fatalf("fallback summary request = %+v", req)+ }+ callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "One finding was recorded; remaining signals will be evaluated."}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{}})+ default:+ t.Fatalf("unexpected provider call %d", providerCalls)+ }+ return nil+ }++ available := []providers.Tool{+ {Name: agentcapabilities.PatrolGetFindingsToolName},+ {Name: agentcapabilities.PatrolReportFindingToolName},+ {Name: agentcapabilities.PatrolAssessFindingToolName},+ }+ result, err := loop.ExecuteWithTools(context.Background(), "failed-watch-continuation", []Message{{Role: "user", Content: "check both containers"}}, available, func(StreamEvent) {})+ if err != nil {+ t.Fatalf("accepted finding should survive optional continuation failure: %v", err)+ }+ if providerCalls != 4 {+ t.Fatalf("provider calls = %d, want read, report, one continuation attempt, bounded summary", providerCalls)+ }+ if len(creator.created) != 1 || creator.created[0].ResourceID != "app-container-api" {+ t.Fatalf("created findings = %+v, want accepted API finding preserved", creator.created)+ }+ if len(result) == 0 || result[len(result)-1].Content != "One finding was recorded; remaining signals will be evaluated." {+ t.Fatalf("final result = %+v", result)+ }+}+func TestAgenticLoopSuppressesExactRepeatedAcceptedPatrolReport(t *testing.T) {provider := &stubStreamingProvider{}executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})diff --git a/internal/ai/providers/subscription_agent.go b/internal/ai/providers/subscription_agent.goindex 60eebcc48c..404cbed54e 100644--- a/internal/ai/providers/subscription_agent.go+++ b/internal/ai/providers/subscription_agent.go@@ -210,6 +210,17 @@ func (c *SubscriptionAgentClient) TestConnection(ctx context.Context) error {}func (c *SubscriptionAgentClient) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error) {+ // Subscription CLIs buffer a complete structured turn before Pulse can emit+ // the first provider event. For that transport, an inter-chunk idle budget+ // is necessarily a complete-turn idle budget. Preserve the caller's tighter+ // Patrol deadline instead of letting the client's configured (and normally+ // longer) process timeout keep a silent local agent alive.+ if req.StreamIdleTimeout > 0 {+ var cancel context.CancelFunc+ ctx, cancel = context.WithTimeout(ctx, req.StreamIdleTimeout)+ defer cancel()+ }+model := c.modelif strings.TrimSpace(req.Model) != "" {model = req.Modeldiff --git a/internal/ai/providers/subscription_agent_test.go b/internal/ai/providers/subscription_agent_test.goindex f670eb7f05..9bb019d69a 100644--- a/internal/ai/providers/subscription_agent_test.go+++ b/internal/ai/providers/subscription_agent_test.go@@ -52,6 +52,29 @@ func TestSubscriptionAgentRequestTimeout(t *testing.T) {}}+func TestSubscriptionAgentBufferedTurnHonorsStreamIdleTimeout(t *testing.T) {+ if runtime.GOOS == "windows" {+ t.Skip("fake subscription CLI uses a POSIX shell script")+ }+ binDir := t.TempDir()+ writeExecutable(t, filepath.Join(binDir, "codex"), `#!/bin/sh+sleep 2+exit 0+`)+ t.Setenv("PATH", binDir+string(os.PathListSeparator)+os.Getenv("PATH"))++ client := NewSubscriptionAgentClient(SubscriptionAgentCodex, "gpt-5.6-luna", 3*time.Minute)+ started := time.Now()+ _, err := client.Chat(context.Background(), ChatRequest{StreamIdleTimeout: 50 * time.Millisecond})+ elapsed := time.Since(started)+ if err == nil || !strings.Contains(err.Error(), "context deadline exceeded") {+ t.Fatalf("buffered turn error = %v, want stream-idle deadline", err)+ }+ if elapsed >= time.Second {+ t.Fatalf("buffered turn ignored 50ms stream-idle deadline; elapsed=%s", elapsed)+ }+}+func TestNormalizeSubscriptionAgentModel(t *testing.T) {tests := []struct {name string