Skip to content

A reclaimed session tells the client instead of vanishing - #75836

Merged
OutThisLife merged 3 commits into
mainfrom
bb/session-reap-notify
Aug 1, 2026
Merged

A reclaimed session tells the client instead of vanishing#75836
OutThisLife merged 3 commits into
mainfrom
bb/session-reap-notify

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

Three backend paths tear down a live session without the client asking: the idle-TTL reaper, the max_live_sessions LRU cap, and the WS-orphan reap (on by default, 20s after a transport detaches). None of them told anyone. _teardown_session pushed no event, and ws_orphan_reap / lru_evict / idle_timeout appeared nowhere in the desktop or TUI clients.

So a client kept holding a runtime id the backend had already forgotten, and only discovered it by failing a later prompt against a session that no longer existed. Reported as sessions "suddenly lost in the backend" when running several at once — the reclaim is intentional, the silence is what makes it read as data loss.

The backend now broadcasts session.reclaimed with the runtime id, the stored id, and the reason. It broadcasts rather than targets the session, because the reap paths run on background timer threads with no contextvar binding and the WS-orphan case has by definition lost its own transport — a targeted emit would bottom out on stdio and never reach the peer that owns the session. Client-initiated closes (tui_close and friends) stay silent; the client asked for those and already knows.

The desktop drops the cached state for that runtime instead of waiting for a resume to 404, reusing the same dropSessionState primitive the existing dead-tile path already calls, and refreshes the lists whose ended_at moved. The stored row is untouched, so the conversation stays in the sidebar and reopening it resumes from the DB.

No lifecycle change: the eviction guards are as they were, mid-turn / awaiting-approval / still-building sessions remain exempt, and the 20s orphan grace from #38591 is unchanged. This only makes an existing reclaim visible.

The idle-TTL reaper, the LRU cap, and the WS-orphan reap tear down a
live session without the client asking. Nothing was pushed, so a client
kept a runtime id the backend had already forgotten and only found out
by failing a later prompt. Broadcast session.reclaimed with the runtime
id and the reason; client-initiated closes stay silent.
Evict the runtime the backend just reclaimed instead of waiting for a
resume to 404, and refresh the lists whose ended_at moved. The stored
row is untouched, so reopening resumes from the DB.
@OutThisLife
OutThisLife enabled auto-merge August 1, 2026 04:06
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 9824e95

ℹ️ Info

Desktop E2E visual evidence · View test artifacts · View job

2 visual diffs.

inline evidence is publishing...

@OutThisLife
OutThisLife merged commit 4579838 into main Aug 1, 2026
45 checks passed
@OutThisLife
OutThisLife deleted the bb/session-reap-notify branch August 1, 2026 04:11
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
…ap-notify

A reclaimed session tells the client instead of vanishing
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