Skip to content

[FEATURE] Resumable Subagent Sessions (Persistent Multi-Turn Context via Session ID) #7317

Description

@ohcedar

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Claude Code subagents are stateless: each invocation starts with a clean slate, so you can’t “continue” a prior subagent exchange. Any follow-up requires replaying context, which increases latency and token/compute cost. By contrast, the main Claude Code session can be resumed by ID, but that capability doesn’t exist for subagents.

Proposed Solution

Introduce stateful subagent sessions:
• On first invocation, the subagent returns a subagent_session_id.
• Subsequent calls can pass that ID to resume the subagent with full prior turns (messages, tool outputs, scratch state) restored.
• Provide CLI ergonomics (e.g., --agent --agent-resume ) and programmatic APIs to create/continue/close sessions; include TTL, max-turn, and size limits.
This mirrors existing main-session resume semantics while remaining scoped to each subagent.

Alternative Solutions

Replay everything: Re-invoke the subagent with the original prompt plus the new ask. This burns tokens, adds latency, and risks prompt drift or omissions.

Priority

Medium - Would be very helpful

Feature Category

CLI commands and flags

Use Case Example

You’re shipping a feature that spans backend and frontend. You invoke two subagents: backend-specialist and frontend-specialist. After initial outputs, integration breaks.
1. Resume the backend subagent with its subagent_session_id and ask a targeted follow-up; it replies with the fix approach.
2. Resume the frontend subagent with its own subagent_session_id, reference the backend’s answer, and apply the corresponding UI change.
Because both conversations are continued (not restarted), neither subagent has to re-rebuild context, so the loop is faster, cheaper, and more reliable.

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions