Reusable worker sessions: close_agent / resume_agent (CL-6943) - #618
Merged
TheGreatAxios merged 1 commit intoAug 24, 2026
Merged
Conversation
Worker sessions from spawn_agent no longer tear down on a clean completion — they stay open and retained until close_agent runs. close_agent(target) permanently closes a session (descendants first, bounded by a ~30s deadline per session so a wedged descendant cannot hang the call); resume_agent(id) reopens a retained, completed session. A new AgentLifecycleStatus enum (pending_init/running/interrupted/ completed/shutdown/not_found) tracks this independent of the existing TUI display status, and a retained session is exempt from the finished-session display cap until it is actually closed. interrupt_agent and followup_task are a separate, later change.
TheGreatAxios
force-pushed
the
cl-6943-reusable-worker-sessions-interrupt_agent-close_agent
branch
from
August 24, 2026 10:42
387291e to
0c9b554
Compare
TheGreatAxios
enabled auto-merge (squash)
August 24, 2026 10:42
TheGreatAxios
added a commit
that referenced
this pull request
Aug 27, 2026
) Worker sessions from spawn_agent no longer tear down on a clean completion — they stay open and retained until close_agent runs. close_agent(target) permanently closes a session (descendants first, bounded by a ~30s deadline per session so a wedged descendant cannot hang the call); resume_agent(id) reopens a retained, completed session. A new AgentLifecycleStatus enum (pending_init/running/interrupted/ completed/shutdown/not_found) tracks this independent of the existing TUI display status, and a retained session is exempt from the finished-session display cap until it is actually closed. interrupt_agent and followup_task are a separate, later change.
TheGreatAxios
added a commit
that referenced
this pull request
Aug 27, 2026
) Worker sessions from spawn_agent no longer tear down on a clean completion — they stay open and retained until close_agent runs. close_agent(target) permanently closes a session (descendants first, bounded by a ~30s deadline per session so a wedged descendant cannot hang the call); resume_agent(id) reopens a retained, completed session. A new AgentLifecycleStatus enum (pending_init/running/interrupted/ completed/shutdown/not_found) tracks this independent of the existing TUI display status, and a retained session is exempt from the finished-session display cap until it is actually closed. interrupt_agent and followup_task are a separate, later change.
TheGreatAxios
deleted the
cl-6943-reusable-worker-sessions-interrupt_agent-close_agent
branch
August 28, 2026 00:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
close_agent(target): permanently closes a session, descendants closed first, each bounded by a ~30s cleanup deadline so a wedged descendant cannot hang the call.resume_agent(id): reopens a retained, completed session so it is addressable again (no prompt argument — actually pushing new input isinterrupt_agent/followup_task, a separate later change).AgentLifecycleStatus(pending_init | running | interrupted | completed | shutdown | not_found), tracked alongside the existing TUI display status onSubAgentSession.DEFAULT_MAX_COMPLETED = 20) untilclose_agentactually shuts it down.Out of scope (separate lane):
interrupt_agent,followup_task.close_agent/resume_agentwere already reserved inFLEET_VERBS/gated viaassertTierMayMountFleetVerb; leaves cannot mount either.Teardown notes
close()in the vendored agent package setsclosed = truebefore teardown completes and releases its lock last — a failed/wedged close can leave a workdir lock held. Bounding the cleanup deadline here does not fix that (known issue, CL-6984); it only stops a wedged descendant from hanging the caller'sclose_agentcall.Test plan
bun test src/subagent/session-store.test.ts src/subagent/lifecycle-tools.test.ts src/subagent/authority.test.ts src/subagent/agent-fleet.test.ts src/subagent/run-authority.test.tsbun run check(lint/typecheck/build/test) — full suite green except one pre-existing timing-flaky test (tool execution watchdog > stale resume after a forced ceiling resume does not unfreeze a newer pause), unrelated to this change and passes on its own in isolation.scripts/verify-corbits-only-scope.sh