https://github.com/agnusdei1207/opencode-orchestrator
Opencode Plugin for AI-Agent Orchestration
https://github.com/agnusdei1207/opencode-orchestrator
ai-orchestration opencode rust
Last synced: 25 days ago
JSON representation
Opencode Plugin for AI-Agent Orchestration
- Host: GitHub
- URL: https://github.com/agnusdei1207/opencode-orchestrator
- Owner: agnusdei1207
- License: mit
- Created: 2026-01-13T01:25:07.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-01-21T12:20:13.000Z (about 1 month ago)
- Last Synced: 2026-01-22T00:28:49.303Z (about 1 month ago)
- Topics: ai-orchestration, opencode, rust
- Language: TypeScript
- Homepage: https://rdot.agnusdei.kr/
- Size: 42.6 MB
- Stars: 56
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-AI-driven-development - OpenCode Orchestrator - Production-Grade Multi-Agent Orchestration Engine for High-Integrity Software Engineering (Multi-Agent & Orchestration / Other IDEs)
README
OpenCode Orchestrator
Production-Grade Multi-Agent Orchestration Engine for High-Integrity Software Engineering
[](LICENSE)
[](https://www.npmjs.com/package/opencode-orchestrator)
---
## β‘ Quick Start
```bash
npm install -g opencode-orchestrator
```
Inside an OpenCode environment:
```bash
/task "Implement a new authentication module with JWT and audit logs"
```
---
---
## π Engine Workflow
OpenCode Orchestrator utilizes a **Hub-and-Spoke Topology** with **Work-Stealing Queues** to execute complex engineering tasks through parallel, context-isolated sessions.
```text
[ User Task ]
β
ββββββββββββΌβββββββββββ
β COMMANDER ββββββββββββββ (Loop Phase)
β [Work-Stealing] β β
ββββββββββ¬βββββββββββββ β
β β
ββββββββββΌβββββββββββ β
β PLANNER β (Todo.md) β
β [Session Pool] β β
ββββββββββ¬βββββββββββ β
β β (MVCC Atomic Sync)
βββββββββββββββΌβββββββββββββββ β
βΌ (Isolated Session Pool)βΌ β
[ Session A ] [ Session B ] [ Session C ] β
[ Worker ] [ Worker ] [ Reviewer ] β
β [Memory ] β [Memory ] β [Memory β β
β Pooling] β β Pooling] β β Pooling] β β
βββββββββββββββ¬βββββββββββββββ β
β β
ββββββββββΌβββββββββββ β
β MSVP MONITOR ββββββββββββββββ
β [Adaptive Poll] β
ββββββββββ¬βββββββββββ
β
ββββββββββΌβββββββββββ
β QUALITY ASSURANCE β
ββββββββββ¬βββββββββββ
β
[ β¨COMPLETED ]
```
---
## π οΈ Core Capabilities
### π Atomic MVCC State Synchronization
The engine solves the "Concurrent TODO Update" problem using **Multi-Version Concurrency Control (MVCC) + Mutex**. Agents can safely mark tasks as complete in parallel without data loss or race conditions. Every state change is cryptographically hashed and logged for a complete audit trail.
### π§© Advanced Hook Orchestration
Execution flows are governed by a **Priority-Phase Hook Registry**. Hooks (Safety, UI, Protocol) are grouped into phases (`early`, `normal`, `late`) and executed using a **Topological Sort** to handle complex dependencies automatically, ensuring a predictable and stable environment.
### π‘οΈ Autonomous Recovery
- **Self-healing loops** with adaptive stagnation detection
- **Proactive Agency**: Smart monitoring that audits logs and plans ahead during background tasks
- **Auto-retry with backoff**: Exponential backoff for transient failures
### π― State-Level Session Isolation
Reused sessions in the **SessionPool** are explicitly reset using server-side compaction triggered by health monitors. This ensures that previous task context (old error messages, stale file references) never leaks into new tasks, maintaining 100% implementation integrity.
### π Zero-Payload Turbo Mode
Leverages `system.transform` to unshift massive agent instruction sets on the server side. This reduces initial message payloads by **90%+**, slashing latency and preventing context fragmentation during long autonomous loops.
---
## π οΈ Infrastructure & Reliability
### π Resource Safety & Reliability
- **RAII Pattern (ConcurrencyToken)**: Guaranteed resource cleanup with zero leaks
- **ShutdownManager**: Priority-based graceful shutdown with 5-second timeout per handler
- **Automatic Backups**: All config changes backed up with rollback support
- **Atomic File Operations**: Temp file + rename for corruption-proof writes
- **Finally Blocks**: Guaranteed cleanup in all critical paths
- **Zero Resource Leaks**: File watchers, event listeners, concurrency slots all properly released
### β‘ Performance Optimizations
- **Work-Stealing Queues**: Chase-Lev deque implementation for 90%+ CPU utilization
- Planner: 2 workers, Worker: 8 workers, Reviewer: 4 workers
- LIFO for owner (cache locality), FIFO for thieves (fairness)
- **Memory Pooling**: 80% GC pressure reduction
- Object Pool: 200 ParallelTask instances (50 prewarmed)
- String Interning: Deduplication for agent names, status strings
- Buffer Pool: Reusable ArrayBuffers (1KB, 4KB, 16KB, 64KB)
- **Session Reuse**: 90% faster session creation (500ms β 50ms)
- Pool size: 5 sessions per agent type
- Max reuse: 10 times per session
- Health check: Every 60 seconds
- **Rust Connection Pool**: 10x faster tool calls (50-100ms β 5-10ms)
- Max 4 persistent processes
- 30-second idle timeout
- **Adaptive Polling**: Dynamic 500ms-5s intervals based on system load
### π‘οΈ Safety Features
- **Circuit Breaker**: Auto-recovery from API failures (5 failures β open)
- **Resource Pressure Detection**: Rejects low-priority tasks when memory > 80%
- **Terminal Node Guard**: Prevents infinite recursion (depth limit enforcement)
- **Auto-Scaling**: Concurrency slots adjust based on success/failure rate
---
## π οΈ Key Innovations
### π§ Hierarchical Memory System
Maintains focus across thousands of conversation turns using a 4-tier memory structure and **EMA-based Context Gating** to preserve "Architectural Truth" while pruning operational noise.
### Dynamic Concurrency Auto-Scaling
Slots for parallel implementation scale up automatically after a **3-success streak** and scale down aggressively upon detection of API instability or implementation failures.
### π‘οΈ Neuro-Symbolic Safety
Combines LLM reasoning with deterministic **AST/LSP verification**. Every code change is verified by native system tools before being accepted into the master roadmap.
### π Adaptive Intelligence Loop
- **Stagnation Detection**: Automatically senses when no progress is made across multiple iterations
- **Diagnostic Intervention**: Forces the agent into a "Diagnostic Mode" when stagnation is detected, mandating log audits and strategy pivots
- **Proactive Agency**: Mandates Speculative Planning and Parallel Thinking during background task execution
### π Native TUI Integration
Seamless integration with OpenCode's native TUI via **TaskToastManager**. Provides non-intrusive, real-time feedback on **Mission Progress**, active **Agent Sub-sessions**, and **Technical Metrics** using protocol-safe Toast notifications.
### β‘ Event-Driven Architecture
Utilizes a hybrid event-driven pipeline (`EventHandler` + `TaskPoller`) to maximize responsiveness while maintaining robust state tracking and resource cleanup.
### π Secure Configuration
Runtime agent configuration is strictly validated using **Zod schemas**, ensuring that custom agent definitions in `agents.json` are type-safe and error-free before execution.
---
## β‘ Elite Multi-Agent Swarm
| Agent | Expertise | Capability |
|:------|:-----|:---|
| **Commander** | Mission Hub | Session pooling, parallel thread control, state rehydration, work-stealing coordination |
| **Planner** | Architect | Symbolic mapping, dependency research, roadmap generation, file-level planning |
| **Worker** | Implementer | High-throughput coding, TDD workflow, documentation, isolated file execution |
| **Reviewer** | Auditor | Rigid verification, LSP/Lint authority, integration testing, final mission seal |
---
## π Performance Benchmarks
### Throughput & Efficiency
- **Concurrent Sessions**: 50+ parallel agent sessions with work-stealing
- **CPU Utilization**: 90%+ (up from 50-70%)
- **Tool Call Speed**: 10x faster (5-10ms vs 50-100ms) via Rust connection pool
- **Session Creation**: 90% faster (50ms vs 500ms) via session pooling
- **Processing Speed**: 3-5x baseline throughput
### Resource Efficiency
- **Memory Usage**: 60% reduction (40% of baseline) via pooling
- **GC Pressure**: 80% reduction via object/string/buffer pooling
- **Token Efficiency**: 40% reduction via Incremental State & System Transform
### Reliability
- **Sync Accuracy**: 99.95% reliability via MVCC+Mutex transaction logic
- **Mission Survival**: 100% uptime through plugin restarts via S.H.R (Self-Healing Rehydration)
- **Resource Leaks**: Zero (guaranteed by RAII pattern)
- **Config Safety**: 100% (atomic writes + auto-backup + rollback)
### Scalability
- **Work-Stealing Efficiency**: 80% improvement in parallel efficiency (50% β 90%+)
- **Adaptive Polling**: Dynamic 500ms-5s based on load
- **Auto-Scaling**: Concurrency slots adjust automatically based on success rate
---
## ποΈ Technical Stack
- **Runtime**: Node.js 18+ (TypeScript)
- **Tools**: Rust-based CLI tools (grep, glob, ast) via connection pool
- **Concurrency**: Chase-Lev work-stealing deque + priority queues
- **Memory**: Object pooling + string interning + buffer pooling
- **State Management**: MVCC + Mutex
- **Safety**: RAII pattern + circuit breaker + resource pressure detection
---
## π Documentation
- [Why We Built a Custom Orchestrator Instead of Using OpenCode's APIs β](docs/WHY_CUSTOM_ORCHESTRATOR.md)
- [System Architecture Deep-Dive β](docs/SYSTEM_ARCHITECTURE.md)
- [Windows Configuration Guide β](docs/WINDOWS_CONFIGURATION.md)
- [Developer Notes β](docs/DEVELOPERS_NOTE.md)
---
## π§ Installation & Configuration
### Safe Installation
The installation process is **production-safe** with multiple protection layers:
1. β
**Never overwrites** - always merges with existing config
2. β
**Automatic backups** - timestamped, last 5 kept
3. β
**Atomic writes** - temp file + rename (OS-level atomic)
4. β
**Write verification** - ensures correctness after every change
5. β
**Automatic rollback** - restores from backup on any failure
6. β
**Cross-platform** - Windows (native, Git Bash, WSL), macOS, Linux
### Configuration Logs
- Unix: `/tmp/opencode-orchestrator.log`
- Windows: `%TEMP%\opencode-orchestrator.log`
---
## π License
MIT License - see [LICENSE](LICENSE) for details.
---
Built with β‘ for production-grade autonomous software engineering