mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2639] [Issue]: text_rewrite stale-edit guard breaks the whole retry result loop, dropping every later agent's persistence #1299
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#1299
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 @Romuromylus on GitHub (Jun 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2639
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Medium — data-loss. In
applyRetryResultEffects, the stale-edit guard for atext_rewriteresult runsbreak, which exits the entirefor (const result of sortedResults)loop instead of skipping only the rewrite. Every result that sorts after thetext_rewriteentry (game/tracker/persona/quest/custom-tracker/lorebook/CYOA/illustrator/sprite) is then never applied, even though those agents already ran and burned tokens.Expected behavior
A stale
text_rewriteresult should be skipped on its own. All other agent results in the same retry batch should still be persisted (DB writes) and rendered (illustrator image generation).Actual behavior
packages/server/src/routes/generate/retry-agents-route.ts:2016— inside the single result loop:The loop body sequentially handles ~11 result types, many of which persist after
text_rewrite:game_state_update,context_injection,character_tracker_update,persona_stats_update(app.db.update),secret_plot,lorebook_update,quest_update(app.db.update),cyoa_choices,custom_tracker_update(app.db.update),image_prompt/illustrator (image generation). The sort only hoistsgame_state_updateto the front, so atext_rewriteresult from a post-processing prose-guardian/continuity agent commonly sits ahead of those — andbreakdrops all of them silently.There is also a false-positive trigger:
currentResponseForRewriteis seeded from the macro-resolvedagentContext.mainResponse, whilecurrentMessage.contentfromchats.getMessageis the raw stored content. A message that legitimately contains literal{{...}}makes resolved ≠ raw, so the guard wrongly reports "edited during retry" and breaks even when nothing was edited.Steps to reproduce
{{...}}text.Environment
staging @ 3dc062e2Logs, screenshots, or video
Static source audit, cited to file:line above.
Additional context
Fix sketch: replace the
breakatretry-agents-route.ts:2016withcontinueso only the stale rewrite is skipped and the unrelated results that follow it still apply. Separately, compare against the raw stored content (or store/compare a resolved baseline on both sides) so a message containing literal{{...}}does not trip the bogus "edited during retry" path.Regression notes: not a regression. The break-exits-whole-loop defect is byte-identical on
main(retry-agents-route.ts:1407, loop opened at1394), so it is long-standing. The only staging-side change is that staging seeds the rewrite baseline from the macro-resolvedmainResponse(line 576) wheremainuses the raw value (line 298) — this widens the{{...}}false-positive window but does not introduce the underlyingbreakdefect. Found via static audit.Template check