[GH-ISSUE #1192] Silent agent failures: applyAgentResultEffects never surfaces failed agents to UI #589

Closed
opened 2026-10-20 17:30:31 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Romuromylus on GitHub (May 25, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1192

Originally assigned to: @Romuromylus on GitHub.

Symptom

When agent generations fail (any reason: 4xx from provider, timeout, malformed output), the failure is invisible in the UI. The user sees the existing empty-state panels ("No agent activity yet" / "No tracker data yet") with no error indication, no toast, no failed-agent badge.

Where the gap is

applyAgentResultEffects in src/features/runtime/generation/hooks/use-generate.ts short-circuits on !result.success:

agentStore.addResult(result.agentId || result.agentType, result);

if (!result.success) return;   // drops out before any error surface
const bubble = formatAgentBubble(result, agentName);
if (bubble) agentStore.addThoughtBubble(...);

Meanwhile agent.store.ts already defines a surface for failed agents:

  • failedAgentTypes: string[]
  • failedAgentFailures: AgentFailure[] (carries error + reasonLabel)
  • setFailedAgentTypes / setFailedAgentFailures setters
  • clearFailedAgentTypes clearer

And the UI already consumes them - RoleplayHUDActionsMenu and ChatSettingsDrawer both render a failed-agent block with a retry button when these arrays are non-empty.

The setters are defined and the UI is wired, but nothing in the per-turn hot path ever calls them. The only caller of clearFailedAgentTypes is the retryAgents flow. So failed agents from a normal generation never populate the store, and the failed-agent UI never lights up.

Concrete repro (from #1188)

  1. Import a pre-refactor profile with a chat whose tracker characters have inlined base64 avatar data URLs (or any state that pushes agent prompts past the provider ceiling).
  2. Open the chat, send a message.
  3. Watch the console: every tracker agent returns Provider returned HTTP 400 Bad Request: prompt is too long: ...
  4. UI shows the empty-state panels exactly as if nothing had happened.

That bug was hard to spot because the failure surface was invisible. The token-bloat fix in #1191 removes the trigger for that specific class, but the same silent-failure path exists for any future cause of agent failure.

Suggested fix shape

In applyAgentResultEffects, after addResult and before the !result.success early return, append to the failed-agent arrays so the UI lights up the existing failed-agent block.

Considerations:

  • The arrays need clearing somewhere consistent - likely clearFailedAgentTypes at the start of each generation (in runGenerationWithUi), to avoid stale failures persisting across turns.
  • Existing AgentFailure shape carries error + reasonLabel; reasonLabel would ideally classify by provider-error class (prompt_too_long, rate_limited, auth, unknown) so the UI can hint at remediation without exposing raw provider strings.
  • The retry button on the existing failed-agent block already wires into retryAgents, so no UI work needed beyond the store call.

Not a regression - this gap has existed since the failure-arrays plumbing was added. Filing now so it does not drift after #1191 lands.

Originally created by @Romuromylus on GitHub (May 25, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1192 Originally assigned to: @Romuromylus on GitHub. ## Symptom When agent generations fail (any reason: 4xx from provider, timeout, malformed output), the failure is invisible in the UI. The user sees the existing empty-state panels ("No agent activity yet" / "No tracker data yet") with no error indication, no toast, no failed-agent badge. ## Where the gap is `applyAgentResultEffects` in `src/features/runtime/generation/hooks/use-generate.ts` short-circuits on `!result.success`: ```ts agentStore.addResult(result.agentId || result.agentType, result); if (!result.success) return; // drops out before any error surface const bubble = formatAgentBubble(result, agentName); if (bubble) agentStore.addThoughtBubble(...); ``` Meanwhile `agent.store.ts` already defines a surface for failed agents: - `failedAgentTypes: string[]` - `failedAgentFailures: AgentFailure[]` (carries `error` + `reasonLabel`) - `setFailedAgentTypes` / `setFailedAgentFailures` setters - `clearFailedAgentTypes` clearer And the UI already consumes them - `RoleplayHUDActionsMenu` and `ChatSettingsDrawer` both render a failed-agent block with a retry button when these arrays are non-empty. The setters are defined and the UI is wired, but nothing in the per-turn hot path ever calls them. The only caller of `clearFailedAgentTypes` is the `retryAgents` flow. So failed agents from a normal generation never populate the store, and the failed-agent UI never lights up. ## Concrete repro (from #1188) 1. Import a pre-refactor profile with a chat whose tracker characters have inlined base64 avatar data URLs (or any state that pushes agent prompts past the provider ceiling). 2. Open the chat, send a message. 3. Watch the console: every tracker agent returns `Provider returned HTTP 400 Bad Request: prompt is too long: ...` 4. UI shows the empty-state panels exactly as if nothing had happened. That bug was hard to spot because the failure surface was invisible. The token-bloat fix in #1191 removes the trigger for that specific class, but the same silent-failure path exists for any future cause of agent failure. ## Suggested fix shape In `applyAgentResultEffects`, after `addResult` and before the `!result.success` early return, append to the failed-agent arrays so the UI lights up the existing failed-agent block. Considerations: - The arrays need clearing somewhere consistent - likely `clearFailedAgentTypes` at the start of each generation (in `runGenerationWithUi`), to avoid stale failures persisting across turns. - Existing `AgentFailure` shape carries `error` + `reasonLabel`; `reasonLabel` would ideally classify by provider-error class (`prompt_too_long`, `rate_limited`, `auth`, `unknown`) so the UI can hint at remediation without exposing raw provider strings. - The retry button on the existing failed-agent block already wires into `retryAgents`, so no UI work needed beyond the store call. Not a regression - this gap has existed since the failure-arrays plumbing was added. Filing now so it does not drift after #1191 lands.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#589
No description provided.