subagents

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package subagents provides foreground subagent spawning for task delegation. A subagent is a fully independent agent loop with its own LLM client, tool registry, and message history. It inherits the parent's config, persona, grimoire, and permissions but runs in isolation. For v1.8, subagents run in the foreground (blocking) with no inter-agent messaging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles subagent lifecycle and execution.

func NewManager

func NewManager(cfg *config.Config, workspace string, isChild bool) *Manager

NewManager creates a subagent manager. Pass isChild=true when the manager itself is running inside a subagent to block recursive spawning.

func (*Manager) GetRun

func (m *Manager) GetRun(id string) (*SubagentRun, bool)

GetRun returns a subagent run by ID.

func (*Manager) ListRuns

func (m *Manager) ListRuns() []*SubagentRun

ListRuns returns all subagent runs, most recent first.

func (*Manager) Spawn

func (m *Manager) Spawn(ctx context.Context, goal string, workspace string) (*SubagentRun, error)

Spawn creates and runs a subagent with the given goal. It blocks until the subagent completes or the context is cancelled. Returns the subagent's final response text.

type SpawnAgentTool

type SpawnAgentTool struct {
	// contains filtered or unexported fields
}

SpawnAgentTool is a built-in tool that allows the model to spawn subagents for task delegation. The subagent runs in the foreground (blocks until complete) and returns its final result.

func NewSpawnAgentTool

func NewSpawnAgentTool(manager *Manager) *SpawnAgentTool

NewSpawnAgentTool creates a new spawn_agent tool backed by the given manager.

func (*SpawnAgentTool) Description

func (t *SpawnAgentTool) Description() string

func (*SpawnAgentTool) Execute

func (t *SpawnAgentTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

func (*SpawnAgentTool) InterruptBehavior

func (t *SpawnAgentTool) InterruptBehavior() tools.InterruptBehavior

func (*SpawnAgentTool) IsConcurrencySafe

func (t *SpawnAgentTool) IsConcurrencySafe(input map[string]any) bool

func (*SpawnAgentTool) IsReadOnly

func (t *SpawnAgentTool) IsReadOnly() bool

func (*SpawnAgentTool) Name

func (t *SpawnAgentTool) Name() string

func (*SpawnAgentTool) Parameters

func (t *SpawnAgentTool) Parameters() json.RawMessage

func (*SpawnAgentTool) ValidateInput

func (t *SpawnAgentTool) ValidateInput(input map[string]any) error

type SubagentRun

type SubagentRun struct {
	ID        string    `json:"id"`
	Goal      string    `json:"goal"`
	Workspace string    `json:"workspace"`
	Status    string    `json:"status"` // "running", "completed", "failed"
	Result    string    `json:"result"`
	Error     string    `json:"error,omitempty"`
	StartedAt time.Time `json:"started_at"`
	EndedAt   time.Time `json:"ended_at,omitempty"`
	Turns     int       `json:"turns"`
}

SubagentRun tracks the state and result of a spawned subagent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL