Overview
OpenCode is an AI coding assistant that stores session data in a global SQLite database. The plugin:- Launches OpenCode with inline prompt delivery
- Detects process status (running/exited)
- Does not support activity detection, cost tracking, or metadata updates
For production use, consider Claude Code or Codex plugins which offer full session introspection.
Installation
Configuration
Configure inagent-orchestrator.yaml:
Configuration Options
Task description passed to
opencode runModel identifier passed via
--model flagOpenCode does not support system prompts, permission modes, or many of the configuration options available in other agents.
How It Works
Launch Command
OpenCode is launched with the prompt as a positional argument:Process Detection
The plugin checks if theopencode process is running:
- Tmux runtime: Searches
psoutput for “opencode” on the session’s TTY - Process runtime: Checks if the PID is alive via
process.kill(pid, 0)
Activity Detection
Reason: OpenCode stores all session data in a single global SQLite database (~/.local/share/opencode/opencode.db) without per-workspace scoping. When multiple OpenCode sessions run in parallel, database modifications from any session would cause all sessions to appear active.
Until OpenCode provides per-workspace session tracking, the plugin cannot reliably detect activity state.
Limitations
No Session Introspection
The plugin returnsnull for:
getSessionInfo(): No summaries, token counts, or cost estimatesgetRestoreCommand(): No native resume supportgetActivityState(): Cannot determine if agent is active, idle, or waiting
No Metadata Updates
OpenCode does not support hooks or command interception. Session metadata is never automatically updated.Single Database
All sessions share~/.local/share/opencode/opencode.db, making it impossible to:
- Track costs per session
- Distinguish activity between concurrent sessions
- Resume specific sessions
Usage Examples
Spawn an Agent
Check Process Status
Attach to Session
Troubleshooting
Activity state always shows 'unknown'
Activity state always shows 'unknown'
Cause: OpenCode does not provide per-session activity trackingSolution: This is expected behavior. Check process status instead:Or attach to the session to view actual state:
No cost or token usage data
No cost or token usage data
Cause: OpenCode does not expose this data per sessionSolution: Track costs manually via:
- API provider’s billing dashboard (OpenAI, etc.)
- Global OpenCode database queries (requires SQLite knowledge)
- Third-party monitoring tools
Cannot resume sessions
Cannot resume sessions
Cause: OpenCode does not support native session resumptionSolution: Start a new session instead. Previous context is lost.
Multiple sessions interfere with each other
Multiple sessions interfere with each other
Cause: Shared global databaseSolution: Run OpenCode sessions sequentially, not in parallel. Or use workspace-scoped agents like Claude Code or Codex.
Comparison with Other Agents
| Feature | OpenCode | Claude Code | Codex | Aider |
|---|---|---|---|---|
| Session Isolation | ❌ Global DB | ✅ Per-workspace | ✅ Per-workspace | ✅ Per-workspace |
| Cost Tracking | ❌ None | ✅ Full | ✅ Full | ❌ None |
| Activity Detection | ❌ None | ✅ JSONL events | ✅ File mtime | ⚠️ Git commits |
| Auto-metadata | ❌ None | ✅ PostToolUse | ✅ PATH wrappers | ❌ None |
| Resume Support | ❌ None | ✅ Native | ✅ Native | ❌ None |
| Maturity | ⚠️ Experimental | ✅ Production | ✅ Production | ✅ Stable |
When to Use OpenCode
Consider OpenCode if:- You’re already invested in the OpenCode ecosystem
- You only run one agent at a time (no parallelism)
- You don’t need cost tracking or session introspection
- You’re experimenting with different agent providers
Environment Variables
The plugin sets minimal environment variables:Session identifier (for orchestrator use only)
Project identifier (set by caller, not the plugin)
Issue/ticket identifier if applicable
Future Improvements
For OpenCode to be production-ready, it needs:- Per-workspace session storage: Move away from global SQLite DB
- Session introspection API: Expose token counts, costs, summaries
- Activity events: JSONL or similar format for state detection
- Command hooks: PostToolUse or similar for metadata updates
- Resume support: Native thread/session resumption
Contributing
If you’re an OpenCode contributor interested in improving orchestrator integration:- Add per-workspace session directories (like Claude’s
~/.claude/projects/{path}/) - Export JSONL event logs for activity tracking
- Support
--resume <session-id>flag - Provide token count and cost APIs
