mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2991] [Issue]: A throwing lorebook-keeper retry discards all already-computed tracker/CYOA/rewrite results (missing error isolation) #1563
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#1563
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?
Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2991
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
On the retry path, the non-lorebook agents run first and produce results, but those results are only applied to the chat much later. In between, the lorebook-keeper stage runs with no error isolation. If the keeper's DB work throws (a lorebook write error, disk error, etc.), the rejection propagates to the route's single outer catch, which only emits an error event. As a result the apply step is never reached, and every non-lorebook agent that already SUCCEEDED (rewrites, world-state/character/persona/quest/custom trackers, CYOA, illustrator, sprites) is silently dropped — never applied, never saved as run history, never even streamed.
How to reproduce (try it yourself)
You'll see: the SSE stream ends with
type:"error"; the tracker/CYOA/rewrite effects already computed are never applied.Expected: a keeper persistence failure should not discard unrelated, already-successful agent results.
Where it is
packages/server/src/routes/generate/retry-agents-route.ts:3174-3188(unguardedexecuteLorebookKeeperRetriescall) before:3301(persistRetryResults) and:3314(applyRetryResultEffects); throw sources at:2131and:2162. The other stages (executeRetryBatches per-group catch, persistRetryResults per-result catch, applyRetryResultEffects per-result catch) are isolated; only the keeper stage is not.What's happening
executeLorebookKeeperRetries(which includes DB persistence) is sequenced beforeapplyRetryResultEffectsinside one shared try block and is not isolated. Its failure aborts application of unrelated, already-successful results.Suggested fix
Wrap the keeper stage in its own try/catch so a keeper DB failure cannot abort applying the non-lorebook results, AND emit an
agent_errorSSE inside the catch (matching the existing illustrator failure pattern) so a real keeper failure stays visible — important for the keeper-only retry case. Replace the unguarded call at lines 3174-3188:Regression avoided: the literal suggested fix ("continue with an empty entries array", i.e. logger.error-only swallow) would make a genuine keeper failure invisible — in the keeper-only retry case the route would stream a misleading
done. Adding theagent_errorSSE keeps the failure visible. The keeper's return value is consumed only in keeper-only spots that safely no-op on[], and the keeper mutates only per-target context clones, so swallowing leaves no corrupt state.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in merged staging PR #3004.