Skip to content

fix: dispose session on archive - #177

Merged
maxy-shpfy merged 1 commit into
mainfrom
maxy/fix--dispose-session-on-archive
Nov 18, 2026
Merged

maxy-shpfy merged 1 commit into
mainfrom
maxy/fix--dispose-session-on-archive

Conversation

@maxy-shpfy

@maxy-shpfy maxy-shpfy commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Archiving a session now tears down its live compute instead of leaving Pi processes running in the background. PATCH /api/sessions/:id with archived: true puts the session to sleep: open Runs are cancelled, every Pi agent (Prime + sub-agents) is killed without supervisor respawn, and schedules are disarmed. Live sub-agents are persisted as detached so a later wake can revive them. Unarchiving only re-arms schedules — agents wake lazily on the next message.

  • PiAgentManager.sleep(sessionId) cancels open Runs, quiets each agent so the kill-triggered exit is not reported as an in-flight error, disposes the session, and returns the live sub-agent ids.
  • TriggerEngine.load() registers a session's triggers for listing without arming a schedule; sync() now loads + arms. Joining an archived session loads triggers without waking it.
  • handleUpdateSession now takes SessionUpdateDeps { store, pi, triggerEngine }; applyArchiveState sleeps + disarms on archive and re-arms on unarchive.

Screenshots

N/A — backend only.

How to test

  1. Start a session with Prime and at least one sub-agent running.
  2. PATCH /api/sessions/:id with { "archived": true }.
  3. Confirm the Pi processes exit, open Runs settle as cancelled, live sub-agents persist as detached, and no error event is emitted.
  4. Unarchive and send a message; Prime wakes and detached sub-agents revive.
  5. pnpm --filter @tangent/server test — new coverage in piAgentManager.test.ts ("sleep kills every agent…") and sockets/chat.test.ts (cold wake, live no-op, archived join).

@maxy-shpfy
maxy-shpfy added this pull request to stack #180 November 12, 2026 03:38
@maxy-shpfy
maxy-shpfy removed this pull request from stack #180 November 12, 2026 05:50
@maxy-shpfy
maxy-shpfy force-pushed the maxy/fix--dispose-session-on-archive branch from 1e671f3 to 7dd8abc Compare November 12, 2026 05:52
@maxy-shpfy
maxy-shpfy changed the base branch from maxy/feat--bundle-global-memory to main November 12, 2026 05:52
@maxy-shpfy
maxy-shpfy marked this pull request as ready for review November 12, 2026 07:46
@maxy-shpfy
maxy-shpfy force-pushed the maxy/fix--dispose-session-on-archive branch from 7dd8abc to 761aaaf Compare November 18, 2026 21:07
@maxy-shpfy
maxy-shpfy requested a review from a team as a code owner November 18, 2026 21:07
@maxy-shpfy
maxy-shpfy force-pushed the maxy/fix--dispose-session-on-archive branch from 761aaaf to 5143ff0 Compare November 18, 2026 21:16
@maxy-shpfy
maxy-shpfy merged commit 2c3ae3d into main Nov 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants