subagent

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package subagent lets a model delegate tasks to sub-agents, which work on them in contexts of their own and report back. A call of its tool runs one agent, several in parallel, a chain of them, or one in the background.

Index

Constants

View Source
const MaxDepth = 5

MaxDepth caps how deep sub-agents nest: the main agent is at depth 0, an agent it spawns at 1. A host that gives sub-agents the subagent tool relies on it to stop runaway recursion.

Variables

This section is empty.

Functions

func New

func New(tasks *task.Runtime, agents ...Agent) agentcore.Tool

New returns the subagent tool, which delegates to agents. With tasks, the model may also run an agent in the background, as a task of tasks.

Types

type Agent added in v1.8.5

type Agent struct {
	Name        string
	Description string
	// Config configures a run of the agent; an error fails the run. Each run
	// gets a configuration of its own, so that its tools keep state of their
	// own. The run's events go to its Emit, and to the tool call waiting for
	// it as Progress. The runs of a parallel call work at once: the Emits
	// of their Configs are called concurrently.
	Config func(Spawn) (agentcore.Config, error)
	// WrapRun, if set, wraps each run of the agent, as tracing does: it
	// returns the context the run works in, and a callback for the text of
	// the run's last response and its error.
	WrapRun func(ctx context.Context, s Spawn, prompt string) (context.Context, func(output string, err error))
}

Agent is a sub-agent the model may delegate to.

type Mode added in v1.8.5

type Mode string

Mode is how a call runs its agents.

const (
	ModeSingle     Mode = "single"
	ModeParallel   Mode = "parallel"
	ModeChain      Mode = "chain"
	ModeBackground Mode = "background"
)

type Progress added in v1.8.5

type Progress struct {
	Spawn Spawn
	Event agentcore.Event
}

Progress is the progress the tool reports: an event of a run the call waits for. A background run reports none.

type Spawn added in v1.8.5

type Spawn struct {
	Agent string
	// ID tells the run from every other run in the process, as "explore#3".
	ID   string
	Mode Mode
	// Model is the model the call asked for, or "" for the agent's own.
	// Config honors it or refuses it.
	Model string
}

Spawn is a run of an agent.

Jump to

Keyboard shortcuts

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