Skip to content

[FEATURE]: DB-backed agent team coordination (parallel sub-agents, messaging, memory) #19215

Description

@pamelia

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Related: #12711 (file-based design by @ugoenyioha), #12661, #15035, #17994

Describe the enhancement you want to request

opencode's TaskTool only does synchronous sub-agent execution. No way to run agents in parallel, have them talk to each other, or coordinate on shared tasks.

#12711 proposes a file-based approach (JSON on disk, no DB changes). I built an alternative using DB-backed state, which fits how the rest of opencode works (sessions, messages, parts — all DB-backed with Bus events). Posting this to get design direction before opening PRs.

Key differences from #12711:

#12711 This proposal
Storage JSON files in .opencode/teams/ 4 SQLite tables (team, team_member, team_task, agent_memory)
Concurrency File locking DB transactions + WAL mode
Recovery Scan files, mark interrupted reconcile() disbands stale teams on startup
Agent memory Not included Per-agent per-project persistent memory (100KB cap)

Why DB instead of files:

  • Consistent with every other opencode subsystem (sessions, messages, parts, projects)
  • Transactions give atomic team create (team + lead member in one tx)
  • Bus events for real-time TUI updates work naturally via existing patterns
  • No file locking needed — SQLite WAL handles concurrent agents

What's implemented (locally, ready to PR when approved):

  • Team management with lead/member lifecycle, agent name auto-disambiguation
  • Background agent execution with configurable concurrency limit (default 10)
  • Cross-session message injection (synthetic user messages, race-safe Bus subscribe)
  • Agent memory with 100KB cap
  • Team task board
  • TUI sidebar showing active teams/agents
  • 30 tests across 3 test files

Features we'd add (from #12711 and beyond)

The current implementation covers the core primitives. These features from #12711 are worth adding and I'm ready to build them if the core team is interested:

Delegate mode — Lead gets restricted to coordination-only tools (no write/edit/bash). Forces clean separation between orchestration and execution. Prevents the lead from doing work it should delegate. Implementation: a delegate flag on team_create that applies a permission override denying write tools on the lead session.

Plan approval — Teammates start in read-only mode. They research, formulate a plan, send it to the lead for approval. Lead approves (write tools unlocked) or rejects (teammate revises). Prevents wasted token spend on wrong approaches. Implementation: planApproval status on team members and a team_approve_plan tool.

Broadcast messaging — Send a message to all teammates at once. Current send_message is point-to-point only. Useful for the lead to announce decisions, share context, or signal everyone to stop. Implementation: iterate members and inject into each session.

Atomic task claiming — Any member can claim a pending task from the shared board with an atomic DB transaction preventing two agents from grabbing the same task. Implementation: TeamTask.claim(taskID, agent) that sets owner + status in one transaction.

Idle member status — Distinguish between "finished current work, waiting for more" (idle) and "done forever" (completed). Lets the lead know which members are still available for follow-up work.

TUI enhancements — Header badge with team name + member count, prompt bar busy indicator ("3 teammates working"), spinner on busy teammate sessions in session list.

What is the use case?

  • Parallel spec reviews (5+ specialist agents simultaneously)
  • Iterative self-review loops (fresh reviewer each turn)
  • Any skill where agents need to communicate findings to a lead
  • Persistent agent memory across sessions
  • Security audits across frontend/backend/infra with different models per teammate
  • Multi-file refactors with coordinated plan approval before writes

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions