Skip to content

feat(opencode): add agent teams — DB-based parallel multi-session collaboration#15205

Open
DXM666 wants to merge 7 commits intoanomalyco:devfrom
DXM666:feat/agent-teams
Open

feat(opencode): add agent teams — DB-based parallel multi-session collaboration#15205
DXM666 wants to merge 7 commits intoanomalyco:devfrom
DXM666:feat/agent-teams

Conversation

@DXM666
Copy link
Copy Markdown

@DXM666 DXM666 commented Feb 26, 2026

Issue for this PR

Refs #12661, #5887, #12711

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds agent teams — a DB-based coordination system for parallel multi-session collaboration. A lead session can spawn multiple teammate sessions that work in parallel, communicate via messages, and share a task list.

Key architectural choice: uses SQLite/Drizzle (3 new tables: team, team_task, team_message + team_id/team_role on session) to stay consistent with OpenCode's existing data layer. This is an alternative to the file-based approach in #12711.

Other design points:

  • Single unified team tool with action parameter instead of multiple separate tools
  • Non-blocking spawn + wait-to-collect semantics
  • Shared task list with dependency tracking
  • Pending team messages are injected as synthetic user messages in the prompt loop
  • TUI header badge and Shift+Up/Down shortcuts to cycle team members

Future work (can be added incrementally): server restart recovery, plan approval, delegate mode, name-based addressing, full TUI sidebar.

How did you verify your code works?

  • Created teams, spawned multiple teammates with different agents, verified parallel execution
  • Tested point-to-point and broadcast messaging between teammates
  • Tested task create/claim/complete with dependency validation
  • Verified team cleanup properly archives and removes teammate sessions
  • Tested TUI header display and keyboard navigation between team sessions

Screenshots / recordings

N/A — TUI changes are header badge, keyboard shortcuts, and a tasks panel.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Found 1 potential duplicate:

PR #12730: feat: add agent team core — Team namespace, messaging, recovery, and events
#12730

This PR appears to be related as it also implements agent team functionality including messaging and recovery. It may overlap with the core team coordination features in the current PR.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Add a team coordination system that lets a lead session spawn and manage
multiple teammate sessions working in parallel. Built on SQLite/Drizzle
to stay consistent with OpenCode's existing data layer.

- 3 new DB tables: team, team_task, team_message
- Unified `team` tool with actions: create, spawn, wait, message,
  broadcast, tasks, status, shutdown, cleanup
- Non-blocking spawn with wait-to-collect semantics
- Shared task list with dependency tracking
- Prompt-level injection of pending team messages
- TUI: header badge and keyboard shortcuts to cycle team members

Refs anomalyco#12661, anomalyco#5887, anomalyco#12711

Made-with: Cursor
xiaodong added 2 commits February 27, 2026 16:52
- Add GET /team/:teamID/tasks HTTP route for listing team tasks
- Add TeamTasksPanel TUI component with pending/in-progress/completed sections
- Add Ctrl+T shortcut to toggle team tasks panel visibility
- Sync team tasks on team.task.completed events
- Regenerate SDK with Team client class and types

Made-with: Cursor
Add a built-in /team command that instructs the agent to break down
a task into subtasks and execute them in parallel using agent teams.

Made-with: Cursor
@DXM666
Copy link
Copy Markdown
Author

DXM666 commented Feb 27, 2026

Update: Added 2 more commits:

Commit 2 — HTTP route + TUI tasks panel + SDK

  • GET /team/:teamID/tasks route for listing team tasks
  • TeamTasksPanel component showing tasks grouped by status
  • Ctrl+T shortcut to toggle the panel
  • Sync store auto-refreshes on team.task.completed events
  • SDK regenerated with Team client class

Commit 3 — /team slash command

  • Built-in /team command that breaks down a task into parallel subtasks and executes them using agent teams

xiaodong added 4 commits February 27, 2026 18:14
Replace hardcoded { modelID: "default", providerID: "default" } fallback
with Provider.defaultModel() in spawn and wakeForMessage, consistent
with how the rest of the codebase resolves default models.

Made-with: Cursor
- Implement logic to switch to a lead session when a team member session is deleted.
- Add a helper function to refresh team tasks upon task completion, creation, or claiming events.
- Automatically display the team tasks panel for lead sessions.
- Introduce new events for task creation and claiming to improve task tracking.

Made-with: Cursor
- Add scrollable view to TeamTasksPanel for better task visibility.
- Implement session cleanup logic to remove foreign key references before session deletion.
- Introduce publishSessionUpdated function to notify TUI of session updates.
- Improve error handling and logging during session removal and team cleanup processes.

Made-with: Cursor
# Conflicts:
#	packages/opencode/src/cli/cmd/tui/context/sync.tsx
#	packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
#	packages/opencode/src/config/config.ts
#	packages/opencode/src/id/id.ts
#	packages/opencode/src/server/server.ts
#	packages/opencode/src/session/index.ts
#	packages/opencode/src/session/session.sql.ts
#	packages/opencode/src/storage/schema.ts
#	packages/sdk/js/src/v2/gen/sdk.gen.ts
#	packages/sdk/js/src/v2/gen/types.gen.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant