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
Keep live Patrol context aligned with readiness
rcourtman12aa31b5066a
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 827e89e769..1561427583 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -7464,3 +7464,17 @@ root cause, discloses failed tool-call count without treating failures asevidence, and describes a successful typed proposal only as a governedproposal. It never dumps raw tool output, infers execution, or upgrades thefinding to resolved. A failed proposal remains absent from the receipt.++### Live Patrol uses the context envelope it certifies++Every Watch and Patrol investigation provider request, including bounded+recovery and final-summary turns, carries a provider-neutral minimum context+request of 16,384 tokens. Providers without a runtime context control ignore+the hint; Ollama projects it to native `num_ctx`. The Patrol model-readiness+probe imports this same core-owned value rather than maintaining a second+qualification-only constant. A model must therefore be exercised and run with+the same minimum context envelope: Pulse must never certify tool use with a+large probe context and then silently truncate live infrastructure context or+governed tool schemas at Ollama's smaller server default. Output-token and+reasoning allowances remain separately bounded and do not expand mutation+authority.diff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.goindex c2210b9d49..b091e3dbe2 100644--- a/internal/ai/chat/agentic.go+++ b/internal/ai/chat/agentic.go@@ -1221,6 +1221,7 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meif patrolOutputLimitRecoveryTurn {applyPatrolOutputLimitRecoveryAllowance(&req, a.totalOutputTokens)}+ applyExecutionRuntimeEnvelope(&req, a.currentExecutionProfile())// Pre-request context validation: catch overflow from message history growth.// Phase 2 handles first-turn overflow via seed budget; this catchesdiff --git a/internal/ai/chat/agentic_additional_test.go b/internal/ai/chat/agentic_additional_test.goindex d0238ce9e7..64e48b223d 100644--- a/internal/ai/chat/agentic_additional_test.go+++ b/internal/ai/chat/agentic_additional_test.go@@ -180,6 +180,11 @@ func TestAgenticLoopPatrolInvestigationRepairsToolFreeStart(t *testing.T) {if len(requests) != 3 {t.Fatalf("provider requests = %d, want 3", len(requests))}+ for i, req := range requests {+ if req.MinContextTokens != PatrolProviderMinContextTokens {+ t.Fatalf("request %d MinContextTokens = %d, want %d", i, req.MinContextTokens, PatrolProviderMinContextTokens)+ }+ }for _, requestIndex := range []int{0, 1} {for _, tool := range requests[requestIndex].Tools {if tool.Name == agentcapabilities.PatrolProposeActionToolName {diff --git a/internal/ai/chat/agentic_control.go b/internal/ai/chat/agentic_control.goindex 83544da8eb..98c209d314 100644--- a/internal/ai/chat/agentic_control.go+++ b/internal/ai/chat/agentic_control.go@@ -14,8 +14,23 @@ const (patrolDetectionRecoveryAllowance = 4_096patrolDetectionSummaryAllowance = 1_024patrolDetectionMinimumAllowance = 512++ // PatrolProviderMinContextTokens is the minimum runtime context requested+ // for every Watch and investigation model turn. The readiness probe uses+ // the same value: certifying a model with a larger Ollama num_ctx than the+ // live loop would silently truncate the production prompt and tool schemas.+ PatrolProviderMinContextTokens = 16_384)+func applyExecutionRuntimeEnvelope(req *providers.ChatRequest, profile tools.ExecutionProfile) {+ if req == nil {+ return+ }+ if profile == tools.ProfilePatrolDetection || profile == tools.ProfilePatrolInvestigation {+ req.MinContextTokens = PatrolProviderMinContextTokens+ }+}+func applyExecutionInferenceAllowance(req *providers.ChatRequest, profile tools.ExecutionProfile, summaryOnly bool, outputTokensUsed int) {if req == nil || profile != tools.ProfilePatrolDetection {returndiff --git a/internal/ai/chat/agentic_final.go b/internal/ai/chat/agentic_final.goindex 9bfd27244b..a04f5a3411 100644--- a/internal/ai/chat/agentic_final.go+++ b/internal/ai/chat/agentic_final.go@@ -82,6 +82,7 @@ func (a *AgenticLoop) ensureFinalTextResponseWithSystemPrompt(// provider-specific tool_choice transport fields.}applyExecutionInferenceAllowance(&summaryReq, a.currentExecutionProfile(), true, a.totalOutputTokens)+ applyExecutionRuntimeEnvelope(&summaryReq, a.currentExecutionProfile())a.mu.Lock()requestSanitizer := a.requestSanitizera.mu.Unlock()diff --git a/internal/ai/chat/agentic_pure_helpers_w0716_coverage_test.go b/internal/ai/chat/agentic_pure_helpers_w0716_coverage_test.goindex bbdb9dfd75..e9a984f11d 100644--- a/internal/ai/chat/agentic_pure_helpers_w0716_coverage_test.go+++ b/internal/ai/chat/agentic_pure_helpers_w0716_coverage_test.go@@ -6,6 +6,7 @@ import ("testing""github.com/rcourtman/pulse-go-rewrite/internal/agentcapabilities"+ "github.com/rcourtman/pulse-go-rewrite/internal/ai/providers""github.com/rcourtman/pulse-go-rewrite/internal/ai/tools")@@ -512,6 +513,27 @@ func Test_w0716_agentic_SetExecutionProfile(t *testing.T) {})}+func TestPatrolExecutionRuntimeEnvelopeMatchesReadinessContextFloor(t *testing.T) {+ for _, profile := range []tools.ExecutionProfile{+ tools.ProfilePatrolDetection,+ tools.ProfilePatrolInvestigation,+ } {+ req := &providers.ChatRequest{}+ applyExecutionRuntimeEnvelope(req, profile)+ if req.MinContextTokens != PatrolProviderMinContextTokens {+ t.Fatalf("profile %d MinContextTokens = %d, want %d", profile, req.MinContextTokens, PatrolProviderMinContextTokens)+ }+ }++ interactive := &providers.ChatRequest{MinContextTokens: 4_096}+ applyExecutionRuntimeEnvelope(interactive, tools.ProfileInteractiveAssistant)+ if interactive.MinContextTokens != 4_096 {+ t.Fatalf("interactive context request changed to %d", interactive.MinContextTokens)+ }++ applyExecutionRuntimeEnvelope(nil, tools.ProfilePatrolDetection)+}+type strErr stringfunc (e strErr) Error() string { return string(e) }diff --git a/internal/ai/chat/service_patrol_additional_test.go b/internal/ai/chat/service_patrol_additional_test.goindex f5a3bc8fcc..b20bf3138a 100644--- a/internal/ai/chat/service_patrol_additional_test.go+++ b/internal/ai/chat/service_patrol_additional_test.go@@ -248,6 +248,9 @@ func TestService_ExecutePatrolStream_Success(t *testing.T) {if mockProvider.lastRequest.StreamIdleTimeout != patrolProviderStreamIdleTimeout {t.Fatalf("stream_idle_timeout=%s want %s", mockProvider.lastRequest.StreamIdleTimeout, patrolProviderStreamIdleTimeout)}+ if mockProvider.lastRequest.MinContextTokens != PatrolProviderMinContextTokens {+ t.Fatalf("min_context_tokens=%d want %d", mockProvider.lastRequest.MinContextTokens, PatrolProviderMinContextTokens)+ }if doneCount != 1 {t.Fatalf("expected done event to be emitted")}diff --git a/internal/ai/patrol_model_readiness.go b/internal/ai/patrol_model_readiness.goindex c41212e8b2..74cdfdcd79 100644--- a/internal/ai/patrol_model_readiness.go+++ b/internal/ai/patrol_model_readiness.go@@ -52,7 +52,7 @@ const (// schemas and generation budget; without an explicit num_ctx Ollama runs// at its server default (typically 4096) and silently truncates the// prompt, capping context quality regardless of the model (#1624).- patrolReadinessProbeContextTokens = 16384+ patrolReadinessProbeContextTokens = chat.PatrolProviderMinContextTokens// patrolReadinessProbeMaxTokens caps probe generation. Thinking models// (qwen3) spend reasoning tokens against this budget before emitting the