agent

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolNameRunBackgroundAgent   = "run_background_agent"
	ToolNameListBackgroundAgents = "list_background_agents"
	ToolNameViewBackgroundAgent  = "view_background_agent"
	ToolNameStopBackgroundAgent  = "stop_background_agent"
)

Variables

This section is empty.

Functions

func CreateToolSet added in v1.60.0

func CreateToolSet() (tools.ToolSet, error)

CreateToolSet is used by the tools registry.

func New added in v1.60.0

func New() tools.ToolSet

New returns a lightweight ToolSet for registering background agent tool definitions and instructions. It does not require a Runner and is suitable for use in the teamloader registry.

Types

type Handler

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

Handler owns all background agent tasks and provides tool handlers.

func NewHandler

func NewHandler(runner Runner) *Handler

NewHandler creates a new Handler with the given Runner.

func (*Handler) HandleList

HandleList lists all background agent tasks.

func (*Handler) HandleRun

func (h *Handler) HandleRun(ctx context.Context, sess *session.Session, toolCall tools.ToolCall) (*tools.ToolCallResult, error)

HandleRun starts a sub-agent task asynchronously and returns a task ID immediately.

func (*Handler) HandleStop

func (h *Handler) HandleStop(_ context.Context, _ *session.Session, toolCall tools.ToolCall) (*tools.ToolCallResult, error)

HandleStop cancels a running background agent task.

func (*Handler) HandleView

func (h *Handler) HandleView(_ context.Context, _ *session.Session, toolCall tools.ToolCall) (*tools.ToolCallResult, error)

HandleView returns the output and status of a specific background agent task.

func (*Handler) RegisterHandlers added in v1.30.1

func (h *Handler) RegisterHandlers(register func(name string, fn func(context.Context, *session.Session, tools.ToolCall) (*tools.ToolCallResult, error)))

RegisterHandlers adds all background agent tool handlers to the given dispatch map, keyed by tool name.

func (*Handler) StopAll

func (h *Handler) StopAll()

StopAll cancels all running tasks and waits for their goroutines to exit. Called during runtime shutdown to ensure clean teardown.

type RunBackgroundAgentArgs

type RunBackgroundAgentArgs struct {
	Agent          string `json:"agent" jsonschema:"The name of the sub-agent to run in the background."`
	Task           string `json:"task" jsonschema:"A clear and concise description of the task the agent should achieve."`
	ExpectedOutput string `json:"expected_output,omitempty" jsonschema:"The expected output from the agent (optional)."`
}

RunBackgroundAgentArgs specifies the parameters for dispatching a sub-agent task asynchronously.

type RunParams

type RunParams struct {
	AgentName      string
	Task           string
	ExpectedOutput string
	ParentSession  *session.Session
	OnContent      func(content string)
}

RunParams holds the parameters for running a sub-agent.

type RunResult

type RunResult struct {
	Result string // final assistant message on completion
	ErrMsg string // error detail if failed
}

RunResult holds the outcome of a sub-agent execution.

type Runner

type Runner interface {
	// CurrentAgentSubAgentNames returns the names of the current agent's sub-agents.
	CurrentAgentSubAgentNames() []string
	// RunAgent starts a sub-agent and blocks until completion or cancellation.
	RunAgent(ctx context.Context, params RunParams) *RunResult
}

Runner abstracts the runtime dependency for background agent execution.

type StopBackgroundAgentArgs

type StopBackgroundAgentArgs struct {
	TaskID string `json:"task_id" jsonschema:"The ID of the background agent task to stop."`
}

StopBackgroundAgentArgs specifies the task ID to cancel.

type ToolSet added in v1.60.0

type ToolSet struct{}

ToolSet provides tool definitions and instructions without a Runner.

func (*ToolSet) Instructions added in v1.60.0

func (t *ToolSet) Instructions() string

func (*ToolSet) Tools added in v1.60.0

func (t *ToolSet) Tools(context.Context) ([]tools.Tool, error)

type ViewBackgroundAgentArgs

type ViewBackgroundAgentArgs struct {
	TaskID string `json:"task_id" jsonschema:"The ID of the background agent task to view."`
}

ViewBackgroundAgentArgs specifies the task ID to inspect.

Jump to

Keyboard shortcuts

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