mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1193] [MERGED] Surface failed agents in generation hot path #4969
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4969
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1193
Author: @Romuromylus
Created: 5/25/2026
Status: ✅ Merged
Merged: 5/25/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/surface-failed-agents📝 Commits (3)
bdc18adSurface failed agents in generation hot path72ce2d8Merge branch 'refactor' into fix/surface-failed-agents26cfb46Scope retryAgents failure clear to retried types only📊 Changes
2 files changed (+32 additions, -3 deletions)
View changed files
📝
src/features/runtime/generation/hooks/use-generate.ts(+22 -3)📝
src/shared/stores/agent.store.ts(+10 -0)📄 Description
Why this change
Closes #1192.
When an agent generation fails (provider 4xx, timeout, malformed output, anything that sets
result.success: false), the failure is invisible in the UI. The existing empty-state panels render and no toast, badge, or retry surface appears. The store fields and UI consumers for failed agents already exist (failedAgentTypes,failedAgentFailures, the amber dot on the Agents nav button,RoleplayHUDActionsMenu's retry block,use-chat-timeline-actionsretry handler) but nothing in the per-turn hot path ever populated them.applyAgentResultEffectswouldaddResultto the per-agent map, then short-circuit on!result.successbefore any failure surface was touched. The only caller ofclearFailedAgentTypeswas theretryAgentsflow, so the arrays stayed empty in normal usage.This wasn't a regression — the gap has been there since the failure-arrays plumbing was added. The #1191 avatar-bloat fix removed one common trigger for silent agent failures, but the silent-failure shape itself stays open for any future cause (rate limits, auth errors, timeouts, malformed output), so closing the gap now keeps the original report from drifting.
What changed
src/shared/stores/agent.store.ts: addaddFailedAgentFailure(failure)action. Dedupes byagentTypeso the same agent failing again on a later turn or a re-retry replaces the prior entry instead of stacking.src/features/runtime/generation/hooks/use-generate.ts:applyAgentResultEffects, push the failure before the early return on!result.success. UsestoAgentFailurefromshared/lib/agent-failures.tssoreasonLabel("Context limit", "Timeout", "Rate limit", "Authentication", ...) is classified from the provider error string, which is what the retry block uses for human-readable copy.runGenerationWithUi, clear the failed-agent arrays at turn start so stale failures don't bleed across turns.retryAgents, replace the after-loopclearFailedAgentTypes()with a scoped clear at the top. IfagentTypesis provided, only entries whoseagentTypeis in that set are removed — the rest stay visible. IfagentTypesis omitted (full retry), keep the existing full clear. This matters for the per-agent rerun buttons (illustrator/cyoa/lorebook-keeper/per-tracker) called fromGameSurface,CyoaChoices,ChatSettingsDrawer,SecretPlotPanel,ContextInjectionPanel, anduse-tracker-rerun: a successful targeted retry now leaves prior-turn failures for other agents visible instead of wiping them. The "Retry Failed Agents" all-button case (use-chat-timeline-actions.ts:377, passes the fullfailedAgentTypes) is functionally equivalent under either clear scope.No UI work required — the existing consumers (
PanelNavButtonsbadge,RoleplayHUDActionsMenuretry section,use-chat-timeline-actionshandleRetryFailedAgents) all read from the store and react automatically.Verification
pnpm checkpasses locally (architecture + frontend TS + cargo check + docs check).pnpm dev+ Vite atlocalhost:1420): injected synthetic failures viauseAgentStore.getState().addFailedAgentFailure(toAgentFailure({...}))forcharacter-tracker(prompt-too-long),world-state(timeout), andillustrator(rate limit). Confirmed dedupe byagentTypeworks,reasonLabelresolves correctly ("Context limit", "Timeout", "Rate limit"), and the amber failed-agent dot lights up on the Agents nav button. Then simulated a targeted retry of["illustrator"]: the scoped-clear filter removed only the illustrator entry and the remaining two failures + the dot stayed visible. Untargeted retry (noagentTypes) clears everything as before.clearFailedAgentTypes()resets both arrays and the dot disappears.pnpm tauri dev: the real end-to-end repro path (trigger an actual provider failure in the desktop shell and confirm the retry block + retry button work). Will run that pass before promoting this PR out of draft.Risk
applyAgentResultEffects, which is shared by chat / roleplay / game modes. Only adds a store write on the already-existing failure short-circuit, so behavior for successful results is unchanged.retryAgentsclear semantics changed from "always clear everything before the retry" to "scoped clear" when a targetedagentTypeslist is supplied. This is a behavior change for the per-agent rerun buttons, but it's the intended one — without it, a successful targeted retry would hide prior-turn failures for agents that weren't even re-run.agentTypeinaddFailedAgentFailureoverwrites a prior entry of the same type. The current agent runtime is one-per-type per turn, so this is correct; if a future change ever fans out per-character trackers under a single type, the dedupe would need to switch to a composite key.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.