Skip to content

fix(daemon): reconstruct session state for events on unknown sessions#92

Draft
rgao-coreweave wants to merge 1 commit into
mainfrom
fix/daemon-session-reconstruction
Draft

fix(daemon): reconstruct session state for events on unknown sessions#92
rgao-coreweave wants to merge 1 commit into
mainfrom
fix/daemon-session-reconstruction

Conversation

@rgao-coreweave

@rgao-coreweave rgao-coreweave commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

The daemon keeps all session state in memory, seeded only at SessionStart. A Claude Code session that outlives a daemon idle-restart sent its next UserPromptSubmit to a fresh daemon with no record of it, which logged "Unknown session" and silently dropped tracing for the rest of that session (159 such errors over 14 days locally; 52 sessions seen straddling a restart).

Reconstruct the session from the transcript_path carried on every hook event, seeding the turn counter from the turns already on disk so the daemon tolerates its own restarts.

Test plan

  • node --import tsx --test tests/daemon-session-reconstruction.test.ts

The daemon idles out after ~10 min and holds all session state in memory,
seeded only at SessionStart. A Claude Code session that outlives a daemon
restart sends its next UserPromptSubmit to a fresh daemon that never saw its
SessionStart, which logged "Unknown session" and silently dropped tracing for
the rest of that session (159 such errors over 14 days in one local log; 52
distinct sessions observed straddling a restart).

Reconstruct the session from the transcript_path every hook event carries,
seeding the turn counter from the turns already on disk so numbering continues.
Makes the daemon tolerant of its own restarts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor Author

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