You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Addresses the 4 remaining high-priority memory leak issues from the
work plan (I-9385-A, I-7046-A, PR-14635, I-7046-C partial).
I-9385-A (CRITICAL, Priority anomalyco#1) — tool/task.ts: call Session.remove()
after extracting subagent task output. This fires the session.deleted
event, which triggers cleanupSessionCaches() in the event-reducer —
freeing all in-memory messages, parts, diffs, permissions, and status
for the subagent session. The task_id in the output becomes a dead
reference; if the LLM tries to resume, Session.get() fails gracefully
and a fresh session is created. Validated: the cleanup infrastructure
already existed but was never invoked for subagent sessions.
I-7046-A (CRITICAL, Priority anomalyco#3) — session/compaction.ts: clear
part.state.output and part.state.attachments when pruning compacted
tool parts. Previously, prune() set time.compacted but left the full
output string in both the DB row and the in-memory store.
toModelMessages already substituted "[Old tool result content cleared]"
for compacted parts — this change aligns stored data with that
behavior, freeing the large strings from memory and disk.
PR-14635 (HIGH, Priority anomalyco#4) — TUI event listener cleanup:
- app.tsx: save the unsubscribe functions returned by all 6
sdk.event.on() calls; call them in a single onCleanup() handler.
Previously, onCleanup was not even imported.
- routes/session/index.tsx: save and clean up the message.part.updated
listener. This component mounts/unmounts during session navigation,
so each navigation previously added a duplicate listener.
- component/prompt/index.tsx: save and clean up the PromptAppend
listener. Same mount/unmount pattern as the session component.
I-7046-C (partial) — the TUI event listener fixes above cover the
most impactful instances of the missing-dispose pattern. A full audit
of all subscribe() call sites remains as follow-up work.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0 commit comments