Repository navigation
feat(opencode): add task-parallel tool to fan out independent subtasks concurrently - #47107
everest-an wants to merge 1 commit into
Conversation
58b403e to
76b4c5b
Compare
|
Rebased onto latest dev to clear the ~112-commit gap — CI is green and it merges cleanly now. This adds a new builtin tool, so I understand it should go through design review first. If the team is open to the idea I'm happy to adjust scope or design; if it's not the direction you want, feel free to close — I just didn't want to leave it sitting silently. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #47105
Type of change
What does this PR do?
This adds a
task-paralleltool that lets the primary agent fan out a list of 2-5 independent subtasks to concurrent subagent sessions and collect a single combined summary.The
tasktool already supportsbackground=trueasync subagents, andBackgroundJobforks each job into its own scope, so parallel execution is technically possible today - but the model has to orchestrate it by hand (issue multipletaskcalls in one message, then wait for each notification). That's easy to get wrong: the model forgets to wait, or polls, or duplicates work.task-parallelmakes the fan-out explicit: pass a list of subtasks, it launches them all concurrently, waits for every one, and returns one summary.Each subtask runs in its own subagent session using the exact same machinery as the
tasktool -deriveSubagentSessionPermissionfor permissions,sessions.createwithparentID, andops.promptfromctx.extra.promptOpsto drive the subagent to completion. A subtask that fails is reported aserrorin the summary while the others still complete; the wall-clock time is roughly the longest subtask instead of the sum.Changes:
packages/opencode/src/tool/task-parallel.ts(new): the tool. Resolves each subtask's agent + session up front, runs them in parallel viaEffect.forEach(..., { concurrency: "unbounded" }), and renders a combined<parallel-tasks>summary.packages/opencode/src/tool/task-parallel.txt(new): model-facing description (when to use it, how to split tasks, cap at 2-5).packages/opencode/src/tool/registry.ts: register the tool in the builtin tool set.packages/opencode/test/task-parallel.test.ts(new): unit tests for the summary rendering and the parameter schema.How did you verify your code works?
bun run typecheckinpackages/opencodepasses.bun test test/task-parallel.test.tspasses (6 pass / 0 fail).ops.promptcall against thetasktool's ownrunTaskto make sure the subagent invocation is identical.Screenshots / recordings
N/A - no UI change.
Checklist