mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2296] [Issue]: Deleting a chat orphans its agent-runs and agent-memory rows (storage bloat; main cleaned them on delete) #1132
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#1132
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 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2296
Originally assigned to: @Xelvanis on GitHub.
Summary
Deleting a chat cascades messages, swipes, tracker snapshots, gallery, and scene memories, but never clears that chat's agent-runs / agent-memory rows. Those live in a separate chatId-keyed store, so they are orphaned and accumulate per deleted chat. Main deleted them on chat remove.
Expected behavior
Deleting a chat (or chat group) should also remove that chat's agent-runs and agent-memory rows, so no per-chat agent bookkeeping is left behind.
Actual behavior
Agent-runs and agent-memory rows keyed by the deleted chat's id survive deletion and are never garbage-collected, growing monotonically as storage bloat. Active chats are unaffected (orphans are inert), so the impact is storage growth that scales with how many chats a user deletes and how active their agents were.
Steps to reproduce
agent-runsandagent-memoryentries keyed by that chat id remain.Impact area
Environment
f56a3774(compared against main @b4ab97fb)Logs, screenshots, or video
n/a (static source comparison of main vs refactor)
Regression notes
Worked in main. Main
packages/server/src/services/storage/chats.storage.ts:411-412(inremove()) deletesagentRunsandagentMemorybychatId(and again at:427-428inremoveGroup). Refactorsrc-tauri/src/commands/storage/chats.rs:1120-1147(delete_chat_with_messages) cascades tracker snapshots (:1138), gallery (:1140), message rows + swipes (:1141), and scene memories/refs (:1130-1131), then deletes the chat row (:1144), but never callsclear_agent_runs_and_memory_for_chat(src-tauri/src/commands/storage/agents.rs:329-368). That cleanup is reachable only via the standaloneagent_runs_clear_for_chatcommand, which the TS side calls only from the roleplay "reset world state" button (RoleplayHUD.tsx:205), never from deletion. Agent-runs/agent-memory are stored in separateagent-runs/agent-memorycollections keyed by chat id (agents.rs:350-356), so they survive the chat-row delete. The chat-delete flow isuseDeleteChat->storageApi.delete("chats", id)-> Ruststorage_delete(entities.rs:730) ->delete_chat_with_messages.Additional context
Call
clear_agent_runs_and_memory_for_chatfromdelete_chat_with_messages(and the group-delete path) so agent bookkeeping is cleaned alongside the other cascaded dependents.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: