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 ¶
- type ArtifactService
- type CheckpointManager
- type Config
- type IndexService
- type ParentMap
- type Runner
- func (r *Runner) AppName() string
- func (r *Runner) CheckpointManager() CheckpointManager
- func (r *Runner) FindAgent(name string) agent.Agent
- func (r *Runner) IsCheckpointEnabled() bool
- func (r *Runner) ListAgents() []agent.Agent
- func (r *Runner) RootAgent() agent.Agent
- func (r *Runner) Run(ctx context.Context, userID, sessionID string, content *agent.Content, ...) iter.Seq2[*agent.Event, error]
- type TransferRestrictable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArtifactService ¶
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 Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner orchestrates agent execution within sessions.
func (*Runner) CheckpointManager ¶
func (r *Runner) CheckpointManager() CheckpointManager
CheckpointManager returns the checkpoint manager (may be nil).
func (*Runner) FindAgent ¶
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 ¶
IsCheckpointEnabled returns whether checkpointing is enabled.
func (*Runner) ListAgents ¶
ListAgents returns all agents in the runner's agent tree.
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.