feat: add agent team core — Team namespace, messaging, recovery, and events#12730
Open
ugoenyioha wants to merge 4 commits intoanomalyco:devfrom
Open
feat: add agent team core — Team namespace, messaging, recovery, and events#12730ugoenyioha wants to merge 4 commits intoanomalyco:devfrom
ugoenyioha wants to merge 4 commits intoanomalyco:devfrom
Conversation
Contributor
|
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. |
This was referenced Feb 8, 2026
Contributor
|
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: