Preserve independent background sessions through owner shutdown and idle cleanup
This commit is contained in:
+14
-10
@@ -96,8 +96,8 @@ Ordinary notifications are not spooled; the existing thread readback repairs gap
|
||||
|
||||
State is bounded to 128 callbacks / 8 MiB and 256 in-flight client calls, with a
|
||||
16 MiB frame limit. Exceeding pending bounds closes the bridge without granting,
|
||||
declining or otherwise auto-answering an interaction. A detached bridge expires
|
||||
after 20 minutes with no pending interactions, or after 24 hours even if pending.
|
||||
declining or otherwise auto-answering an interaction. A detached bridge keeps its original upstream connection indefinitely by default.
|
||||
Only explicitly supplied positive `-idle`/`-max-detached` limits enable expiry.
|
||||
An upstream App Server restart, a bridge crash, or expiry loses its connection-
|
||||
bound callbacks: no disk JSON can recreate them on a new connection. The initial
|
||||
deployment cannot recover requests already owned by the old direct connection.
|
||||
@@ -161,16 +161,20 @@ The host stops the CLI (EOF, then SIGINT, then SIGKILL to its process group) and
|
||||
removes its files only when one of these happens:
|
||||
|
||||
- The operator closes the chat (`chat_close`).
|
||||
- The server's idle release or live-process cap fires.
|
||||
- A genuinely idle unhosted CLI is released. For hosted sessions, server cache
|
||||
eviction only detaches; the host owns authoritative background-task liveness.
|
||||
- The CLI exits; the server then gets its stderr.
|
||||
- With no server attached, the CLI has been idle for the same 20 minutes, or
|
||||
no server has attached for 24 hours.
|
||||
- With no server attached, the CLI has been genuinely idle for 20 minutes,
|
||||
with no foreground turn, pending interaction, or native background task.
|
||||
There is no default hard detached lifetime limit.
|
||||
|
||||
If the host itself dies, the server first tries to reconnect once. If that fails,
|
||||
it stops the orphaned CLI's process group (only when that pid's command line
|
||||
still names the session) and removes the host files. A running turn ends with
|
||||
the notice "the Claude Code host stopped unexpectedly; the next prompt resumes
|
||||
this session with --resume". The next prompt then resumes the session.
|
||||
If the control connection is lost, the server first tries to reconnect. A verified
|
||||
live host is preserved when its socket is temporarily unavailable, and another
|
||||
CLI is not started alongside it. Dead host recovery verifies process identity
|
||||
before stopping an orphan. On attachment, the host's authoritative task snapshot
|
||||
restores running task identities even after older spool records were trimmed.
|
||||
Legacy hosts without that snapshot remain attached during cache eviction, so
|
||||
their older detached idle timers cannot mistake background work for an idle CLI.
|
||||
|
||||
Limits:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user