feat: add agent team core — Team namespace, messaging, recovery, and events#12730
feat: add agent team core — Team namespace, messaging, recovery, and events#12730ugoenyioha wants to merge 4 commits into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
a6f186b to
db0179f
Compare
ce90bed to
aed05dd
Compare
- Reorder in autoWake: add .then() handler to transition shutdown_requested → shutdown - Remove ready from shutdown_requested transitions (prevent overwrite race) - cancelMember: accept shutdown_requested in addition to busy - Wrap autoWake in try/catch (prevent unhandled rejections from fire-and-forget calls)
17f2522 to
e8c8647
Compare
- Add inbox.ts (JSONL inbox for O(1) writes) - Add core-only tests (autowake, cancel, persistence, recovery) - Update core files to latest dev versions (events, index, messaging) - Adapt to upstream Session API (no teammate field, no LoopResult) - Includes shutdown race condition fix - Move tool-dependent tests to team-tools PR
|
im hoping the opencode team is considering something like this. thx for taking the first step into it |
|
This is needed , I am using a markdown shared file between different models-sessions atm |
|
bump |
|
Can we please get this merged? |
…malyco#12732 to v1.3.0 Port the agent teams feature from the blog post three PRs onto the latest OpenCode v1.3.0 codebase. Adapts to current architecture: Effect patterns, branded IDs, and service refactoring. Core (PR anomalyco#12730): Team state, messaging, recovery, events Tools (PR anomalyco#12731): 9 MCP tools, HTTP routes, registry integration TUI (PR anomalyco#12732): Team dialog, sync store extension Gated behind OPENCODE_EXPERIMENTAL_AGENT_TEAMS flag.
|
No chance to merge? |
|
Why hasn't this merged yet? |
|
Extremely keen, thanks for this PR 🙇 |
|
Very interested in this |
|
I also wonder why hasn't this merged yet? I really need an agent taam to discuss something, not only subagents. |
|
Let me also express my interest in this, can we get it merged anytime soon? |
|
Let me also express my interest in this, can we get it merged anytime soon? |
|
Really looking forward to it. |
Summary
Adds the foundational layer for agent teams (Fixes #12711), gated behind
OPENCODE_EXPERIMENTAL_AGENT_TEAMS=1.This is PR 1/3 in the agent teams stack. It introduces the core Team namespace with full CRUD, persistence, recovery, and inter-agent messaging — everything downstream PRs (#12731 tools, #12732 TUI) build on top of.
What's included
Team namespace (
team/index.ts— 392 lines)create,get,list,addMember,removeMember,cleanupStoragenamespace with project-scoped keys (["team", projectId, name]and["team_tasks", projectId, name]). No rawBun.file/Bun.writeor filesystem paths — Storage handles atomicity and locking internally.createandgetwrapped withfn()for Zod input validationaddMember,setMemberStatus,setDelegate,setMemberPlanApproval,removeMember) useStorage.update()— read-modify-write under lock"lead"rejection — all insideStorage.updatecallback for atomicity{ guard: true }parameter prevents overwriting"shutdown"status (TOCTOU prevention for teammate completion callbacks)active,idle,shutdown,interruptedstates with atomic updatessetDelegate()toggles lead's write permissions — when enabled, the lead is restricted to coordination-only toolssetMemberPlanApproval()managesnone→pending→approved/rejectedflow per membercleanup()publishesTeamEvent.CleanedwithleadSessionIDanddelegatefields so listeners can handle side-effects (e.g. restoring lead session permissions) — no direct Session import in the cleanup pathTask system (
TeamTasksinteam/index.ts)list,add,update,complete,claim— all useStorage.updatefor concurrency safetyclaim()checks status, assignee, and dependency resolution inside aStorage.updatecallbackdepends_onlogic as the per-session Todo system — auto-blocks tasks with unresolved deps, auto-unblocks when deps completeTaskUpdatedandTaskClaimedevents propagate to TUI in real-timeMessaging (
team/messaging.ts— 134 lines)send()routes messages between teammates and the lead by injecting synthetic user messages into the recipient's sessionbroadcast()sends to all active members (skipsshutdownandinterrupted), includes the lead if sender isn't the leadautoWake()starts a new prompt loop so the LLM picks up and processes the message immediately[Team message from <name>]: <text>user messages withsynthetic: trueEvents (
team/events.ts— 130 lines)team.created,team.member.spawned,team.member.status,team.message,team.broadcast,team.task.updated,team.task.claimed,team.shutdown.request,team.plan.approval,team.cleanedTeamInfoSchema,TeamMemberSchema,TeamTaskSchemawith Zod, re-exported for downstream useTeamEvent.CleanedincludesleadSessionIDanddelegatefields for event-based permission restorationproviderID/modelIDformat), planApprovalBootstrap hook (
project/bootstrap.ts)Team.recover()call during instance startupRecovery (
Team.recover())status: "active"(stale from a crash)interruptedFeature flag (
flag/flag.ts)OPENCODE_EXPERIMENTAL_AGENT_TEAMS— dynamic getter from environment variable, gates all team functionalityTests
4 test files, 26 tests:
team-autowake.test.ts— Auto-wake behavior when messages arrive for idle sessionsteam-persistence.test.ts— Storage persistence, config read/write, task serialization (verified via API, not raw file paths)team-recovery.test.ts— Recovery logic for interrupted teammates after server restart (with Storage cleanup)team-recovery-e2e.test.ts— End-to-end recovery scenarios with session injectionFiles changed
src/team/index.tssrc/team/messaging.tssrc/team/events.tssrc/flag/flag.tssrc/project/bootstrap.tstest/team/team-autowake.test.tstest/team/team-persistence.test.tstest/team/team-recovery.test.tstest/team/team-recovery-e2e.test.tsStack
PR 1/3 — merge in order: