Repository navigation
feat(team): Dispatcher and TeamBus — closes #3 - #8
Merged
Merged
Conversation
Move inter-agent coordination to internal/team, separate from agent execution: - Dispatcher: Send, Reply, Broadcast, Assign (route by role/team) - ErrNoAgentForRole: typed error for unmatched Assign - TeamBus: polls agent inboxes, dispatches to MessageHandler; Start idempotent, Stop drains cleanly - 11 tests covering all Dispatcher methods and TeamBus delivery/idempotency Dependency chain: internal/team → internal/agent + internal/mailbox (no cycles) Closes #3 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
EngineerProjects
added a commit
that referenced
this pull request
Jun 4, 2026
feat(team): Dispatcher and TeamBus — closes #3
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
New package
internal/team— inter-agent coordination, cleanly separated from agent execution.Dependency chain (no cycles):
Dispatcher— routes messages between agents:Send— direct task to a specific agent UUIDReply— threaded reply linked via ReplyToBroadcast— fan-out to all team members (sender excluded)Assign— delivers to first agent matching role (+ optional team scope)ErrNoAgentForRole— typed error whenAssignfinds no matchTeamBus— polls every agent's inbox at a configurable interval:Start(ctx)— non-blocking, one goroutine per agent, idempotentStop()— cancels all goroutines, waits for clean exitMessageHandler— injectable callback, extension point for session executionWhy a separate package
internal/agentalready handles sub-agent tool execution (runner, async, isolation…).Mixing team coordination there merges two unrelated responsibilities.
internal/teamhas a single job: routing messages and triggering handlers.Test plan
TestDispatcher_Send— message delivered, fields preservedTestDispatcher_Send_EmptyIDs— error on empty from/toTestDispatcher_Reply— reply linked to original via ReplyToTestDispatcher_Reply_EmptyReplyTo— error when replyToID missingTestDispatcher_Broadcast— fan-out to team, sender excludedTestDispatcher_Broadcast_EmptyTeamID— error when teamID missingTestDispatcher_Assign_ByRole— task routed to matching roleTestDispatcher_Assign_ByRoleAndTeam— scoped to correct team onlyTestDispatcher_Assign_NoMatch— returnsErrNoAgentForRoleTestTeamBus_DeliversMessages— bus picks up message within 500msTestTeamBus_Start_Idempotent— second Start is a no-opAll 11 tests pass. Full
go build ./...clean.Closes #3