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
Suppress compacted Assistant artifact text
rcourtmaneda53f0b1aa4
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 1a775919af..9c37caea96 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -845,7 +845,14 @@ runtime cost control, and shared AI transport surfaces.proven to be normal answer text or stripped when a raw tool-call markerarrives; it must not flash as run-on prose such as`I'llcheckthedevicenodes...` while the actual governed tool row is still- being assembled.+ being assembled, and it must not be promoted to final assistant answer text+ when the stream reaches `done` without proving a normal answer. The+ referenced OpenCode source at fetched `origin/dev` commit+ `1025540fcc2a69609a0131a7168300205656d728` keeps rendered answer text as+ typed text parts in `packages/ui/src/components/message-part.tsx` and uses+ `createPacedValue` only as a presentation-layer reveal; Pulse adapts that by+ preserving typed content exactly while suppressing malformed compacted+ tool-prelude residue rather than inventing spaces or storing it as prose.A pre-tool assistant preamble such as "I'll check that" does not satisfy thefinal-answer contract after Pulse executes tools. The final-response guardmust require non-empty assistant text after the latest user/tool-result@@ -1103,11 +1110,14 @@ runtime cost control, and shared AI transport surfaces.frontend rendering. Compacted no-whitespace internal prelude text attachedto a leaked tool invocation is part of that same artifact and must besuppressed or retracted from the current stream segment instead of rendered- as assistant prose. Drawer-level loading/progress status must stay scoped to- the active turn and must collapse back to quiet when the turn is idle; it may- mirror the latest active tool/workflow state as a compact heartbeat, but raw- outputs, restored evidence, errors, and completed details stay in the- transcript row that owns the turn. Completed tool rows in the drawer may show+ as assistant prose; if that compacted prelude is still pending when the+ stream closes, terminal flush must drop it rather than turning unreadable+ provider residue into the final answer. Drawer-level loading/progress status+ must stay scoped to the active turn and must collapse back to quiet when the+ turn is idle; it may mirror the latest active tool/workflow state as a+ compact heartbeat, but raw outputs, restored evidence, errors, and completed+ details stay in the transcript row that owns the turn. Completed tool rows in+ the drawer may showcompact tool name, action summary, status, and anexplicit details affordance, but raw tool input/output JSON must not renderin the default transcript. Token accounting and other provider metadatadiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex ea23f1df83..b34778c2e5 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -564,7 +564,10 @@ payload shape change when the portal presents compact client rows.with completed arguments through the normal `tool_progress` event.At least one fixture-backed Assistant tool sequence must exercise theskipped-tool lifecycle by resolving a visible `tool_start` row through- `tool_cancel` instead of hiding the activity.+ `tool_cancel` instead of hiding the activity. At least one fixture-backed+ Assistant tool sequence must exercise compacted provider artifact+ suppression by emitting compacted pre-tool content before a governed tool row+ and final normal answer content.34. `internal/api/ai_handlers.go` shared with `ai-runtime`: AI settings and remediation handlers are both an AI runtime control surface and a canonical API payload contract boundary.Legacy Assistant SSE routes in this handler that still use the olderexecute envelope, including `/api/ai/execute/stream` anddiff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.tsindex 9b9c6c7701..4dfffdf87a 100644--- a/frontend-modern/src/api/__tests__/aiChat.test.ts+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts@@ -194,6 +194,54 @@ describe('AIChatAPI', () => {});});+ it('runs the compacted-artifact dev stream fixture without opening a provider request', async () => {+ const onEvent = vi.fn();++ await AIChatAPI.chat(+ '/fixture compacted-artifact',+ undefined,+ 'openrouter:deepseek/deepseek-chat',+ onEvent,+ );++ expect(apiFetchMock).not.toHaveBeenCalled();+ expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual([+ 'session',+ 'workflow_state',+ 'content',+ 'tool_start',+ 'tool_end',+ 'content',+ 'done',+ ]);+ expect(onEvent.mock.calls[2][0]).toMatchObject({+ type: 'content',+ data: {+ text: expect.stringContaining("I'llcheckthedevicenodes"),+ },+ });+ expect(onEvent.mock.calls[3][0]).toMatchObject({+ type: 'tool_start',+ data: {+ id: 'fixture-tool-compacted',+ name: 'pulse_read',+ },+ });+ expect(onEvent.mock.calls[5][0]).toMatchObject({+ type: 'content',+ data: {+ text: expect.stringContaining('4,358 entries'),+ },+ });+ expect(onEvent.mock.calls[6][0]).toMatchObject({+ type: 'done',+ data: {+ session_id: 'dev-fixture-compacted-artifact',+ model: 'openrouter:deepseek/deepseek-chat',+ },+ });+ });+it('lets the browser paint the first visible text delta before draining a coalesced chat chunk', async () => {vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });const requestAnimationFrame = installAnimationFrame();diff --git a/frontend-modern/src/api/aiChatDevStreamFixture.ts b/frontend-modern/src/api/aiChatDevStreamFixture.tsindex d32c1d56df..3aecb98bb5 100644--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts@@ -3,6 +3,7 @@ import type { AIChatStreamEvent } from './generated/aiChatEvents';export const AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS = ['/fixture devices','/fixture assistant-stream',+ '/fixture compacted-artifact','/fixture skipped-tool',] as const;@@ -190,8 +191,70 @@ const buildSkippedToolFixtureEvents = (model?: string): AIChatStreamEvent[] => [},];+const buildCompactedArtifactFixtureEvents = (model?: string): AIChatStreamEvent[] => [+ {+ type: 'session',+ data: { id: 'dev-fixture-compacted-artifact' },+ },+ {+ type: 'workflow_state',+ data: {+ phase: 'request_start',+ message: 'Preparing Pulse context.',+ },+ },+ {+ type: 'content',+ data: {+ text: "I'llcheckthedevicenodesinsidethecontainertoanswerthat.Letmecounttheentriesin/devandlisttheblockdevices.",+ },+ },+ {+ type: 'tool_start',+ data: {+ id: 'fixture-tool-compacted',+ name: 'pulse_read',+ input:+ '{"target_host":"current_resource","command":"ls /dev | wc -l && lsblk -d -o NAME,TYPE,SIZE"}',+ raw_input:+ 'pulse_read(target_host="current_resource", command="ls /dev | wc -l && lsblk -d -o NAME,TYPE,SIZE")',+ },+ },+ {+ type: 'tool_end',+ data: {+ id: 'fixture-tool-compacted',+ name: 'pulse_read',+ input:+ '{"target_host":"current_resource","command":"ls /dev | wc -l && lsblk -d -o NAME,TYPE,SIZE"}',+ raw_input:+ 'pulse_read(target_host="current_resource", command="ls /dev | wc -l && lsblk -d -o NAME,TYPE,SIZE")',+ output: ['4358', 'NAME TYPE SIZE', 'sda disk 1.8T', 'nvme0n1 disk 931.5G'].join('\n'),+ success: true,+ },+ },+ {+ type: 'content',+ data: {+ text: 'There are 4,358 entries under `/dev`, including 2 block devices: `sda` and `nvme0n1`.',+ },+ },+ {+ type: 'done',+ data: {+ session_id: 'dev-fixture-compacted-artifact',+ model: assistantFixtureModel(model),+ input_tokens: 96,+ output_tokens: 42,+ },+ },+];+const buildFixtureEvents = (prompt: string, model?: string): AIChatStreamEvent[] => {const normalized = normalizeFixturePrompt(prompt);+ if (normalized === '/fixture compacted-artifact') {+ return buildCompactedArtifactFixtureEvents(model);+ }if (normalized === '/fixture skipped-tool') {return buildSkippedToolFixtureEvents(model);}diff --git a/frontend-modern/src/components/AI/Chat/__tests__/assistantOutputHygiene.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/assistantOutputHygiene.test.tsindex 52dd1060c3..2171660df5 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/assistantOutputHygiene.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/assistantOutputHygiene.test.ts@@ -92,7 +92,7 @@ describe('stripAssistantOutputArtifacts', () => {expect(flushPendingAssistantOutputText(state)).toBe('');});- it('flushes held compacted prose when no tool leak follows before stream end', () => {+ it('drops held compacted prose when no tool leak follows before stream end', () => {const state = createAssistantOutputArtifactStreamState();const content ="Thisisbadmodelspacingbutitistheactualanswerbecauseitneverturnsintoatoolcall.";@@ -101,7 +101,7 @@ describe('stripAssistantOutputArtifacts', () => {text: '',stripped: false,});- expect(flushPendingAssistantOutputText(state)).toBe(content);+ expect(flushPendingAssistantOutputText(state)).toBe('');});it('releases a held prefix when the next delta proves it is normal prose', () => {diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.tsindex e6de394939..4940e07afc 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts@@ -1088,7 +1088,7 @@ describe('useChat', () => {dispose();});- it('flushes held compacted prose on done when no tool-call leak follows', async () => {+ it('does not flush held compacted prose on done when no tool-call leak follows', async () => {const { getFireEvent } = setupWithEventCapture();const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));@@ -1103,10 +1103,8 @@ describe('useChat', () => {fire({ type: 'done', data: {} });const assistant = chat.messages().find((m) => m.role === 'assistant')!;- expect(assistant.content).toBe(compacted);- expect(assistant.streamEvents?.filter((e) => e.type === 'content')).toMatchObject([- { type: 'content', content: compacted },- ]);+ expect(assistant.content).toBe('');+ expect(assistant.streamEvents?.filter((e) => e.type === 'content')).toEqual([]);expect(assistant.isStreaming).toBe(false);dispose();});@@ -1140,6 +1138,34 @@ describe('useChat', () => {dispose();});+ it('does not render compacted pre-tool artifact text when a governed tool row follows', async () => {+ const { getFireEvent } = setupWithEventCapture();+ const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));++ await chat.sendMessage('how many devices in this');+ const fire = getFireEvent();+ const compacted =+ "I'llcheckthedevicenodesinsidethecontainertoanswerthat.Letmecounttheentriesin/devandlisttheblockdevices.";++ fire({ type: 'content', data: compacted });+ fire({ type: 'tool_start', data: { id: 'tool-1', name: 'pulse_read', input: '{}' } });+ fire({+ type: 'tool_end',+ data: { id: 'tool-1', name: 'pulse_read', input: '{}', output: '4358', success: true },+ });+ fire({ type: 'content', data: 'There are 4,358 entries under /dev.' });+ fire({ type: 'done', data: {} });++ const assistant = chat.messages().find((m) => m.role === 'assistant')!;+ expect(assistant.content).toBe('There are 4,358 entries under /dev.');+ expect(assistant.content).not.toContain("I'llcheck");+ expect(assistant.streamEvents?.filter((e) => e.type === 'content')).toMatchObject([+ { type: 'content', content: 'There are 4,358 entries under /dev.' },+ ]);+ expect(assistant.streamEvents?.map((e) => e.type)).toEqual(['tool', 'content']);+ dispose();+ });+it('ignores product telemetry events that are not the model response', async () => {const { getFireEvent } = setupWithEventCapture();const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));diff --git a/frontend-modern/src/components/AI/Chat/assistantOutputHygiene.ts b/frontend-modern/src/components/AI/Chat/assistantOutputHygiene.tsindex 2fd4814529..dde0d726ad 100644--- a/frontend-modern/src/components/AI/Chat/assistantOutputHygiene.ts+++ b/frontend-modern/src/components/AI/Chat/assistantOutputHygiene.ts@@ -117,6 +117,9 @@ export function flushPendingAssistantOutputText(state: AssistantOutputArtifactSt}const text = state.pendingText;state.pendingText = '';+ if (isCompactedToolPrelude(text)) {+ return '';+ }state.visibleText += text;return text;}diff --git a/internal/ai/chat/agentic_sanitize.go b/internal/ai/chat/agentic_sanitize.goindex 72cacffc9f..3447e5012e 100644--- a/internal/ai/chat/agentic_sanitize.go+++ b/internal/ai/chat/agentic_sanitize.go@@ -247,6 +247,12 @@ func appendVisibleContentBeforeToolLeak(candidate := existing + textidx := toolCallArtifactIndex(candidate)if idx < 0 {+ if existing == "" && isCompactedToolPrelude(text) {+ if pending != nil {+ *pending = text+ }+ return "", false+ }visible, held := splitTrailingPotentialToolNamePrefix(text)if pending != nil {*pending = held@@ -279,6 +285,9 @@ func flushPendingVisibleContent(builder *strings.Builder, pending *string) strin}visible := *pending*pending = ""+ if isCompactedToolPrelude(visible) {+ return ""+ }return appendSanitizedVisibleDelta(builder, visible)}diff --git a/internal/ai/chat/agentic_sanitize_test.go b/internal/ai/chat/agentic_sanitize_test.goindex 8ff20e9eb1..f423f4f9c5 100644--- a/internal/ai/chat/agentic_sanitize_test.go+++ b/internal/ai/chat/agentic_sanitize_test.go@@ -231,8 +231,8 @@ func TestAppendVisibleContentBeforeToolLeak_ClearsCompactedPreludeWhenSplit(t *tif leakFound {t.Fatal("first compacted chunk should not be classified as a tool leak by itself")}- if delta != first || builder.String() != first {- t.Fatalf("unexpected first compacted delta=%q builder=%q", delta, builder.String())+ if delta != "" || builder.String() != "" || pending != first {+ t.Fatalf("compacted prelude should be held, got delta=%q builder=%q pending=%q", delta, builder.String(), pending)}delta, leakFound = appendVisibleContentBeforeToolLeak(@@ -248,6 +248,18 @@ func TestAppendVisibleContentBeforeToolLeak_ClearsCompactedPreludeWhenSplit(t *t}}+func TestFlushPendingVisibleContent_DropsCompactedPrelude(t *testing.T) {+ var builder strings.Builder+ pending := "Thisisbadmodelspacingbutitistheactualanswerbecauseitneverturnsintoatoolcall."++ if visible := flushPendingVisibleContent(&builder, &pending); visible != "" {+ t.Fatalf("compacted pending text should stay hidden, got %q", visible)+ }+ if builder.String() != "" || pending != "" {+ t.Fatalf("compacted pending text should not enter builder, got builder=%q pending=%q", builder.String(), pending)+ }+}+func TestAppendVisibleContentBeforeToolLeak_CleansDecorativeSymbolsAcrossChunks(t *testing.T) {var builder strings.Buildervar pending string