subagent

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentDefinition

type AgentDefinition struct {
	Name string
	// Description tells the model when to delegate to this agent.
	Description  string
	SystemPrompt string

	// Tools narrows the agent's tools; empty or {"*"} means all.
	Tools           []string
	DisallowedTools []string

	// Model is a model name; "inherit" or empty means the parent's.
	Model string

	// MaxTurns of zero means the subagent default.
	MaxTurns int

	// Origin is the definition's file or "builtin", for error messages.
	Origin string
}

func Definitions

func Definitions(cwd, smallModel string, loaded []AgentDefinition) []AgentDefinition

Definitions lets loaded definitions replace built-in ones by name. smallModel runs the built-in explore agent.

func LoadDir

func LoadDir(dir string) (defs []AgentDefinition, errs []error)

LoadDir reports broken files and skips them, so one bad file doesn't hide the rest. A missing dir holds no agents.

func LoadFile

func LoadFile(path string) (AgentDefinition, error)

func (*AgentDefinition) Agent

func (d *AgentDefinition) Agent(deps BuildDeps) (coresub.Agent, error)

Agent gives each run its own tools (see toolPool) and its own prompt-cache key.

func (*AgentDefinition) Validate

func (d *AgentDefinition) Validate() error

type BuildDeps

type BuildDeps struct {
	// Workspace is the parent's; each run gets its own read state (see
	// toolPool).
	Workspace tools.Workspace

	// MainTools excludes the subagent tool, so a sub-agent can't spawn
	// another.
	MainTools []agentcore.Tool

	DefaultModel agentcore.Model
	ResolveModel func(name string) (agentcore.Model, error)

	// CompactAt and Retry match the parent's.
	CompactAt int
	Retry     retry.Policy

	// SessionID prefixes each run's prompt-cache key.
	SessionID string

	// Middleware wraps the sub-agents' tool calls; a sub-agent's loop
	// inherits none from the parent.
	Middleware []agentcore.ToolMiddleware

	// Emit may return nil to drop a run's events.
	Emit func(coresub.Spawn) func(agentcore.Event) error
}

Jump to

Keyboard shortcuts

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