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
Make the no-narrative fallback summary clean, not a JSON/call-id dump
rcourtman32523c8c947c
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 09a0ca5641..5af42d6fbf 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -2358,6 +2358,17 @@ message) rather than `chat.isLoading()` so it persists for the whole turn:`isLoading` flips false at visible-turn-complete, which previously made the dockflash its status for a frame and vanish.+When the model runs tools but returns no final narrative, the deterministic+fallback summary (`buildAutomaticFallbackSummary` in+`internal/ai/chat/agentic_final.go`) must read as a clean operator message, not a+dump of internals. It names the tools it ran by their real tool name resolved+from the assistant tool calls (`pulse_` prefix stripped) — never the opaque+provider call id (`call_…`/`toolu_…`/`fc_…`), which must not leak into+chat-visible text — and it must not append raw tool output / result snippets.+The earlier form ("I completed N successful check(s) using call_27f0f389…, …+automatic summary. Latest successful result snippet: {…raw JSON…}") is forbidden:+provider call ids and raw tool JSON are not operator-facing answer content.+Assistant slash-command availability is part of the command runtime contract,not only visual polish. The OpenCode reference at fetched `origin/dev` commit`c495635` filters prompt slash commands through the registered command catalogdiff --git a/internal/ai/chat/agentic_additional_test.go b/internal/ai/chat/agentic_additional_test.goindex 7400d4bdb2..dcdc011b88 100644--- a/internal/ai/chat/agentic_additional_test.go+++ b/internal/ai/chat/agentic_additional_test.go@@ -161,7 +161,7 @@ func TestEnsureFinalTextResponse(t *testing.T) {if len(result2) != 3 {t.Fatalf("expected fallback summary message when provider errors")}- if !strings.Contains(result2[len(result2)-1].Content, "automatic summary") {+ if !strings.Contains(result2[len(result2)-1].Content, "didn't return a written summary") {t.Fatalf("expected deterministic fallback summary, got %q", result2[len(result2)-1].Content)}@@ -182,8 +182,13 @@ func TestEnsureFinalTextResponse(t *testing.T) {if len(result3) != 3 {t.Fatalf("expected fallback summary when provider returns empty content")}- if !strings.Contains(result3[len(result3)-1].Content, "Latest successful result snippet") {- t.Fatalf("expected fallback summary to include tool snippet")+ fallback3 := result3[len(result3)-1].Content+ if !strings.Contains(fallback3, "didn't return a written summary") {+ t.Fatalf("expected clean fallback summary, got %q", fallback3)+ }+ // The fallback must not dump raw tool output / result snippets into the chat.+ if strings.Contains(fallback3, "cpu ok") || strings.Contains(fallback3, "result snippet") {+ t.Fatalf("fallback summary must not include raw tool output, got %q", fallback3)}}@@ -327,11 +332,40 @@ func TestBuildAutomaticFallbackSummary(t *testing.T) {{Role: "user", ToolResult: &ToolResult{ToolUseID: "pulse_query_1", Content: "containers ok", IsError: false}},{Role: "user", ToolResult: &ToolResult{ToolUseID: "pulse_read_0", Content: "read failed", IsError: true}},})- if !strings.Contains(summary, "2 successful check(s)") {+ if !strings.Contains(summary, "I ran 2 checks") {t.Fatalf("unexpected fallback summary: %q", summary)}- if !strings.Contains(summary, "pulse_query") {- t.Fatalf("expected tool name in fallback summary")+ // Tool name is surfaced operator-facing (pulse_ prefix stripped), never the+ // raw provider call id.+ if !strings.Contains(summary, "query") {+ t.Fatalf("expected tool name in fallback summary, got %q", summary)+ }+ if !strings.Contains(summary, "1 tool error") {+ t.Fatalf("expected error count in fallback summary, got %q", summary)+ }+}++func TestBuildAutomaticFallbackSummary_UsesToolNamesNotCallIDsOrRawOutput(t *testing.T) {+ // Reproduces the real OpenRouter shape that produced the ugly chat dump:+ // tool results carry opaque provider call ids, and the real tool name lives+ // on the assistant tool call. The fallback must name the tools, not leak the+ // call ids, and must not dump raw tool output into chat-visible text.+ summary := buildAutomaticFallbackSummary([]Message{+ {Role: "assistant", ToolCalls: []ToolCall{+ {ID: "call_27f0f389aba4652a1e292dc", Name: "pulse_query"},+ {ID: "call_66a4659a104b4ee7807201cb", Name: "pulse_metrics"},+ }},+ {Role: "user", ToolResult: &ToolResult{ToolUseID: "call_27f0f389aba4652a1e292dc", Content: `{"nodes":2}`, IsError: false}},+ {Role: "user", ToolResult: &ToolResult{ToolUseID: "call_66a4659a104b4ee7807201cb", Content: `{"cpuPct":12}`, IsError: false}},+ })+ if strings.Contains(summary, "call_") {+ t.Fatalf("fallback summary must not leak provider call ids, got %q", summary)+ }+ if !strings.Contains(summary, "query") || !strings.Contains(summary, "metrics") {+ t.Fatalf("expected real tool names in fallback summary, got %q", summary)+ }+ if strings.Contains(summary, "nodes") || strings.Contains(summary, "cpuPct") || strings.Contains(summary, "{") {+ t.Fatalf("fallback summary must not dump raw tool output, got %q", summary)}}diff --git a/internal/ai/chat/agentic_final.go b/internal/ai/chat/agentic_final.goindex 15484ac850..046ccd03b9 100644--- a/internal/ai/chat/agentic_final.go+++ b/internal/ai/chat/agentic_final.go@@ -168,7 +168,19 @@ func buildAutomaticFallbackSummary(resultMessages []Message) string {successCount := 0errorCount := 0toolCounts := make(map[string]int)- lastSuccessSnippet := ""++ // Resolve provider tool-call ids to the real tool name so the summary names+ // the checks (query, metrics, ...) instead of leaking raw `call_…` ids.+ idToName := make(map[string]string)+ for _, msg := range resultMessages {+ for _, call := range msg.ToolCalls {+ id := strings.TrimSpace(call.ID)+ name := strings.TrimSpace(call.Name)+ if id != "" && name != "" {+ idToName[id] = name+ }+ }+ }for _, msg := range resultMessages {if msg.ToolResult == nil {@@ -179,12 +191,8 @@ func buildAutomaticFallbackSummary(resultMessages []Message) string {continue}successCount++- if tool := normalizeToolUseID(msg.ToolResult.ToolUseID); tool != "" {- toolCounts[tool]++- }- content := strings.TrimSpace(msg.ToolResult.Content)- if content != "" {- lastSuccessSnippet = compactSnippet(content, 360)+ if name := fallbackToolDisplayName(msg.ToolResult.ToolUseID, idToName); name != "" {+ toolCounts[name]++}}@@ -220,19 +228,48 @@ func buildAutomaticFallbackSummary(resultMessages []Message) string {toolList = strings.Join(names, ", ")}+ checkWord := "checks"+ if successCount == 1 {+ checkWord = "check"+ }summary := fmt.Sprintf(- "I completed %d successful check(s) using %s. The model didn't provide a final narrative, so this is an automatic summary.",- successCount, toolList,+ "I ran %d %s (%s) but the model didn't return a written summary this time. Ask me again and I'll pull the results together.",+ successCount, checkWord, toolList,)if errorCount > 0 {- summary += fmt.Sprintf(" There were %d tool error(s) during this run.", errorCount)- }- if lastSuccessSnippet != "" {- summary += "\n\nLatest successful result snippet:\n" + lastSuccessSnippet+ errWord := "errors"+ if errorCount == 1 {+ errWord = "error"+ }+ summary += fmt.Sprintf(" %d tool %s occurred during the run.", errorCount, errWord)}return summary}+// fallbackToolDisplayName resolves an operator-facing tool name for the+// automatic fallback summary. It prefers the real tool name from the assistant's+// tool call (idToName), and only falls back to the tool-use id when that id+// itself reads like a tool name — never an opaque provider call id+// (`call_…`, `toolu_…`, `fc_…`), which must not leak into chat-visible text.+func fallbackToolDisplayName(toolUseID string, idToName map[string]string) string {+ if name := strings.TrimSpace(idToName[strings.TrimSpace(toolUseID)]); name != "" {+ return displayToolName(name)+ }+ normalized := normalizeToolUseID(toolUseID)+ lower := strings.ToLower(normalized)+ if normalized == "" ||+ strings.HasPrefix(lower, "call_") ||+ strings.HasPrefix(lower, "toolu_") ||+ strings.HasPrefix(lower, "fc_") {+ return ""+ }+ return displayToolName(normalized)+}++func displayToolName(name string) string {+ return strings.TrimPrefix(strings.TrimSpace(name), "pulse_")+}+func normalizeToolUseID(toolUseID string) string {toolUseID = strings.TrimSpace(toolUseID)if toolUseID == "" {@@ -252,14 +289,3 @@ func normalizeToolUseID(toolUseID string) string {}return toolUseID[:lastUnderscore]}--func compactSnippet(content string, maxLen int) string {- compact := strings.Join(strings.Fields(content), " ")- if len(compact) <= maxLen {- return compact- }- if maxLen <= 3 {- return compact[:maxLen]- }- return compact[:maxLen-3] + "..."-}