Skip to content

agents: a launched chat is snapshotted at birth, so a backend crash cannot lose a chat the user has not typed into yet - #145

Open
kai-openswarm wants to merge 1 commit into
openswarm-ai:devfrom
kai-openswarm:fix/respawn-parked-sessions
Open

agents: a launched chat is snapshotted at birth, so a backend crash cannot lose a chat the user has not typed into yet#145
kai-openswarm wants to merge 1 commit into
openswarm-ai:devfrom
kai-openswarm:fix/respawn-parked-sessions

Conversation

@kai-openswarm

Copy link
Copy Markdown

What

A chat you open and have not typed into yet lived only in memory until its first turn ended (the turn snapshot), the chat was closed, or the backend shut down gracefully (persist_all_sessions). After a crash or SIGKILL the respawned backend had no file to promote into the dashboard's list; with the renderer's own memory gone too (app restart, window reload) the board came back without the card, and the debounced layout save persisted the loss. A normal quit kept the same chat.

AgentLaunch.launch_agent now writes the same snapshot the turn end writes, right after the session is created. A respawn finds it (reconcile_on_startup marks it stopped, the card returns as the parked chat it was) — exactly what a graceful shutdown already gave it. One atomic JSON write per launch.

Reproduced / verified

  • On a packaged 1.7.7 build: open a chat, kill the backend, let the app respawn it, reload the window → dashboardLayout.cards is []. With this change the card is back. Same app, same steps, only AgentLaunch.py swapped.
  • backend/tests/test_launch_snapshots_session_at_birth.py (2 tests): the file exists at birth with the right dashboard id; a session map emptied as a respawned backend's would be still lists the parked session for its dashboard. Both fail without the change.
  • e2e/tests/parked-chat-survives-backend-crash.spec.ts: kills the packaged backend for real, waits for the app's own respawn, reloads, expects the card. No provider key needed.
  • Existing suites unaffected: launch/session-list/wipe tests green.

…annot lose a chat the user has not typed into yet

Until its first turn ended (the turn snapshot), the chat was closed, or the
backend shut down gracefully (persist_all_sessions), a launched session lived
only in memory. After a crash or SIGKILL the respawned backend had no file to
promote into the dashboard's list; with the renderer's own memory gone too
(app restart, window reload) the board came back without the card, and the
debounced layout save persisted the loss. A normal quit kept the same chat.

Reproduced on 1.7.7 with the packaged app: open a chat, kill the backend, let
it respawn, reload -> cards []; with this change the card is back. Launch now
writes the same snapshot the turn end writes, so a respawn finds the session
(reconcile_on_startup marks it stopped, the card returns as the parked chat it
was). One atomic JSON write per launch. Backend tests cover the file at birth
and the respawned list; an e2e spec kills the packaged backend for real.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant