Skip to content

feat(opencode): add task-parallel tool to fan out independent subtasks concurrently - #47107

Closed
everest-an wants to merge 1 commit into
anomalyco:devfrom
everest-an:agent-task-parallel
Closed

everest-an wants to merge 1 commit into
anomalyco:devfrom
everest-an:agent-task-parallel

Conversation

@everest-an

@everest-an everest-an commented Sep 3, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #47105

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This adds a task-parallel tool 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 task tool already supports background=true async subagents, and BackgroundJob forks each job into its own scope, so parallel execution is technically possible today - but the model has to orchestrate it by hand (issue multiple task calls 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-parallel makes 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 task tool - deriveSubagentSessionPermission for permissions, sessions.create with parentID, and ops.prompt from ctx.extra.promptOps to drive the subagent to completion. A subtask that fails is reported as error in 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 via Effect.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 typecheck in packages/opencode passes.
  • bun test test/task-parallel.test.ts passes (6 pass / 0 fail).
  • Manually reviewed the ops.prompt call against the task tool's own runTask to make sure the subagent invocation is identical.

Screenshots / recordings

N/A - no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@everest-an

Copy link
Copy Markdown
Author

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.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

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:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: add task-parallel tool to fan out independent subtasks concurrently

1 participant