subagent

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package subagent lets the agent delegate to isolated child agents (FR-09). A subagent reuses the same harness loop with its own prompt, tool subset, and permission mode, giving context isolation. It is exposed to the parent as an "Agent" CoreTool; recursion is bounded by a depth guard carried on the context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTool

func NewTool(cfg Config) tool.CoreTool

NewTool builds the "Agent" CoreTool that dispatches to a named subagent.

func Run

func Run(ctx context.Context, cfg Config, agentType, prompt, workDir string) (string, error)

Run executes the named agent from cfg.Agents to completion and returns its final text. It is the programmatic entry point (the Agent tool uses the same machinery); callers like the coordinator use it to fan out work directly.

Types

type Config

type Config struct {
	Provider    llm.Provider
	ParentTools *tool.Registry
	Agents      map[string]Definition
	MaxDepth    int // default 3
	CanUseTool  permission.CanUseTool
	Hooks       harness.HookRunner
	// Transcript, when non-nil, persists each subagent run to its own sidechain
	// file under the parent session (whose id is read from the context). Subagent
	// tokens are recorded there, separate from the parent's totals.
	Transcript *transcript.Store
}

Config wires the Agent tool.

type Definition

type Definition struct {
	Description    string          // shown to the parent model in the Agent tool prompt
	Prompt         []string        // the subagent's system prompt
	Tools          []string        // tool names it may use (empty = inherit all)
	PermissionMode permission.Mode // its permission mode (default: parent's)
	MaxTurns       int
}

Definition configures a named subagent (FR-09.1).

Jump to

Keyboard shortcuts

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