mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2990] [Issue]: Retry tool attachment never wires the edit_chat_message tool, so message-editing agents silently lose it on retry #1565
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#1565
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/2990
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The main generation path resolves an agent's full tool set in one pass, including
edit_chat_messagefor agents that enabled it and hold theedit_messagescapability. The retry path instead uses three narrow attach helpers (spotify / chat-metadata / lorebook-write) — none of which know aboutedit_chat_message. So a custom agent that usesedit_chat_messageends up with no tool context on retry, the model is told it has no tools, and its message-editing behavior fails on retry even though it works on initial generation.How to reproduce (try it yourself)
edit_messagescapability and theedit_chat_messagetool (the editor saves the tool into enabledTools only when edit_messages is on). Give it a prompt instructing it to call edit_chat_message.You'll see: on retry,
entry.resolved.toolContextstays undefined, the agent runs with no tool loop, and it cannot edit messages.Expected: same tool availability as initial generation.
Where it is
packages/server/src/routes/generate/retry-agents-route.ts:1262-1268(allow-lists),:3078-3085(only three attach helpers called),:2010-2011(batch-vs-tool split — no toolContext means no tool loop),agent-executor.ts:388(tool loop only when toolContext.tools is non-empty). Main-path comparison:packages/server/src/services/generation/tool-resolution-runtime.ts:692-707(and executor at 631-650).What's happening
The retry tool-context logic was reimplemented as three special-case helpers instead of mirroring the main path's generic per-agent enabledTools resolution.
edit_chat_messagewas simply not added to any allow-list, and no helper injects areplaceChatMessageContentexecutor on retry.Suggested fix
Add a fourth retry attach helper that mirrors the main path's edit_chat_message handling, gated on the
edit_messagescapability, that MERGES into any existing toolContext, and call it LAST (after spotify/metadata/lorebook) so it composes with the others. The helper validates the message belongs to this chat and is user/assistant role (mirroring tool-resolution-runtime.ts:631-650), only attaches when the agent enabled the tool AND hascustomAgentHasCapability(settings, "edit_messages"), and delegates non-edit calls to any pre-existing executor:Then at retry-agents-route.ts:3078-3085, add
await attachRetryEditChatMessageToolContexts({ chats, chatId, resolvedAgents });AFTER the existing three. Regression avoided: do NOT "converge onto the generic resolveGenerationTools" — the three retry helpers carry retry-only behavior (spotify before-play capture used by validateSpotifyRetryPlayback, lorebook write-approval envelopes) and operate on a different shape; converging would break those. The capability gate MUST be preserved so retry doesn't expose message-editing to an agent the initial generation denies, and the helper must run LAST and merge so agents combining edit_chat_message with metadata/spotify tools don't lose those.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.