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.

Surface rejected Assistant fallback metadata

rcourtman4a21a5fb903a
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index bdac8a625a..a8de46cafc 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -448,7 +448,11 @@ leave the transcript without exposing hidden provider/tool metadata.
`provider_fallback`, `failed_provider`, `failed_model`, `next_provider`, or
`next_model` workflow metadata. Once visible output has streamed, Pulse must
also keep the failure on that visible attempt rather than silently changing
- route mid-turn. Provider retry workflow states that include `retry_after_ms`
+ route mid-turn. The frontend must not hide stale/legacy
+ `provider_fallback` metadata if a nonconforming stream supplies it; it must
+ surface a rejected-route workflow status while keeping the selected route
+ unchanged and must not infer a model switch from `next_model`. Provider retry
+ workflow states that include `retry_after_ms`
must render as live countdowns derived from the workflow `started_at`
timestamp while the turn is active, matching OpenCode's visible retry wait
behavior instead of freezing the first retry label.
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
index 58b6a3e805..3e367adeff 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
@@ -1331,7 +1331,7 @@ describe('useChat', () => {
dispose();
});
- it('ignores obsolete provider fallback workflow metadata', async () => {
+ it('surfaces obsolete provider fallback workflow metadata without switching routes', async () => {
const { getFireEvent } = setupWithEventCapture();
const { value: chat, dispose } = withRoot(() =>
useChat({ sessionId: 's', model: 'openrouter:openai/gpt-4o-mini' }),
@@ -1352,6 +1352,23 @@ describe('useChat', () => {
const assistant = chat.messages().find((m) => m.role === 'assistant')!;
expect(assistant.model).toBe('openrouter:openai/gpt-4o-mini');
+ expect(assistant.workflowStatus).toEqual(
+ expect.objectContaining({
+ phase: 'provider_fallback_rejected',
+ message: 'Provider fallback metadata received; selected route unchanged.',
+ }),
+ );
+ expect(assistant.streamEvents).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ type: 'workflow_status',
+ workflowStatus: expect.objectContaining({
+ phase: 'provider_fallback_rejected',
+ message: 'Provider fallback metadata received; selected route unchanged.',
+ }),
+ }),
+ ]),
+ );
expect(assistant.streamEvents).not.toEqual(
expect.arrayContaining([
expect.objectContaining({
@@ -1434,6 +1451,12 @@ describe('useChat', () => {
const assistant = chat.messages().find((m) => m.role === 'assistant')!;
expect(assistant.model).toBe('openrouter:openai/gpt-4o-mini');
+ expect(assistant.workflowStatus).toEqual(
+ expect.objectContaining({
+ phase: 'provider_fallback_rejected',
+ message: 'Provider fallback metadata received; selected route unchanged.',
+ }),
+ );
expect(assistant.streamEvents).not.toEqual(
expect.arrayContaining([
expect.objectContaining({
diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
index c3cb672af6..3d452529f8 100644
--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
@@ -511,7 +511,7 @@ export function useChat(options: UseChatOptions = {}) {
};
const streamModelEventKind = (event: StreamDisplayEvent): StreamDisplayEvent['modelEvent'] => {
- if (event.modelEvent && event.modelEvent !== 'fallback') return event.modelEvent;
+ if (event.modelEvent === 'selected' || event.modelEvent === 'switch') return event.modelEvent;
return 'switch';
};
@@ -949,11 +949,17 @@ export function useChat(options: UseChatOptions = {}) {
const extractWorkflowStatus = (data: unknown): WorkflowStatus | null => {
if (!data || typeof data !== 'object') return null;
const record = data as Record<string, unknown>;
+ const phase = typeof record.phase === 'string' ? record.phase.trim() : '';
+ if (phase === 'provider_fallback') {
+ return {
+ phase: 'provider_fallback_rejected',
+ message: 'Provider fallback metadata received; selected route unchanged.',
+ startedAt: Date.now(),
+ };
+ }
+
const message = typeof record.message === 'string' ? record.message.trim() : '';
if (!message) return null;
-
- const phase = typeof record.phase === 'string' ? record.phase.trim() : '';
- if (phase === 'provider_fallback') return null;
const state = typeof record.state === 'string' ? record.state.trim() : '';
const tool = typeof record.tool === 'string' ? record.tool.trim() : '';
const attempt = positiveNumber(record.attempt);
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index a0d56d75c9..18ce7fad71 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -290,9 +290,7 @@ const hasProviderRouteFailureEvidence = (message: ChatMessage): boolean => {
return (message.streamEvents || []).some(
(event) =>
event.type === 'model_switch' &&
- (Boolean(event.failedModel?.trim()) ||
- event.modelEvent === 'fallback' ||
- event.modelEvent === 'switch'),
+ (Boolean(event.failedModel?.trim()) || event.modelEvent === 'switch'),
);
};
diff --git a/frontend-modern/src/components/AI/Chat/types.ts b/frontend-modern/src/components/AI/Chat/types.ts
index e227c814f2..1f6ca52b55 100644
--- a/frontend-modern/src/components/AI/Chat/types.ts
+++ b/frontend-modern/src/components/AI/Chat/types.ts
@@ -125,7 +125,7 @@ export interface StreamDisplayEvent {
content?: string;
model?: string;
failedModel?: string;
- modelEvent?: 'selected' | 'switch' | 'fallback';
+ modelEvent?: 'selected' | 'switch';
settleUntil?: number;
toolId?: string; // Used to match pending_tool with completed tool
approval?: PendingApproval; // For approval_needed events