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 ¶
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 Progress ¶ added in v1.8.5
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.
Click to show internal directories.
Click to hide internal directories.