Package Exports
- opencode-orchestrator
Readme
OpenCode Orchestrator
Autonomous multi-agent plugin for OpenCode
Overview
Multi-agent system that autonomously executes complex tasks. Commander delegates work to specialized agents, manages parallel execution, and maintains shared context.
| Capability | Detail |
|---|---|
| Agents | 4 consolidated (Commander, Planner, Worker, Reviewer) |
| Parallel Sessions | Up to 50 concurrent Worker Sessions |
| Context Management | .opencode/ with adaptive summarization |
| Memory Safety | Auto GC, disk archiving |
| Error Handling | Pattern-based auto recovery + session recovery |
| Todo Continuation | Auto-continues when todos remain |
| Smart Notifications | TaskToastManager with consolidated views |
ποΈ Master Session Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π€ USER REQUEST β
β "/task Build a REST API" β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π― MASTER SESSION (Commander Agent) β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 1οΈβ£ THINK β Analyze request, assess complexity (L1/L2/L3) β β
β β 2οΈβ£ PLAN β Create .opencode/todo.md via Planner β β
β β 3οΈβ£ DELEGATE β Spawn Worker Sessions via delegate_task β β
β β 4οΈβ£ MONITOR β Watch .opencode/ for progress, handle completions β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Session State β β 4 CONSOLIDATED AGENTS β β
β β Map<id,state> β β π― Commander π Planner β β
β βββββββββββββββββββ β π¨ Worker β
Reviewer β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββ
β β Plugin Hooks β β
β β event β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β chat.message β β π SessionRecovery (auto error handling) β β
β β tool.execute β β π TodoContinuation (auto-resume on idle) β β
β βββββββββββββββββββ β π£ TaskToastManager (consolidated notifications)β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
delegate_task (async)
β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ
β β‘ Worker Session 1 β β β‘ Worker Session 2 β β β‘ Worker Session N β
β Agent: Planner β β Agent: Worker β β Agent: Reviewer β
β β β β β β
β β’ Independent exec β β β’ Independent exec β β β’ Independent exec β
β β’ Read/Write β β β’ Read/Write β β β’ Read/Write β
β .opencode/ β β .opencode/ β β .opencode/ β
β β’ Notify parent β β β’ Notify parent β β β’ Notify parent β
β on complete β β on complete β β on complete β
βββββββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ
β β β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π SHARED CONTEXT (.opencode/) β
β β
β .opencode/todo.md β Master TODO (Planner creates, Reviewer updates) β
β .opencode/context.md β Adaptive context (shrinks as progress increases) β
β .opencode/docs/ β Cached docs (Planner/Worker save, auto-expire) β
β .opencode/archive/ β Old context for reference β
β β
β β‘ All sessions read/write this shared workspace β
β π Progress is tracked via todo.md checkboxes β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββInstallation
npm install -g opencode-orchestratorRestart OpenCode after installation.
Usage
π Two Modes of Operation
| Mode | Trigger | Behavior |
|---|---|---|
| Commander Mode π― | /task "mission" |
Full autonomous execution until sealed |
| Chat Mode π¬ | Regular conversation | Simple Q&A, no autonomous behavior |
π― Commander Mode - /task (Recommended for Real Work)
Use /task when you need the AI to complete a mission autonomously:
/task "Fix the login bug in the docker-compose environment"
/task "Add dark mode support to the entire app"
/task "Refactor the API to use TypeScript"What Commander Mode Does:
- βΎοΈ Runs until sealed β Loops until agent outputs
<mission_seal>SEALED</mission_seal> - π§ Anti-Hallucination β Researches docs before coding
- β‘ Parallel Execution β Up to 50 concurrent agents
- π Auto-Recovery β Handles errors automatically
- π Triage System β Adapts strategy to complexity (L1/L2/L3)
ποΈ Mission Seal Loop:
/task "mission" β Agent works β Idle? β Seal found?
β β
β No β Yes
ββββββββββββββββ΄βββ β
CompleteWhen the agent finishes ALL work, it outputs:
<mission_seal>SEALED</mission_seal>Control Commands:
/stopor/cancelβ Stop the loop manually- Max 20 iterations (configurable)
/task "mission" triggers full Commander mode with Mission Seal loop
π¬ Chat Mode - Regular Conversation (Simple Q&A)
Just type normally without /task for simple questions:
How do I add a loading spinner?
What's the difference between useState and useReducer?Chat Mode is just regular conversation β no autonomous execution, no parallel agents, no mission tracking.
π‘ Pro Tip: Use
/taskfor anything that requires multiple steps, file changes, or verification. Use Chat Mode for quick questions.
The 7 Agents
| Agent | Role | Responsibility |
|---|---|---|
| Commander π― | Orchestrator | Autonomous mission control |
| Planner π | Planner + Research | Task decomposition, research, caching docs |
| Worker π¨ | Developer + Docs | Full-stack implementation, documentation |
| Reviewer β | Quality + Context | Verification, TODO updates, context management |
π οΈ Available Tools
| Tool | Description |
|---|---|
delegate_task |
Delegate work to subagent (async/sync) |
get_task_result |
Get result from delegated task |
list_tasks |
List all running/completed tasks |
cancel_task |
Cancel a running task |
webfetch |
Fetch URL content as Markdown |
websearch |
Search web (SearXNG β Brave β DuckDuckGo) |
codesearch |
Search open source code patterns |
cache_docs |
Manage cached documentation |
run_background |
Run command in background |
check_background / list_background |
Monitor background jobs |
grep_search / glob_search / mgrep |
Fast file search |
π Resource Guarantees
| Resource | Limit | Safety Mechanism |
|---|---|---|
| Parallel Sessions | 50 | Queue overflow protection |
| Tasks in Memory | 1,000 | Auto GC + disk archive |
| Notifications | 100/parent | FIFO eviction |
| Event History | 100 | Ring buffer |
| Session TTL | 60 min | Auto cleanup |
| Poll Interval | 1 second | Fast completion detection |
| Max Poll Count | 600 | Hard limit prevents infinite loops |
| Sync Timeout | 5 min | Safe delegate_task timeout |
| Recovery Attempts | 3 | Auto session error recovery |
π§ͺ Test Coverage
Test Files: 19 passed
Tests: 216 passed
Duration: ~4.3sπ Reliability Features
Session Recovery
Automatic recovery from common errors:
tool_result_missing- Tool crash recoverythinking_block_order- Thinking block issuesrate_limit- API rate limiting with backoff- Max 3 recovery attempts per session
Todo Continuation
- Monitors
session.idleevents - 2-second countdown before auto-continuation
- Cancels on user interaction
- Skips if background tasks running
noReply Optimization
- Individual task completion:
noReply: true(saves tokens) - All tasks complete:
noReply: false(AI processes results)
Uninstall
npm uninstall -g opencode-orchestratorπ§ Debugging
Log file location:
# Find log path (macOS uses /var/folders/...)
npm run log
# or:
tail -f "$(node -e 'console.log(require("os").tmpdir())')/opencode-orchestrator.log"
# Windows
# C:\Users\<username>\AppData\Local\Temp\opencode-orchestrator.logDocumentation
- System Architecture β Detailed technical docs
- OpenCode SDK Reference β API usage reference
- Release Notes β Version history
- Troubleshooting
License
MIT License. LICENSE