Repository navigation
Description
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:
- Specify - Architect agent creates specs
- Clarify - Same architect resolves ambiguities
- Implement - Engineer agent writes code
- 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:
- Subagent API - Add optional
resumeSessionIdparameter - Session metadata - Store/expose child session IDs to parent
- Context loading - When resuming, prepend previous child session events to new session
- 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 laterAlternatives Considered
- Manual context injection - Parent could summarize and inject previous work, but loses nuance and adds token overhead
- Session-level resume -
/sessionsworks for whole conversations but not individual subagents - 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
github-actions commentedon Jan 1, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
machinekoder commentedon Jan 23, 2026
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.
machinekoder commentedon Jan 23, 2026
It might be even more powerful to combine this feature with OpenCode's session forking tools.
Steffen025 commentedon Jan 23, 2026
@thdxr - any news regarding this Feature request?
Do you think about implementing it?
github-actions commentedon Mar 26, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.