Skip to content

feat(team): Dispatcher and TeamBus — closes #3 - #8

Merged
EngineerProjects merged 1 commit into
devfrom
feat/team
Jun 4, 2026
Merged

EngineerProjects merged 1 commit into
devfrom
feat/team

Conversation

@EngineerProjects

Copy link
Copy Markdown
Collaborator

Summary

New package internal/team — inter-agent coordination, cleanly separated from agent execution.

Dependency chain (no cycles):

internal/agent   →  AgentProfile, ProfileRegistry
internal/mailbox →  Message, Mailbox
internal/team    →  imports both, owns coordination logic
  • Dispatcher — routes messages between agents:
    • Send — direct task to a specific agent UUID
    • Reply — threaded reply linked via ReplyTo
    • Broadcast — fan-out to all team members (sender excluded)
    • Assign — delivers to first agent matching role (+ optional team scope)
  • ErrNoAgentForRole — typed error when Assign finds no match
  • TeamBus — polls every agent's inbox at a configurable interval:
    • Start(ctx) — non-blocking, one goroutine per agent, idempotent
    • Stop() — cancels all goroutines, waits for clean exit
    • MessageHandler — injectable callback, extension point for session execution

Why a separate package

internal/agent already handles sub-agent tool execution (runner, async, isolation…).
Mixing team coordination there merges two unrelated responsibilities.
internal/team has a single job: routing messages and triggering handlers.

Test plan

  • TestDispatcher_Send — message delivered, fields preserved
  • TestDispatcher_Send_EmptyIDs — error on empty from/to
  • TestDispatcher_Reply — reply linked to original via ReplyTo
  • TestDispatcher_Reply_EmptyReplyTo — error when replyToID missing
  • TestDispatcher_Broadcast — fan-out to team, sender excluded
  • TestDispatcher_Broadcast_EmptyTeamID — error when teamID missing
  • TestDispatcher_Assign_ByRole — task routed to matching role
  • TestDispatcher_Assign_ByRoleAndTeam — scoped to correct team only
  • TestDispatcher_Assign_NoMatch — returns ErrNoAgentForRole
  • TestTeamBus_DeliversMessages — bus picks up message within 500ms
  • TestTeamBus_Start_Idempotent — second Start is a no-op

All 11 tests pass. Full go build ./... clean.

Closes #3

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
EngineerProjects merged commit c6054f8 into dev Jun 4, 2026
@EngineerProjects
EngineerProjects deleted the feat/team branch June 4, 2026 12:18
EngineerProjects added a commit that referenced this pull request Jun 4, 2026
feat(team): Dispatcher and TeamBus — closes #3
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