Skip to content

[FEATURE]: Agent-level resume for subagents (resumeSessionId parameter) #6584

Closed

Description

@Steffen025

Problem Statement

When building multi-phase agent workflows, there's currently no way to resume a specific subagent with its previous context. Each Task/subagent invocation starts fresh.

Use Case

Complex workflows like specification-driven development have multiple phases:

  1. Specify - Architect agent creates specs
  2. Clarify - Same architect resolves ambiguities
  3. Implement - Engineer agent writes code
  4. Validate - Same engineer runs tests

Currently, the engineer in step 4 has no memory of what they implemented in step 3. The context is lost between invocations.

Proposed Solution

Add an optional resumeSessionId parameter to subagent invocation:

// First call - returns session ID
const result = await invokeSubagent({
  agent: "engineer",
  task: "Implement the auth system based on these specs..."
});
// result.sessionId: "xyz789"

// Later - resume with full context
const continued = await invokeSubagent({
  agent: "engineer", 
  task: "Now add tests for the auth system you just built",
  resumeSessionId: "xyz789"  // Load previous session context
});

Technical Considerations

What would need to change:

  1. Subagent API - Add optional resumeSessionId parameter
  2. Session metadata - Store/expose child session IDs to parent
  3. Context loading - When resuming, prepend previous child session events to new session
  4. Session lifecycle - Make child sessions persistent and queryable by parent

Current architecture (from my understanding):

# Parent session
~/.opencode/sessions/abc123.jsonl

# Child session (ephemeral)
~/.opencode/sessions/xyz789.jsonl  # Currently no way to reference later

Alternatives Considered

  1. Manual context injection - Parent could summarize and inject previous work, but loses nuance and adds token overhead
  2. Session-level resume - /sessions works for whole conversations but not individual subagents
  3. Longer initial prompts - Include everything upfront, but context windows have limits

Additional Context

This came up while migrating PAI (Personal AI Infrastructure) to run on OpenCode. PAI's Task tool has a resume parameter that enables stateful agent workflows.

Related: Issue #6558 (model selection for subagents) - similar pattern of adding optional Task parameters.

Happy to help with implementation if this is something the team is interested in!

Activity

  1. github-actions commented on Jan 1, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. machinekoder commented on Jan 23, 2026

    @machinekoder

    Reading this paper about „Recursive LM“ https://arxiv.org/abs/2512.24601 suggests splitting LM sessions into smaller chunks improves overall performance on research intensive tasks. Being able to continue subagent sessions would mean the main agent could outsource such tasks completely, imagine the subagent (or a user session) explored the communication patterns between two frameworks. The main agent could just ask follow up questions without wasting additional tokens and polluting its own context window.

  3. machinekoder commented on Jan 23, 2026

    @machinekoder

    It might be even more powerful to combine this feature with OpenCode's session forking tools.

  4. Steffen025 commented on Jan 23, 2026

    @Steffen025
    Author

    @thdxr - any news regarding this Feature request?
    Do you think about implementing it?

  5. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions