Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(opencode): mark a subagent's end on every close path
João Matheus9baae1e24b45
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rsindex 63f4bb8e..4ede877f 100644--- a/crates/ai-memory-cli/src/commands/install_hooks.rs+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs@@ -5202,8 +5202,12 @@ function startSession(id: string | undefined, cwd: string, extra: Record<string,function endSession(id: string | undefined, directory: string, cwd?: string, extra: Record<string, unknown> = {{}}): void {{if (!id || !startedSessions.delete(id)) return;const resolvedCwd = cwd || cwdFor(id, directory);- postHook("session-end", {{ sessionID: id, cwd: resolvedCwd, ...extra }});+ // Every close path marks a subagent's end, the dispose at exit included:+ // an unmarked end leaves the next session a sub-task baton (#755).+ const parent = sessionParents.get(id);+ postHook("session-end", {{ sessionID: id, cwd: resolvedCwd, ...(parent ? {{ agent_id: parent }} : {{}}), ...extra }});sessionCwds.delete(id);+ sessionParents.delete(id);handoffFetches.delete(id);recapFetches.delete(id);preCompactLast.delete(id);