Documentation
¶
Overview ¶
Package delegate lets an agent hand work to other agents: the delegate tool runs a full sub-agent (its own thread and sandbox, a role-specific prompt) and returns its report, and the prompt sections tell a thread which role and task it was started for.
Index ¶
Constants ¶
const ( DefaultMaxDepth = 2 DefaultMaxParallel = 3 DefaultTimeout = 30 * time.Minute )
Defaults and limits.
Variables ¶
This section is empty.
Functions ¶
func DefaultRoles ¶
DefaultRoles is the built-in catalogue: planner, coder, reviewer, tester and explorer.
func Roster ¶
func Roster(catalogue ...map[string]Role) agent.PromptSection
Roster lists the roles a thread may delegate to. Add it only where the delegate tool is offered; the tool's own description carries the same list for models that do not read the system prompt closely, so this is the short form. The optional argument is the catalogue (default: DefaultRoles).
Types ¶
type Options ¶
type Options struct {
// Spawner runs the sub-agents.
Spawner factory.Spawner
// Store reads the calling thread's ThreadInfo: its login, task, policy and
// repository are inherited, its ParentThreadID chain gives the depth. Nil
// treats every thread as an ordinary one at depth 0.
Store factory.Store
// Roles is the catalogue (nil: DefaultRoles).
Roles map[string]Role
// MaxDepth is how deep delegation nests: a thread already that many
// delegations below an ordinary thread gets no delegate tool (0: 2).
MaxDepth int
// MaxParallel bounds the sub-agents one run has running at once (0: 3).
MaxParallel int
// Models are the model ids the caller may pick with the model argument;
// empty means the caller cannot choose and the role or spawner default applies.
Models []string
// Timeout bounds one delegation (0: 30 minutes).
Timeout time.Duration
// Task loads the factory task of a thread so the sub-agent also gets the
// task's title and spec. Optional.
Task func(ctx context.Context, taskID string) (*factory.Task, error)
// OnSpend is told what each finished sub-run spent, for the thread's task
// (only when the thread has one). Optional.
OnSpend func(ctx context.Context, taskID string, d factory.Spend)
}
Options configures a Provider.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider offers the delegate and delegate_many tools.
type Role ¶
type Role struct {
Name string
// Description is the one-liner the delegating agent reads to pick a role.
Description string
// Instructions is the role's prompt text, added to the sub-agent's system prompt.
Instructions string
// ReadOnly roles run in plan mode: nothing they do changes anything.
ReadOnly bool
// Model "" uses the spawner's default model.
Model string
}
Role is a kind of sub-agent the delegate tool can start.