subagents

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package subagents provides explicit, synchronous child-agent delegation. It never discovers agents, transfers control or starts background work.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfig      = errors.New("subagents: invalid configuration")
	ErrUnknown     = errors.New("subagents: unknown child")
	ErrTask        = errors.New("subagents: invalid task")
	ErrBudget      = errors.New("subagents: delegation budget exhausted")
	ErrBusy        = errors.New("subagents: a child is already active")
	ErrNested      = errors.New("subagents: nested delegation is not enabled")
	ErrChildFailed = errors.New("subagents: child run failed")
	ErrOutput      = errors.New("subagents: invalid or excessive child output")
)

Functions

This section is empty.

Types

type Child

type Child struct {
	Name         string
	Description  string
	Instructions string
	Config       agent.Config
}

Child is a caller-reviewed definition. Config is independent of the parent and must explicitly contain every authorized model, tool and verifier. Instructions are trusted application configuration, not discovered data.

type Config

type Config struct {
	Children          []Child
	MaxRuns           int
	MaxTotalSteps     int
	MaxTotalToolCalls int
	Timeout           time.Duration
}

Config sets one delegation scope's lifetime limits. Zero selects four attempts, 16 reserved model steps, 32 reserved tool calls, and 30 seconds per child. Full child limits are charged before execution, even on failure. Counts do not represent tokens, money, or resource isolation.

type Result

type Result struct {
	Child     string `json:"child"`
	Text      string `json:"text"`
	Steps     int    `json:"steps"`
	ToolCalls int    `json:"tool_calls"`
}

Result exposes only a successful child's final text and attempt counts. The text may be untrusted or sensitive; the caller authorizes its sharing.

type Scope

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

Scope is a one-turn, non-resettable delegation budget with immutable child definitions. It is safe for concurrent calls, but permits only one active child. Do not copy a Scope. No background work or resources require Close.

func New

func New(cfg Config) (*Scope, error)

New validates all child configurations before returning a scope. It does not invoke models or handlers. Child limits default to four model steps and eight tool attempts; hard ceilings are 16 and 32 respectively.

func (*Scope) Run

func (s *Scope) Run(ctx context.Context, name, task string) (Result, error)

Run synchronously executes one independent child turn. The caller must pass a context and supply cooperating models/tools. Cancellation does not roll back effects. Failed runs return no child transcript or raw error.

func (*Scope) Stats

func (s *Scope) Stats() Stats

Stats returns a coherent copy of the scope's current counters.

func (*Scope) Tool

func (s *Scope) Tool() (agent.Tool, error)

Tool creates a caller-registerable delegate tool tied to this scope. Register only on the intended parent for one turn. Names are a fixed enum, not a model-controlled registry. The parent gets only Result; errors follow the core's ordinary redaction policy.

type Stats

type Stats struct {
	Started           int
	Succeeded         int
	Failed            int
	ReservedSteps     int
	ReservedToolCalls int
	Active            bool
}

Stats describes lifetime reservations and outcomes, not a billable usage estimate. Started = Succeeded + Failed + one if Active.

Jump to

Keyboard shortcuts

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