Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Give truncated Patrol decisions room to finish

rcourtman1a1752538098
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 8c20f6d61d..3b644a7f33 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -3405,6 +3405,11 @@ Qualification floor: Patrol model launch and product-claim qualification must us
container ID or substitute a display name after `pulse_query` returns a
canonical `app-container` ID; cross-tool identity translation is an AI
runtime responsibility.
+ The investigation seed must therefore label the finding's display name,
+ canonical resource ID, and resource type as separate fields and state the
+ tool-schema rule explicitly: `resource_id` receives the canonical ID, while
+ a display name is used only by arguments documented as names or queries.
+ Human-readable prompt formatting must not make those identities ambiguous.
Investigation action-catalog and proposal tools inherit that identity
boundary in both directions: an exact, uniquely resolved Docker provider
coordinate may be translated back to its canonical `app-container` target,
@@ -7285,8 +7290,11 @@ A Watch provider turn that stops because its output-token allowance was
exhausted is not a completed finding decision. Core preserves the partial turn
only as model context, excludes its unfinished prose from the durable Patrol
summary, and offers one bounded retry containing only the governed finding
-report and assessment tools. A second token-limited turn fails the run closed;
-it can never be interpreted or published as an all-clear.
+report and assessment tools. That retry may use a larger per-turn allowance
+from the same fixed run-level output budget so reasoning-heavy models can reach
+the structured decision without increasing the run's total spend. A second
+token-limited turn fails the run closed; it can never be interpreted or
+published as an all-clear.
Every provider tool call admitted by the orchestration boundary from the main
pass, evaluation pass, and assessment sweep is merged into the one durable
diff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.go
index 7d22531007..74337b9aa2 100644
--- a/internal/ai/chat/agentic.go
+++ b/internal/ai/chat/agentic.go
@@ -1125,6 +1125,9 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me
}
}
applyExecutionInferenceAllowance(&req, a.currentExecutionProfile(), patrolSummaryOnlyTurn, a.totalOutputTokens)
+ if patrolOutputLimitRecoveryTurn {
+ applyPatrolOutputLimitRecoveryAllowance(&req, a.totalOutputTokens)
+ }
// Pre-request context validation: catch overflow from message history growth.
// Phase 2 handles first-turn overflow via seed budget; this catches
diff --git a/internal/ai/chat/agentic_additional_test.go b/internal/ai/chat/agentic_additional_test.go
index 720225f148..9c262dc1e3 100644
--- a/internal/ai/chat/agentic_additional_test.go
+++ b/internal/ai/chat/agentic_additional_test.go
@@ -624,6 +624,9 @@ func TestAgenticLoopRecoversTruncatedPatrolDecisionWithGovernedFindingTurn(t *te
if !strings.Contains(recoveryRequest.System, "previous model turn exhausted its output budget") {
t.Fatalf("recovery prompt = %q", recoveryRequest.System)
}
+ if recoveryRequest.MaxTokens != patrolDetectionRecoveryAllowance {
+ t.Fatalf("recovery MaxTokens = %d, want %d within the existing run budget", recoveryRequest.MaxTokens, patrolDetectionRecoveryAllowance)
+ }
var persisted strings.Builder
for _, message := range result {
if message.Role == "assistant" {
diff --git a/internal/ai/chat/agentic_control.go b/internal/ai/chat/agentic_control.go
index 7c320482d9..83544da8eb 100644
--- a/internal/ai/chat/agentic_control.go
+++ b/internal/ai/chat/agentic_control.go
@@ -11,6 +11,7 @@ const (
// preventing a concise check from inheriting a provider's unbounded default.
patrolDetectionRunOutputAllowance = 7_000
patrolDetectionTurnOutputAllowance = 2_048
+ patrolDetectionRecoveryAllowance = 4_096
patrolDetectionSummaryAllowance = 1_024
patrolDetectionMinimumAllowance = 512
)
@@ -35,6 +36,23 @@ func applyExecutionInferenceAllowance(req *providers.ChatRequest, profile tools.
req.ReasoningEffort = providers.ReasoningEffortLow
}
+func applyPatrolOutputLimitRecoveryAllowance(req *providers.ChatRequest, outputTokensUsed int) {
+ if req == nil {
+ return
+ }
+
+ allowance := patrolDetectionRecoveryAllowance
+ if remaining := patrolDetectionRunOutputAllowance - outputTokensUsed; remaining < allowance {
+ allowance = remaining
+ }
+ if allowance < patrolDetectionMinimumAllowance {
+ allowance = patrolDetectionMinimumAllowance
+ }
+
+ req.MaxTokens = allowance
+ req.ReasoningEffort = providers.ReasoningEffortLow
+}
+
// Abort aborts an ongoing session.
func (a *AgenticLoop) Abort(sessionID string) {
a.mu.Lock()