Repository navigation
Description
Describe the feature or problem you'd like to solve
The session management tools can create, list, message, rename and close sessions, but an agent can't bring a persisted session back, and neither an agent nor the user can put a live session aside to free its resources and resume it later.
Proposed solution
Add two tools to the session management suite, governed by sessionManagementTools like the others:
resume_session reopens a persisted session that isn't live (closed, suspended, or ended when the CLI restarted) by ID or name, with an optional initial prompt.
- It keeps the session's conversation, model, agent mode and allow-all state, as
/resumeand--resumedo, and accepts the same overrides ascreate_session. - It returns the live session ID, so the caller can message, rename or close it.
- It completes the existing tools:
close_sessionkeeps history, but no tool can reopen that history.
suspend_session takes a live session out of memory and keeps everything needed to resume it.
- It stops the session at the next safe point (after its current tool call, or once it is idle) and saves its state.
- It releases the session's resources, such as memory, background shells and its runtime slot.
list_sessionsand the Sessions sidebar show the session as suspended.resume_session,/resumeor--resumebrings it back.- It follows the same ownership rule as
close_session: sessions this session created and their descendants. A user action can suspend any session.
In the Sessions sidebar, add a suspend action to each session card, alongside the close button that sidebar.showCloseButton enables.
- Show suspended sessions as dimmed cards with a resume action.
- Users often keep sessions they want to come back to but no longer need running. Suspending them frees resources without losing their place or reaching for
/resumeand a session ID later. sidebar.showResumableSessionsalready restores remembered sessions on relaunch; suspend gives the same benefit within a running CLI.
Example prompts or workflows
- A coordinator agent: "Suspend every worker whose pull request is only waiting on review, and resume each one when its PR gets a new comment."
- Under memory pressure, before a reboot: "Suspend all idle sessions." After the restart: "Resume the coordinators first, then their workers in batches of three."
- A user parks a long investigation from the sidebar at the end of the day, then resumes it from the same card the next morning.
- After the CLI restarts, a coordinator resumes the sessions it created without the user running
copilot --resume <id>once per session.
Additional context
- We run one coordinator session that drives about 30 peer sessions through
create_sessionandsend_session_messageon one macOS machine (CLI 1.0.115). - The single CLI process hosting those sessions grew to about 23 GB, and the kernel reported sustained memory pressure. The only relief was a full reboot, because nothing could release idle sessions short of closing them for good.
- After the reboot, the coordinator had no tool to reopen the sessions it had been managing. As a workaround, it ran AppleScript to open a Terminal window per session, running
copilot --resume <id> -i "<prompt>". That works only on macOS, opens windows on the user's desktop without asking, and starts a separate CLI process for every session.resume_sessionwould do this through the same permission and scope model as the other session tools. - Suspend is different from close: it states the intent to return, and the session stays visible as resumable instead of disappearing from the sidebar and
list_sessions.
🤖 Agent-authored by GitHub Copilot CLI · Model: Claude Opus 5.5
Activity