mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2640] [Issue]: retry save_lorebook_entry tool writer bypasses the agent write-approval gate #1301
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#1301
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/2640
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Medium — security (unapproved agent write / prompt-injection surface). When
agentWriteApprovalRequired("Review Agent Outputs") is enabled, the retry route gates only the structuredlorebook_updateresult type through approval. The newer tool-basedsave_lorebook_entrywriter writes to the lorebook DB immediately during agent execution with no approval check, so a hallucinating or prompt-injected agent can create/overwrite lorebook entries the user expected to review first.Expected behavior
With "Review Agent Outputs" on, the toggle promises (ChatSettingsDrawer): "Lorebook, summary, character card updates, and reviewable writer-agent outputs wait for your approval." Every agent-driven lorebook write — including
save_lorebook_entrytool calls — should be held as a proposal for approval, not committed inline.Actual behavior
packages/server/src/routes/generate/retry-agents-route.ts—attachRetryLorebookWriterToolContexts(1103–1211) attaches asave_lorebook_entrytool whoseexecuteToolCallcallslorebooksStore.createEntry(1153) /updateEntry(1188) immediately, and it is wired unconditionally at line 2768 with no reference torequireAgentWriteApproval(read at line 2682). The approval flag only gates the structured path (markRetryLorebookResultForApproval, 2850–2856). Dispatch is direct:The same un-gated writer also backs the main generate route:
packages/server/src/services/generation/tool-resolution-runtime.ts:366 createLorebookEntryWriter, wired at line 667 inresolveGenerationTools, which never receives the approval flag. So the gap is codebase-wide, not retry-only.Steps to reproduce
agentWriteApprovalRequired) on a chat.save_lorebook_entry/ lorebook-write tool.save_lorebook_entrytool call.Environment
staging @ 3dc062e2Logs, screenshots, or video
Static source audit, cited to file:line above.
Additional context
Fix sketch: gate both writers behind
requireAgentWriteApproval— the retryattachRetryLorebookWriterToolContextsand the sharedcreateLorebookEntryWriterintool-resolution-runtime.ts. When approval is required, the tool should return a proposal/envelope (mirroringbuildLorebookWriteApprovalProposal/markRetryLorebookResultForApproval) instead of performing the create/update immediately.Regression notes: staging-only new code, not a regression —
main'sretry-agents-route.tscontains none ofattachRetryLorebookWriterToolContexts,save_lorebook_entry, oragentWriteApprovalRequired(the whole approval feature and the tool writer are new on staging). This is an incompleteness in the new approval feature. Found via static audit.Template check
@Romuromylus commented on GitHub (Jun 19, 2026):
Sibling of #2639 — both live in
retry-agents-route.ts. I'm planning to land all of #2639, #2640, #2641, #2642, #2643 in a single agents-subsystem hardening PR.