runner

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package runner provides the orchestration layer for agent execution.

The Runner manages agent execution within sessions, handling:

  • Session creation and retrieval
  • Agent selection based on session history
  • Event streaming and persistence
  • Parent map for agent tree navigation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactService

type ArtifactService interface {
	agent.Artifacts
}

ArtifactService defines the interface for artifact storage.

type CheckpointManager

type CheckpointManager interface {
	// IsEnabled returns whether checkpointing is enabled.
	IsEnabled() bool

	// ClearCheckpoint removes a checkpoint.
	ClearCheckpoint(ctx context.Context, appName, userID, sessionID, taskID string) error
}

CheckpointManager defines the interface for checkpoint operations.

Architecture (ported from legacy Hector):

  • Checkpoints capture execution state at strategic points
  • Enables fault tolerance and HITL workflow recovery
  • Stored in session state under "pending_executions" key

type Config

type Config struct {
	// AppName identifies the application.
	AppName string

	// Agent is the root agent for execution.
	Agent agent.Agent

	// SessionService manages session lifecycle (SOURCE OF TRUTH).
	SessionService session.Service

	// ArtifactService manages artifact storage (optional).
	ArtifactService ArtifactService

	// IndexService provides semantic search over sessions (optional).
	// This is a SEARCH INDEX built on top of SessionService.
	// Can be rebuilt from SessionService at any time.
	IndexService IndexService

	// CheckpointManager handles execution state checkpointing (optional).
	// Enables fault tolerance and HITL workflow recovery.
	CheckpointManager CheckpointManager
}

Config contains the configuration for creating a Runner.

type IndexService

type IndexService interface {
	// Index adds session events to the search index.
	// Called after each turn (data already persisted to SessionService).
	Index(ctx context.Context, sess agent.Session) error

	// Search performs semantic similarity search.
	Search(ctx context.Context, req *memory.SearchRequest) (*memory.SearchResponse, error)
}

IndexService defines the interface for semantic search over sessions.

Architecture (derived from legacy Hector):

  • SessionService: SOURCE OF TRUTH (stores all events in SQL)
  • IndexService: SEARCH INDEX (can be rebuilt from SessionService)

The index is populated after each turn and can be rebuilt on startup.

type ParentMap

type ParentMap map[string]agent.Agent

ParentMap maps agent names to their parent agents.

func BuildParentMap

func BuildParentMap(root agent.Agent) (ParentMap, error)

BuildParentMap creates a parent map for the agent tree.

type Runner

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

Runner orchestrates agent execution within sessions.

func New

func New(cfg Config) (*Runner, error)

New creates a new Runner.

func (*Runner) AppName

func (r *Runner) AppName() string

AppName returns the application name.

func (*Runner) CheckpointManager

func (r *Runner) CheckpointManager() CheckpointManager

CheckpointManager returns the checkpoint manager (may be nil).

func (*Runner) FindAgent

func (r *Runner) FindAgent(name string) agent.Agent

FindAgent searches for an agent by name in the runner's agent tree. This provides the same functionality as ADK-Go's find_agent() method.

Example:

runner, _ := runner.New(runner.Config{Agent: coordinator})
researcher := runner.FindAgent("researcher")

func (*Runner) IsCheckpointEnabled

func (r *Runner) IsCheckpointEnabled() bool

IsCheckpointEnabled returns whether checkpointing is enabled.

func (*Runner) ListAgents

func (r *Runner) ListAgents() []agent.Agent

ListAgents returns all agents in the runner's agent tree.

func (*Runner) RootAgent

func (r *Runner) RootAgent() agent.Agent

RootAgent returns the root agent.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, userID, sessionID string, content *agent.Content, cfg agent.RunConfig) iter.Seq2[*agent.Event, error]

Run executes the agent for the given user input, yielding events. For each user message, it finds the proper agent within the agent tree to continue the conversation within the session.

type TransferRestrictable

type TransferRestrictable interface {
	DisallowTransferToParent() bool
	DisallowTransferToPeers() bool
}

TransferRestrictable is implemented by agents that can restrict transfers.

Jump to

Keyboard shortcuts

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