by kdcokenny
Claude Code-style background agents for OpenCode – async delegation with context persistence
# Add to your Claude Code skills
git clone https://github.com/kdcokenny/opencode-background-agentsKeep working while research runs in the background. Your work survives context compaction.
A plugin for OpenCode that enables async background delegation. Fire off research tasks, continue brainstorming or coding, and retrieve results when you need them.
Context windows fill up. When that happens, compaction kicks in and your AI loses track of research it just did. You end up re-explaining, re-researching, starting over.
Background agents solve this:
ocx add kdco/background-agents --from https://registry.kdco.dev
If you don't have OCX installed, install it from the OCX repository.
Optional: Install kdco-workspace for the full experience—it bundles background agents with specialist agents, planning tools, and research protocols:
ocx add kdco/workspace --from https://registry.kdco.dev
1. Delegate → "Research OAuth2 PKCE best practices"
2. Continue → Keep coding, brainstorming, reviewing
3. Notified → <system-reminder> tells you it's done
4. Retrieve → AI calls delegation_read() to get the result
Results are persisted to ~/.local/share/opencode/delegations/ as markdown files. Each delegation is automatically tagged with a title and summary, so the AI can scan past research and find what's relevant.
The plugin adds three tools:
| Tool | Purpose |
|------|---------|
| delegate(prompt, agent) | Launch a background task |
| delegation_read(id) | Retrieve a specific result |
| delegation_list() | List all delegations with titles and summaries |
Only read-only agents (researcher, explore) can use delegate. Write-capable agents (coder, scribe) must use the native task tool.
Why? Background delegations run in isolated sessions outside OpenCode's session tree. The undo/branching system cannot track changes made in background sessions—reverting would not affect these changes, risking unexpected data loss.
A workaround is being explored.
Delegations timeout after 15 minutes.
View active and completed sub-agents using OpenCode's navigation shortcuts:
| Shortcut | Action |
|----------|--------|
| Ctrl+X Up | Jump to parent session |
| Ctrl+X Left | Previous sub-agent |
| Ctrl+X Right | Next sub-agent |
Each delegation is a...
No comments yet. Be the first to share your thoughts!