Documentation
¶
Overview ¶
Package team provides multi-agent orchestration with inter-agent communication.
Teams coordinate multiple agents working together using different strategies: sequential (pipeline), parallel (fan-out/fan-in), router (intelligent dispatch), or coordinator (LLM-driven task decomposition). Communication flows through the protocol.Bus with optional direct agent-to-agent channels for low-latency paths.
Index ¶
- type AgentInfo
- type ErrorStrategy
- type MergeFunc
- type ModelRouterFunc
- type RouterFunc
- type Strategy
- type Team
- func (t *Team) AddAgent(a *agent.Agent) *Team
- func (t *Team) Broadcast(ctx context.Context, fromAgent, subject string, data map[string]any) error
- func (t *Team) DelegateTask(ctx context.Context, from, to, subject string, task protocol.TaskPayload) (*protocol.ResultPayload, error)
- func (t *Team) DirectChannel(agentA, agentB string, bufSize int) *protocol.DirectChannel
- func (t *Team) MessageHistory() []*protocol.Envelope
- func (t *Team) Run(ctx context.Context, input graph.State) (graph.State, error)
- func (t *Team) SetCoordinator(a *agent.Agent) *Team
- func (t *Team) SetErrorStrategy(es ErrorStrategy) *Team
- func (t *Team) SetMaxConcurrency(n int) *Team
- func (t *Team) SetMaxIterations(n int) *Team
- func (t *Team) SetMerge(fn MergeFunc) *Team
- func (t *Team) SetModelRouter(fn ModelRouterFunc) *Team
- func (t *Team) SetRouter(fn RouterFunc) *Team
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentInfo ¶
type AgentInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Capabilities []string `json:"capabilities"`
}
AgentInfo is a lightweight descriptor exposed to routing functions.
type ErrorStrategy ¶
type ErrorStrategy int
ErrorStrategy controls how agent failures are handled.
const ( ErrorStrategyFailFast ErrorStrategy = iota // abort on first error ErrorStrategyCollect // collect all errors, return combined ErrorStrategyBestEffort // ignore errors, return successful results )
type ModelRouterFunc ¶
type ModelRouterFunc func(ctx context.Context, state graph.State, agents []AgentInfo) (string, error)
ModelRouterFunc selects an agent using model-based reasoning. It receives the full state plus a list of available agents with descriptions.
type RouterFunc ¶
RouterFunc selects an agent ID based on the current state.
type Team ¶
type Team struct {
ID string
Name string
Agents map[string]*agent.Agent
Order []string
Strategy Strategy
Router RouterFunc
ModelRouter ModelRouterFunc
Merge MergeFunc
Bus *protocol.Bus
MaxConcurrency int // for parallel strategy; 0 = unbounded
ErrorMode ErrorStrategy // how to handle agent failures
Coordinator *agent.Agent // explicit coordinator agent (for StrategyCoordinator)
MaxIterations int // max coordinator planning iterations; 0 = 1
}
Team orchestrates multiple agents working together.
func (*Team) AddAgent ¶
AddAgent adds an agent to the team and registers it on the communication bus.
func (*Team) DelegateTask ¶
func (t *Team) DelegateTask(ctx context.Context, from, to, subject string, task protocol.TaskPayload) (*protocol.ResultPayload, error)
DelegateTask uses the bus to delegate a task from one agent to another.
func (*Team) DirectChannel ¶
func (t *Team) DirectChannel(agentA, agentB string, bufSize int) *protocol.DirectChannel
DirectChannel returns (or creates) a dedicated low-latency channel between two agents that bypasses the central bus.
func (*Team) MessageHistory ¶
MessageHistory returns all inter-agent messages exchanged during the team run.
func (*Team) SetCoordinator ¶
SetCoordinator sets an explicit coordinator agent (for StrategyCoordinator). The coordinator is automatically registered on the bus so it can delegate tasks.
func (*Team) SetErrorStrategy ¶
func (t *Team) SetErrorStrategy(es ErrorStrategy) *Team
SetErrorStrategy controls how agent failures are handled.
func (*Team) SetMaxConcurrency ¶
SetMaxConcurrency limits goroutines for parallel execution.
func (*Team) SetMaxIterations ¶
SetMaxIterations sets the max number of coordinator planning iterations.
func (*Team) SetModelRouter ¶
func (t *Team) SetModelRouter(fn ModelRouterFunc) *Team
SetModelRouter sets a model-based routing function (for StrategyRouter).
func (*Team) SetRouter ¶
func (t *Team) SetRouter(fn RouterFunc) *Team
SetRouter sets a static routing function (for StrategyRouter).