task

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package task provides a tool that lets the LLM spawn one-shot subagent runs for complex or parallelizable subtasks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatResult

func FormatResult(agent string, r subagent.Result) string

FormatResult formats a subagent result into a human-readable response string.

Types

type AgentInfo

type AgentInfo struct {
	Name        string
	Description string
}

AgentInfo describes an available subagent type for the tool description.

type Inputs

type Inputs struct {
	Description string `json:"description" jsonschema:"required,description=Short summary of the task (3-5 words)"`
	Prompt      string `json:"prompt" jsonschema:"required,description=Full task description for the subagent"`
	Agent       string `json:"agent,omitempty" jsonschema:"description=Agent type to use (omit for default)"`
}

Inputs defines the JSON schema for the Task tool parameters.

type RunFunc

type RunFunc func(ctx context.Context, agent string, prompt string) (subagent.Result, error)

RunFunc is the callback that spawns a subagent run. The caller (wiring layer) provides this — it resolves the agent name to a Runner and calls Runner.Run.

type Tool

type Tool struct {
	tool.Base

	// Run is set by the wiring layer after construction. Nil = tool returns an error.
	Run RunFunc
	// Agents lists available subagent types for the dynamic description.
	Agents []AgentInfo
}

Tool lets the LLM delegate work to a subagent with isolated context.

func New

func New(agents []AgentInfo) *Tool

New creates a Task tool with the given agent info. The Run callback must be set separately before the tool is usable.

func (*Tool) BuildDescription

func (t *Tool) BuildDescription() string

BuildDescription creates a dynamic tool description from available agents.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, args map[string]any) (string, error)

Execute validates input, runs the subagent, and formats the result.

func (*Tool) Name

func (t *Tool) Name() string

Name returns the tool's identifier.

func (*Tool) Sandboxable

func (t *Tool) Sandboxable() bool

Sandboxable returns false — the subagent manages its own sandbox.

func (*Tool) Schema

func (t *Tool) Schema() tool.Schema

Schema returns the provider-agnostic tool definition.

Jump to

Keyboard shortcuts

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