GeezerVison is showing github.com — feat(opencode): Support background subagents by tomjw64 · Pull Request #13261 · anomalyco/opencode
Conversation
tomjw64
commented
Feb 12, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #5887
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
The goal of this PR is to support fire-and-forget/async/background tasks in my best approximation of how Claude Code handles it.
This is done by calling SessionPrompt.prompt async and emitting a new BackgroundTaskCompleted event when the promise resolves. The new SessionBackground component listens for these events (and the idle status event) and takes care of flushing the queue of finished task information to the parent session and forcing it to take it a turn with the results of the completed task(s).
This attempts to be a bit more minimal than #7206 to increase the chances of acceptance. I am a first-time contributor to opencode and I almost certainly overlooked something here. I'm happy to receive any suggestions or review.
How did you verify your code works?
I opened opencode and entered the following prompt:
Run 4 general background subagents in parallel. Each one should use bash to
sleep for an amount of time and then print out a random number. Have them sleep
for 10, 18, 18.2, and 18.2 seconds, respectively. Then print out a chart to be
updated as each task notifies you of its completion.
And verified that the agent (tested with Kimi K2.5 Free):
- Could handle additional user interaction before the first subagent completed.
- Woke after the first subagent completed to update the chart.
- Woke a second time after the second subagent completed to update the chart.
- Woke a third and final time after the third and fourth subagents completed (to test that we buffer the results of two completions but still only give the primary agent a single turn once idled again)
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
If you do not follow this template your PR will be automatically rejected.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
reddec, kassieclaire, jensenojs, ivaigult, lukasbesch, yehudacohen, sarendipitee, Gr4ph1xZ, and novascreen reacted with thumbs up emoji
|
The following comment was made by an LLM, it may be inaccurate:
Based on the search results, I found a related PR that may be relevant:
Potential Related PR:
This PR could potentially be a duplicate or overlapping work on the same feature. You may want to review PR #7206 to understand if it was a previous attempt, partially merged, or if #13261 is a reimplementation with different approaches.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tomjw64
commented
Feb 16, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Received some review expressing some concern over task cancellation:
- subagents prompts not cancelled on session delete
- no way of individually cancelling a session in the TUI
We can address (1) in this PR (update: done), but I will open a separate issue for individual issue cancellation (update: done), so that background tasks can be cancelled without e.g. closing out the entire app.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Feb 17, 2026
|
By the love of god, can someone finally just give us parallel subtasks please? Who's supposed to use opencode effectively in its current state?
|
Gr4ph1xZ and Ploppy3 reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I'm trying to understand why background subagents are used in a plugin, if regular subagents in a chat work just fine, and stumbled upon this issue.
How is this different from OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.
— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|