Skip to content

About

Start multiple OpenCode V2 sessions from one and coordinate them in parallel: spawn child sessions, be woken when they report.

Topics

Resources

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

opencode-courier

Start multiple OpenCode V2 sessions from one and coordinate them in parallel.

CI Quality Gate npm Socket Badge License: MIT Supported OpenCode V2 version

A top session fixes two issues in parallel with a lead per issue: a worker's finding wakes its lead mid-run, the lead passes it on, and the sibling rewrites its test, followed in the tree panel

The main case in the /courier tree panel: two issues, a lead per issue, two workers under each. A worker's finding wakes its lead as it comes, the lead passes it on, and the sibling rewrites its test. Each lead's report wakes the top session as it comes.

Quickstart

npm install -g @opencode/[email protected]   # OpenCode V2, the version courier is tested on
opencode plugin add opencode-courier
opencode

Paste this prompt:

Start two helper sessions with courier_spawn and have each report back to you. One runs `sleep 20; echo $((17 * 23))`, the other `sleep 40; echo $((2 ** 10))`. Do not run the commands yourself. When both have reported, reply with one line: RESULTS <first> <second>

The parent starts both children and ends its turn. Each report wakes it, and it replies RESULTS 391 1024. Free models sometimes stall; if nothing moves for a few minutes, send the prompt again.

Why courier

OpenCode's own subagent tool runs a child in the background, wakes an idle parent when the child's turn ends, and shows the child's permission prompts in the top session's view. Use it when a child's final answer is all you need. Courier adds:

  • Messages before a turn ends. A child sends its parent a finding or a question at any time, and each report wakes the parent as it comes. The parent passes a finding on to the children it affects, into their running turns.
  • Reports with a status. A child reports done, partial, blocked or failed, with the branch, commits and checks of its work.
  • Waking an idle session. A message or a schedule starts a new turn.
  • Parallel edits. isolate: true gives a child its own git worktree and branch to merge.
  • Asks reach you. A child's permission requests and questions come to you through the top session. Only you approve a request, in OpenCode's own prompt.
  • Trees. A child may start sessions of its own, within limits you set, with no change to OpenCode's config.

How it works

A parent calls courier_spawn, gets the child's session id at once, and ends its turn. When done or stuck, the child calls courier_send with a status (done, partial, blocked or failed). The message lands in the parent's inbox and starts a new turn if the parent is idle.

Each report wakes the parent as it comes. A child that fails is reported to its parent, with when a rate or quota limit lifts. One about to end its turn without reporting is reminded once, and its parent is told only if it still does not report. A message that does not wake its session is shown as stalled. Children and scheduled messages survive a restart. The courier-orchestrate skill, listed in every session, tells a model how the tools work. A model starts a session only when you ask for one: when to divide a task, and how, is left to you and your own skills. Every detail: the reference.

Install

Requires OpenCode V2: the opencode command from @opencode/cli. Each release is tested against one OpenCode version; this one is tested on OpenCode 2.4.3 (check with opencode --version).

npm install -g @opencode/[email protected]
opencode plugin add opencode-courier

This adds "opencode-courier" to plugins in ~/.config/opencode/opencode.json. Install it by name, without a version: OpenCode offers updates only for an entry without an exact version (updating).

Supported OpenCode version

opencode-courier OpenCode V2 (opencode and @opencode/plugin)
1.2.1 2.4.3
1.1.0, 1.2.0 2.4.2
0.18.5, 1.0.0 2.4.1

Every release: the full table. The server part loads on any V2 host from 2.0.4 on. The terminal part is tested on OpenCode 2.4.3 only.

Options

Set the server options on the plugin's entry in the global config, ~/.config/opencode/opencode.json:

{
  "plugins": [{ "package": "opencode-courier", "options": { "maxDepth": 2, "maxChildren": 3 } }]
}
Option Default
maxDepth 5 How deep a tree goes. Your session is depth 0. A session at maxDepth cannot start sessions.
maxChildren 5 Live children one session may have.
maxTotal 30 Live spawned sessions in one tree.

The terminal part reads its options only from ~/.config/opencode/cli.json, in the same entry form. Its one option, "animations": false, keeps the tree panel still.

Tools

Tool Does
courier_spawn Starts a child session with a task and returns at once. isolate, agent, model, variant, title.
courier_send Messages a session, waking it if idle. With a status, it is a child's report.
courier_tree One look at the whole tree of sessions a session started, directly or through others.
courier_stop Stops a session below you and everything under it.
courier_cleanup Removes an isolated child's worktree and forgets the child.
courier_answer Proposes an answer to a child's permission request, or passes on your answer to its question.
courier_later / courier_cancel Schedules a message for a session, or drops one.

A session that cannot start sessions (one at maxDepth, or an OpenCode subagent in a tree) is offered courier_send, courier_tree, courier_later and courier_cancel only. Parameters and behaviour: the reference.

In the terminal

  • Footer: courier 1 waiting on you · 2 running · 1 idle.
  • /courier tree: a panel with the tree, its root as the first row. enter opens a session, s stops it, q closes.
  • ctrl+x k or /asks: every ask waiting on you in the tree, answered in a dialog.

More: in the terminal.

Tips

  • Keep opencode service start running, so sessions can be woken while you are away. Run one OpenCode server per data directory (why).
  • Allow up front what the work needs, and the question tool if children should ask you. A child's approval prompt waits for you, and the top session's own prompts stall the whole tree (allow bun run * or npm run * and git).
  • Choose a web search provider before children search, or the first one shows you a form.
  • Use isolate: true when children edit files in parallel. The worktree starts from the last commit, so keep providers in the global config or commit opencode.json.
  • To steer a running tree, open a child from the /courier tree panel and type: courier passes what you write to the sessions above it, and tells them if you take it back; a parent with the skill passes it to the parts it changes (details).
  • Schedule a courier_later check-in for a long-running child.

Contributing

Questions go to Discussions, bugs to issues. Pull requests are welcome; start with CONTRIBUTING.md.

License

MIT, see LICENSE.

About

Start multiple OpenCode V2 sessions from one and coordinate them in parallel: spawn child sessions, be woken when they report.

Topics

Resources

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages