You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched existing issues and did not find a duplicate.
I can explain the user problem this solves, not just the implementation I prefer.
Problem to solve
With defer_until_idle (from #504 / PR #654), the reconciler can delay draining an active session — but when the grace timeout expires, it still force-drains. For sessions where context continuity matters (crew-owner sessions with a human attached, long-running coordination agents like mayor), a forced drain loses accumulated context that is expensive or impossible to reconstruct.
There is currently no way to tell the reconciler "drain this session, but preserve its context first."
When the reconciler decides to drain a session with drain_policy = "handoff":
Trigger gc handoff on the session instead of a bare drain+stop
The session dumps its context (conversation state, in-progress work references) before terminating
On restart, the new session can recover from the handoff artifact
This extends the guard-clause pattern established by immediate and defer_until_idle but requires new plumbing: the reconciler must orchestrate a handoff before proceeding with the drain, rather than simply skipping or proceeding.
Alternatives considered
defer_until_idle with long grace timeout: Delays the problem but doesn't solve it — eventually the timeout fires and context is lost anyway.
Prompt injection signaling imminent drain: Wastes context every turn for a rare event, requires session cooperation.
Scope and impact
Reconciler: Third branch in the config-drift and idle-timeout drain guards (alongside immediate and defer_until_idle). Calls gc handoff instead of proceeding directly to drain.
Config schema: New enum value handoff for drain_policy. Additive — no migration.
Before you continue
Problem to solve
With
defer_until_idle(from #504 / PR #654), the reconciler can delay draining an active session — but when the grace timeout expires, it still force-drains. For sessions where context continuity matters (crew-owner sessions with a human attached, long-running coordination agents like mayor), a forced drain loses accumulated context that is expensive or impossible to reconstruct.There is currently no way to tell the reconciler "drain this session, but preserve its context first."
Proposed change
Add a third
drain_policyvalue:handoff.When the reconciler decides to drain a session with
drain_policy = "handoff":gc handoffon the session instead of a bare drain+stopThis extends the guard-clause pattern established by
immediateanddefer_until_idlebut requires new plumbing: the reconciler must orchestrate a handoff before proceeding with the drain, rather than simply skipping or proceeding.Alternatives considered
defer_until_idlewith long grace timeout: Delays the problem but doesn't solve it — eventually the timeout fires and context is lost anyway.Scope and impact
immediateanddefer_until_idle). Callsgc handoffinstead of proceeding directly to drain.handofffordrain_policy. Additive — no migration.[agent.lifecycle]infrastructure from PR fix: reject named_session entries referencing pool agents (#574) #654 (feat: per-agent drain policy in session templates #504). This issue only makes sense if that direction lands.gc handoffintegration: The handoff command already exists; this wires it into the reconciler's drain path.Blocked by: #504 (PR #654)