Help us shape the future of Go! Take the 2026 Go Developer Survey

subagent

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package subagent runs child agents in-process.

It lives under runtime/ rather than plugins/ because it must import runtime/agent to construct a child — the same reason agent/coding is registered from runtime/agent. Kind names are independent of package paths.

Why the child needs its own tool runtime

Wiring the parent's tool runtime here would be a dependency cycle:

tools.default → tool.subagent.default → subagent.default → tools.default

pluginkit rejects that at build time. So deps.tools must point at a sibling runtime instance, and since that instance does not mount tool/subagent, "only the main agent can delegate" stops being a policy and becomes structural.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg Config, deps Deps) (subagent.Spawner, error)

New registers subagent/inprocess: Run a child agent in-process from an agents/<name>.md definition and return only its conclusion.

Best practices:

  • deps.tools must be a sibling tools/runtime instance that does NOT mount tool/subagent: wiring the parent's runtime is a dependency cycle, and the separate instance is what makes 'only the main agent delegates' structural.
  • Give the child a narrower tool set than the parent — read-only is the common case. Delegation is for context isolation, not for a second agent editing the same workspace.
  • Pair with prompt/section/subagents so the parent can see who it may delegate to; the delegate tool's description is static and cannot list definitions read from disk.
  • Raise the delegate entry in the parent's toolTimeouts: a child agent takes far longer than a normal tool call.

Types

type Config

type Config struct {
	// Dirs are definition directories in precedence order; defaults to local:agents then global:agents.
	Dirs []string `json:"dirs,omitempty"`
	// MaxSteps is step cap for definitions that do not set their own; defaults to 20.
	MaxSteps int `json:"maxSteps,omitempty"`
	// TimeoutSeconds is wall clock for one delegation; 0 leaves the delegate tool's own timeout as the only bound.
	TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
}

type Deps

type Deps struct {
	Workspace    workspace.Service        `json:"workspace"`
	SessionStore agentkit.SessionStore    `json:"sessionStore"`
	LLM          agentkit.LLMProvider     `json:"llm"`
	Tools        agentkit.ToolRuntime     `json:"tools"`
	Prompt       agentkit.PromptAssembler `json:"prompt"`
	Hooks        agentkit.HookRuntime     `json:"hooks,omitempty"`
	Compaction   []compaction.Service     `json:"compaction,omitempty"`
}

type Spawner

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

func (*Spawner) Definitions

func (s *Spawner) Definitions(ctx context.Context) ([]subagent.Definition, error)

func (*Spawner) Run

Jump to

Keyboard shortcuts

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