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 Patrol handoff context model-only in Assistant
rcourtman7de85ff257c0
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 787d59fa0a..8f7fd992b2 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -356,7 +356,10 @@ profile and assignment columns, but embedded table framing must route throughcommand policy, or fleet-control authority. Assistant chat enrichment from`finding_id` follows the same rule: lifecycle-owned command execution andagent auto-approval policy stay canonical in the agent/runtime owners, not- in Patrol investigation-record prompt text.+ in Patrol investigation-record prompt text. Model-only Assistant handoff+ context for a Patrol finding is also not agent lifecycle state and must not+ be used as enrollment evidence, command-websocket identity, or installer+ authority.The same isolation rule applies to CSRF token-store behavior in`internal/api/csrf_store.go`: lifecycle-adjacent browser flows may rely onthe shared API/security layer to keep parallel replacement-token retriesdiff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex f98d460a8a..9e41355365 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -174,9 +174,11 @@ runtime cost control, and shared AI transport surfaces.unified findings, persistence, and approval/remediation context must usethe durable investigation record when they need operator-facinginvestigation context. When `/api/ai/chat` receives `finding_id`, the- runtime must enrich the prompt from that durable record before provider- transport while keeping proposed-fix command text out of the chat prompt;- command payloads remain approval-context data, not conversational copy.+ runtime must enrich the provider turn from that durable record while+ preserving the user's authored prompt as the persisted conversation+ message; proposed-fix command text must stay out of both the persisted chat+ message and the model-only handoff context, and command payloads remain+ approval-context data, not conversational copy.The Assistant drawer may also render an attached context briefing for thathandoff, but the briefing is runtime context visibility only: it must notmutate chat control settings, execute tools, or reveal raw command payloads.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 3fddf1af7d..14c1ed002c 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -747,9 +747,11 @@ the canonical monitored-system blocked payload.and the Assistant finding-context request contract, so `/api/ai/chat`payloads carrying `finding_id` may hydrate a structured investigationsummary from the unified finding, but raw proposed-fix commands must stay- out of the prompt and inside governed approval/remediation context; frontend- handoff briefings must derive from the same shared investigation payload- rather than inventing a second finding-context transport shape.+ out of the persisted prompt and inside governed approval/remediation+ context; the backend may pass that summary as model-only handoff context for+ the current turn, and frontend handoff briefings must derive from the same+ shared investigation payload rather than inventing a second finding-context+ transport shape.7. Keep Patrol summary payload consumers aligned on one assessment hierarchy: transport-driven Patrol summary surfaces may show supporting counts and outcomes, but the canonical assessment and verification states must remain singular and not be repeated as a second compact verdict strip8. Keep Patrol verification and activity facts unified on one transport-backed secondary status area: when frontend consumers combine Patrol status payloads (`runtime_state`, `last_patrol_at`, `last_activity_at`, `trigger_status`) with run-history transport, the latest run result, activity mix, scoped-trigger state, and circuit-breaker context must read as one supporting explanation beneath the primary assessment instead of being re-expanded into a separate full-width status strip plus duplicate summary layersand the main Patrol page composition boundary, so once that governeddiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 58520792ac..b7ad55227c 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -411,7 +411,10 @@ bypass the API fail-closed execution gate.action authority. Assistant chat summaries built from `finding_id` remainAI/runtime context; storage and recovery may read the resulting guidanceonly as adjacent investigation context, not as a recovery support verdict- or restore execution contract.+ or restore execution contract. If that guidance is passed as model-only+ Assistant handoff context instead of persisted prompt text, the boundary is+ unchanged: it still cannot become backup freshness, restore eligibility, or+ storage-local recovery authority.That same adjacent `internal/api/` boundary still carries Patrol-runexecution identity. Storage and recovery may observe shared Patroltransport through `internal/api/chat_service_adapter.go`, but they must notdiff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.goindex 5f8ab39d57..e1d96cdf81 100644--- a/internal/ai/chat/service.go+++ b/internal/ai/chat/service.go@@ -471,6 +471,8 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbacInt("message_count", len(messages)).Msg("[ChatService] Got messages, calling agentic loop")+ injectHandoffContextIntoLatestUserMessage(messages, req.HandoffContext)+// Determine which model/loop to use for this request.selectedModel := ""configuredModel := ""@@ -763,6 +765,26 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbacreturn nil}+func injectHandoffContextIntoLatestUserMessage(messages []Message, handoffContext string) {+ contextText := strings.TrimSpace(handoffContext)+ if contextText == "" || len(messages) == 0 {+ return+ }++ for idx := len(messages) - 1; idx >= 0; idx-- {+ if messages[idx].Role != "user" {+ continue+ }+ userText := strings.TrimSpace(messages[idx].Content)+ if userText == "" {+ messages[idx].Content = contextText+ return+ }+ messages[idx].Content = contextText + "\n\n---\nUser message: " + userText+ return+ }+}+// PatrolRequest represents a patrol execution request within the chat servicetype PatrolRequest struct {Prompt string `json:"prompt"`diff --git a/internal/ai/chat/service_execute_additional_test.go b/internal/ai/chat/service_execute_additional_test.goindex 8ee77e2d20..8402078eec 100644--- a/internal/ai/chat/service_execute_additional_test.go+++ b/internal/ai/chat/service_execute_additional_test.go@@ -94,6 +94,75 @@ func TestService_ExecuteStream_Success(t *testing.T) {}}+func TestService_ExecuteStream_HandoffContextIsModelOnly(t *testing.T) {+ tmpDir := t.TempDir()+ store, err := NewSessionStore(tmpDir)+ if err != nil {+ t.Fatalf("failed to create session store: %v", err)+ }++ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})+ var capturedMessages []providers.Message+ provider := &stubServiceProvider{+ streamFn: func(ctx context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {+ capturedMessages = append([]providers.Message(nil), req.Messages...)+ callback(providers.StreamEvent{+ Type: "content",+ Data: providers.ContentEvent{Text: "noted"},+ })+ callback(providers.StreamEvent{+ Type: "done",+ Data: providers.DoneEvent{InputTokens: 1, OutputTokens: 1},+ })+ return nil+ },+ }+ loop := NewAgenticLoop(provider, executor, "system")++ svc := &Service{+ cfg: &config.AIConfig{ChatModel: "openai:test"},+ sessions: store,+ executor: executor,+ agenticLoop: loop,+ provider: provider,+ started: true,+ }++ req := ExecuteRequest{+ SessionID: "sess-handoff",+ Prompt: "What happened?",+ HandoffContext: "[Finding Context]\nID: finding-123\nConclusion: CPU saturated after backup.",+ }+ if err := svc.ExecuteStream(context.Background(), req, func(StreamEvent) {}); err != nil {+ t.Fatalf("ExecuteStream failed: %v", err)+ }++ stored, err := store.GetMessages("sess-handoff")+ if err != nil {+ t.Fatalf("GetMessages failed: %v", err)+ }+ if len(stored) == 0 {+ t.Fatal("expected stored messages")+ }+ if stored[0].Content != "What happened?" {+ t.Fatalf("stored user message = %q, want clean prompt", stored[0].Content)+ }+ if strings.Contains(stored[0].Content, "[Finding Context]") {+ t.Fatalf("stored user message should not include handoff context: %q", stored[0].Content)+ }++ if len(capturedMessages) == 0 {+ t.Fatal("expected provider messages")+ }+ modelUserContent := capturedMessages[len(capturedMessages)-1].Content+ if !strings.Contains(modelUserContent, "[Finding Context]") {+ t.Fatalf("model user content missing handoff context: %q", modelUserContent)+ }+ if !strings.Contains(modelUserContent, "User message: What happened?") {+ t.Fatalf("model user content missing clean user message: %q", modelUserContent)+ }+}+func TestService_ExecuteStream_PrefetchMentionsAndOverrideModel(t *testing.T) {tmpDir := t.TempDir()store, err := NewSessionStore(tmpDir)diff --git a/internal/ai/chat/types.go b/internal/ai/chat/types.goindex 890e708359..ffcee9d100 100644--- a/internal/ai/chat/types.go+++ b/internal/ai/chat/types.go@@ -97,6 +97,7 @@ type ExecuteRequest struct {Model string `json:"model,omitempty"`Mentions []StructuredMention `json:"mentions,omitempty"`FindingID string `json:"finding_id,omitempty"` // Pre-populate finding context for "Discuss" flow+ HandoffContext string `json:"handoff_context,omitempty"` // Model-only context for scoped handoffs; not persisted as user-authored text.MaxTurns int `json:"max_turns,omitempty"` // Override max agentic turns (0 = use default)AutonomousMode *bool `json:"autonomous_mode,omitempty"` // Per-request autonomous override (nil = use service default)}diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.goindex d6e92c1097..db490ae549 100644--- a/internal/api/ai_handler.go+++ b/internal/api/ai_handler.go@@ -1074,14 +1074,15 @@ func (h *AIHandler) HandleChat(w http.ResponseWriter, r *http.Request) {})}- // Augment prompt with finding context when discussing a specific finding- prompt := req.Prompt+ // Build model-only finding context when discussing a specific finding. The+ // chat service injects this into the current model turn without persisting it+ // as the user's authored prompt, so conversation history stays readable.+ handoffContext := ""if req.FindingID != "" {store := h.GetUnifiedStoreForOrg(GetOrgID(ctx))if store != nil {if f := store.Get(req.FindingID); f != nil {- findingCtx := buildUnifiedFindingChatContext(f)- prompt = findingCtx + "\n\n---\nUser message: " + prompt+ handoffContext = buildUnifiedFindingChatContext(f)}}}@@ -1089,11 +1090,12 @@ func (h *AIHandler) HandleChat(w http.ResponseWriter, r *http.Request) {// Stream from AI chat serviceserviceSentDone := falseerr := svc.ExecuteStream(ctx, chat.ExecuteRequest{- Prompt: prompt,+ Prompt: req.Prompt,SessionID: req.SessionID,Model: req.Model,Mentions: chatMentions,FindingID: req.FindingID,+ HandoffContext: handoffContext,AutonomousMode: req.AutonomousMode,}, func(event chat.StreamEvent) {if event.Type == "done" {diff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.goindex b73077c9d0..ad27b25624 100644--- a/internal/api/ai_handler_test.go+++ b/internal/api/ai_handler_test.go@@ -624,15 +624,16 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {Run(func(args mock.Arguments) {reqArg := args.Get(1).(chat.ExecuteRequest)assert.Equal(t, "finding-123", reqArg.FindingID)- assert.Contains(t, reqArg.Prompt, "[Finding Context]")- assert.Contains(t, reqArg.Prompt, "[Investigation Record]")- assert.Contains(t, reqArg.Prompt, "Conclusion: Backup job saturated CPU.")- assert.Contains(t, reqArg.Prompt, "Recommended Action: Approve a controlled service restart after backup completion.")- assert.Contains(t, reqArg.Prompt, "Evidence 1: metrics: CPU stayed above 95% for 10 minutes")- assert.Contains(t, reqArg.Prompt, "Proposed Fix: Restart the workload service")- assert.Contains(t, reqArg.Prompt, "Proposed Fix Commands: 1 command recorded for approval context")- assert.Contains(t, reqArg.Prompt, "User message: What happened?")- assert.NotContains(t, reqArg.Prompt, "systemctl restart workload.service")+ assert.Equal(t, "What happened?", reqArg.Prompt)+ assert.Contains(t, reqArg.HandoffContext, "[Finding Context]")+ assert.Contains(t, reqArg.HandoffContext, "[Investigation Record]")+ assert.Contains(t, reqArg.HandoffContext, "Conclusion: Backup job saturated CPU.")+ assert.Contains(t, reqArg.HandoffContext, "Recommended Action: Approve a controlled service restart after backup completion.")+ assert.Contains(t, reqArg.HandoffContext, "Evidence 1: metrics: CPU stayed above 95% for 10 minutes")+ assert.Contains(t, reqArg.HandoffContext, "Proposed Fix: Restart the workload service")+ assert.Contains(t, reqArg.HandoffContext, "Proposed Fix Commands: 1 command recorded for approval context")+ assert.NotContains(t, reqArg.HandoffContext, "User message: What happened?")+ assert.NotContains(t, reqArg.HandoffContext, "systemctl restart workload.service")})body := `{"prompt":"What happened?","finding_id":"finding-123"}`diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex dec12963b0..21ea36f531 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -116,6 +116,41 @@ func TestPatrolRemediationCommercialCopyUsesSafeRemediationWording(t *testing.T)}}+func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {+ handlerSource, err := os.ReadFile(filepath.Clean("ai_handler.go"))+ if err != nil {+ t.Fatalf("read ai_handler.go: %v", err)+ }+ chatServiceSource, err := os.ReadFile(filepath.Clean("../ai/chat/service.go"))+ if err != nil {+ t.Fatalf("read chat service: %v", err)+ }++ handlerText := string(handlerSource)+ for _, required := range []string{+ "handoffContext = buildUnifiedFindingChatContext(f)",+ "Prompt: req.Prompt",+ "HandoffContext: handoffContext",+ } {+ if !strings.Contains(handlerText, required) {+ t.Fatalf("ai_handler.go must preserve model-only finding handoff contract: missing %q", required)+ }+ }+ if strings.Contains(handlerText, "prompt = findingCtx +") {+ t.Fatal("ai_handler.go must not prepend finding context into the persisted prompt")+ }++ chatServiceText := string(chatServiceSource)+ for _, required := range []string{+ "injectHandoffContextIntoLatestUserMessage(messages, req.HandoffContext)",+ "User message: ",+ } {+ if !strings.Contains(chatServiceText, required) {+ t.Fatalf("chat service must inject handoff context into model-only turn: missing %q", required)+ }+ }+}+func TestContract_ProxmoxSetupScriptUsesPrivilegeSeparatedTokenACLs(t *testing.T) {storagePerms := `pveum aclmod /storage -user pulse-monitor@pve -role PVEDatastoreAdmin