Documentation
¶
Index ¶
- func Run(ctx context.Context, cfg RunnerConfig)
- func Wait(ctx context.Context, mgr *Manager, id string) (string, error)
- type AgentFactory
- type AgentRunner
- type Manager
- func (m *Manager) AcquireSemaphore(ctx context.Context) error
- func (m *Manager) Cancel(id string) bool
- func (m *Manager) Complete(id string, result string, err error)
- func (m *Manager) Get(id string) (*SubAgent, bool)
- func (m *Manager) List() []*SubAgent
- func (m *Manager) Notify(id string)
- func (m *Manager) ReleaseSemaphore()
- func (m *Manager) RunningCount() int
- func (m *Manager) SetCancel(id string, cancel context.CancelFunc)
- func (m *Manager) SetOnComplete(fn func(*SubAgent))
- func (m *Manager) SetOnUpdate(fn func(*SubAgent))
- func (m *Manager) ShowOutput() bool
- func (m *Manager) Spawn(task, displayTask string, tools []string, ctx context.Context) string
- func (m *Manager) Timeout() time.Duration
- func (m *Manager) UpdateProgress(id, summary string)
- type RunnerConfig
- type Status
- type SubAgent
- type ToolInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(ctx context.Context, cfg RunnerConfig)
Run starts the sub-agent in a goroutine, running a complete agentic loop. The sub-agent gets its own context manager, tool subset, and provider instance.
Types ¶
type AgentFactory ¶
type AgentFactory func(prov provider.Provider, tools interface{}, systemPrompt string, maxTurns int) AgentRunner
AgentFactory creates an agent with the given provider, tool registry, system prompt, and max turns. The tools parameter is an opaque value passed through from the caller.
type AgentRunner ¶
type AgentRunner interface {
RunStream(ctx context.Context, prompt string, onEvent func(provider.StreamEvent)) error
}
AgentRunner is the minimal interface needed from an agent.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages spawning, tracking, and collecting results from sub-agents.
func NewManager ¶
func NewManager(cfg config.SubAgentConfig) *Manager
NewManager creates a Manager with the given config.
func (*Manager) AcquireSemaphore ¶
AcquireSemaphore blocks until a slot is available for a new sub-agent to run.
func (*Manager) ReleaseSemaphore ¶
func (m *Manager) ReleaseSemaphore()
ReleaseSemaphore releases a slot.
func (*Manager) RunningCount ¶
RunningCount returns the number of currently running agents.
func (*Manager) SetCancel ¶
func (m *Manager) SetCancel(id string, cancel context.CancelFunc)
SetCancel stores the cancel function for a sub-agent.
func (*Manager) SetOnComplete ¶
SetOnComplete sets a callback invoked when any sub-agent completes.
func (*Manager) SetOnUpdate ¶
SetOnUpdate sets a callback invoked when any sub-agent activity changes.
func (*Manager) ShowOutput ¶
ShowOutput returns whether to show sub-agent output.
func (*Manager) UpdateProgress ¶
type RunnerConfig ¶
type RunnerConfig struct {
Provider provider.Provider
AllTools []ToolInfo
Task string
AllowedTools []string
Manager *Manager
SubAgentID string
AgentFactory AgentFactory
BuildToolSet func(allowedTools []string, allTools []ToolInfo) interface{} // returns opaque tool set for agent
}
RunnerConfig holds everything needed to run a sub-agent.
type SubAgent ¶
type SubAgent struct {
ID string
Task string
DisplayTask string
Tools []string
ToolCallCount int
Status Status
CurrentPhase string
CurrentTool string
CurrentArgs string
ProgressSummary string
Result string
Error error
CreatedAt time.Time
StartedAt time.Time
EndedAt time.Time
// contains filtered or unexported fields
}
SubAgent represents a spawned child agent.
func (*SubAgent) IncrementToolCalls ¶
func (s *SubAgent) IncrementToolCalls()