The idea of an agent orchestrator
I came up with the idea of a simple orchestrator that runs the whole process autonomously.
Some tasks require trying a great many different directions to find a suitable or the best one. With a plain prompt, the agent often keeps stubbornly walking the same two or three paths and never considers the rest. How severe this is depends on the model, but it happens regularly.
OpenCode has no explicit orchestration, but it does have subagents. I wrote a skill where the agent itself takes on the orchestrator role. The core part (simplified):
Loop:
1. Read tree.yaml.
2. Form a queue of attempts from the selected nodes.
3. Launch up to 10 subagents with instructions: goal, parent checkpoint, what to check, response format with a verdict.
4. As soon as a subagent finishes — save the result and launch the next one from the queue.
5. Repeat until a subagent returns solved or all attempts return no_solution.
Tested on hard CTF problems that couldn’t be solved without the orchestrator.
You can also visually analyze which steps were taken, what was done in each of them, and display it as a graph.
Call trees
Examples of call trees from CTF tasks. Each node is one attempt, horizontal bands are waves of parallel subagents.
Time flows from top to bottom. The green line is the path to the flag; yellow nodes are solved, red nodes are no_solution.
Skill instruction
An illustrative listing of the dispatcher contract used by the skill:
# Instruction: research iteration tree
## Dispatcher role
You do not do the research yourself. Your job has three parts:
1. Keep the attempt tree in `tree.yaml` — the source of truth: re-read it in full at every step.
2. Decide which subagents to run **in parallel** and which node each one forks from. Assign `id` before launch so that merging replies is unambiguous.
3. After subagents reply, record the results in `tree.yaml` and in the per-node documents.
Only the dispatcher writes `tree.yaml`: subagents return text. Write only what the subagents returned, including failures.
A subagent receives only the parent's checkpoint:
- the document `docs/<parent>.md` and the paths from the parent's `artifacts` (it reads the files itself);
- for the root (`parent: null`), the checkpoint is the text of `goal` and the paths to the task's input files.
## Launch policy
- **One attempt — one short check**, no more than 10 minutes.
- If it does not fit, split it into several attempts.
- If it exceeds the limit, the node becomes `abandoned` with `reason: timeout` and the slot is freed.
- **No more than 10 subagents at a time.** As soon as one finishes, start the next attempt from `queue` immediately, without waiting for the rest.
- Every subagent must return a verdict:
- `solved` (the success criterion from the prompt is met and a result artifact exists);
- `no_solution` (no solution found, with a reason).
- A reply without a verdict, without an artifact for `solved`, or without a reason for `no_solution`
counts as `no_solution` with `reason` "no verdict/artifact/reason".
- Every subagent works in its own directory `work/<id>/`; paths in `artifacts` are relative to it.
## Cycle
1. Re-read `tree.yaml` in full and the goal's current `status`.
2. Update `queue` in `tree.yaml`: entries `{id, parent, task}`.
- Source — the "Questions for the next step" sections of `done` and `abandoned` nodes, and alternatives from `goal`.
- Questions from an `abandoned` node are attached to its `parent`.
- FIFO order, one entry per `(parent, direction)` pair, no repeated directions.
- New entries go only to the end; an empty queue never refills itself.
3. Launch up to 10 subagents.
- Give each an `id` already assigned in `queue`.
- Give each the parent's checkpoint, a task from `queue`, the success criterion, and the reply format with a verdict.
- A node exists only if the subagent was actually launched.
4. Process completions one at a time.
- Re-read `tree.yaml` and write the reply to `docs/<id>.md`.
- Add or update the node (`status: done`, `outcome` = verdict).
- Only then take the next `id` from `queue`.
- The document is written first, the node last.
- If several finish at once, process them in `id` order as one batch and only then refill the slots.
- Never compress or overwrite node documents.
5. An attempt that hits a dead end or exceeds the time limit:
- Set `status: abandoned`, `outcome: no_solution`, and a `reason`; it counts toward `exhausted`.
- New attempts start only from its `parent`.
- Questions from its document move to `queue` with `parent` = the abandoned node's parent.
6. Repeat until one of two things happens:
- verdict `solved` and the dispatcher has confirmed the result artifact exists →
`goal.status: solved`, `queue` is cleared, no new attempts are launched;
- `queue` is empty, no nodes have status `active`, and every node has `outcome: no_solution` →
`goal.status: exhausted`.
## tree.yaml schema
```yaml
goal: "Select tool X and obtain a reproducible result on inputs Y"
status: open # open | solved | exhausted
max_parallel: 10
attempt_minutes: 10
updated_at: "2026-11-27"
queue: # FIFO: [{id, parent, task}]
- {id: n006, parent: n002, task: "Try a third preprocessing of Y."}
attempts:
- id: n001
parent: null
task: "Install and configure tool X, prepare inputs Y."
summary: "Installed and configured tool X, prepared inputs Y."
status: done
outcome: no_solution
artifacts: ["configs/x.yaml", "data/y.csv"]
detail: docs/n001.md
- id: n002
parent: n001
task: "Run Y through X and compare with the reference."
summary: "Result differs from the reference by 12%."
status: done
outcome: no_solution
reason: "The 12% gap is above the threshold."
artifacts: ["results/x-run1.json"]
detail: docs/n002.md
- id: n003
parent: n002
task: "Tune X parameters and measure the gap."
summary: "Three configurations did not move the result — dead end."
status: abandoned
outcome: no_solution
reason: "The error reproduces on every configuration; likely a limit of the input format."
artifacts: []
detail: docs/n003.md
- id: n004
parent: n001 # n002 and n004 are parallel attempts from n001
task: "Try alternative Z on the same inputs."
summary: "Higher quality, but twice the cost — rejected."
status: done
outcome: no_solution
reason: "Twice the cost exceeds the limit."
artifacts: ["results/z-run1.json"]
detail: docs/n004.md
- id: n005
parent: n001
task: "Run Y through X with different preprocessing."
status: active
outcome: pending
```
- The tree consists only of `goal`, `queue`, and `attempts`.
- There is no separate list of directions: a direction is defined by the text of `task`.
- A node with status `active` contains only `id`, `parent`, `task`, `status`, and `outcome: pending`; the other fields are filled in on completion.
- `summary` is 1–3 sentences in the past tense: the direction, the result, and the reason for `no_solution`; guesses and plans belong in `detail`.
- `artifacts` is the single source of truth for a node's files.
- Node `status` — `active | done | abandoned`.
- Node `outcome` — `pending | solved | no_solution`.
- `reason` is required for `no_solution` and `abandoned`.
## Node document template
```markdown
# Attempt n004
- Parent: n001
- Task: try alternative Z on the same inputs Y
- Status: done
- Verdict: no_solution
- Reason: twice the cost exceeds the limit
## Input
The goal, the parent's checkpoint, and the constraints given to the subagent.
## What was done
Commands, files created and modified, runs — facts only.
## Results
Numbers, findings, conclusions. No guesses, no "probably".
## Problems
Where it got stuck. If the node was abandoned — why.
## Files left
Paths from the node's `artifacts` in `tree.yaml`, nothing added.
## Questions for the next step
What to check next and which node to fork from. For `abandoned`, the questions are addressed to the parent, not to the node itself.
```agent-tree-instruction.md