orchestration

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentPool

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

AgentPool represents a pool of specialized agents

func NewAgentPool

func NewAgentPool() *AgentPool

NewAgentPool creates a new agent pool

func (*AgentPool) Add

func (p *AgentPool) Add(id string, agent *agent.Agent, description string)

Add adds an agent to the pool

func (*AgentPool) Get

func (p *AgentPool) Get(id string) (*agent.Agent, bool)

Get retrieves an agent from the pool

func (*AgentPool) GetDescription

func (p *AgentPool) GetDescription(id string) (string, bool)

GetDescription retrieves an agent's description

func (*AgentPool) List

func (p *AgentPool) List() map[string]*agent.Agent

List returns all agents in the pool

func (*AgentPool) ListDescriptions

func (p *AgentPool) ListDescriptions() map[string]string

ListDescriptions returns all agent descriptions

type AgentRegistry

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

AgentRegistry maintains a registry of available agents

func NewAgentRegistry

func NewAgentRegistry() *AgentRegistry

NewAgentRegistry creates a new agent registry

func (*AgentRegistry) Get

func (r *AgentRegistry) Get(id string) (*agent.Agent, bool)

Get retrieves an agent from the registry

func (*AgentRegistry) List

func (r *AgentRegistry) List() map[string]*agent.Agent

List returns all registered agents

func (*AgentRegistry) Register

func (r *AgentRegistry) Register(id string, agent *agent.Agent)

Register registers an agent with the registry

type CodeOrchestrator

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

CodeOrchestrator orchestrates agents using code-defined workflows

func NewCodeOrchestrator

func NewCodeOrchestrator(registry *AgentRegistry) *CodeOrchestrator

NewCodeOrchestrator creates a new code orchestrator

func (*CodeOrchestrator) ExecuteWorkflow

func (o *CodeOrchestrator) ExecuteWorkflow(ctx context.Context, workflow *Workflow) (string, error)

ExecuteWorkflow executes a workflow

type DelegationAgent

type DelegationAgent struct {
	*agent.Agent
	// contains filtered or unexported fields
}

DelegationAgent is an agent that can delegate tasks to other agents

func NewDelegationAgent

func NewDelegationAgent(baseAgent *agent.Agent, registry *AgentRegistry) *DelegationAgent

NewDelegationAgent creates a new delegation agent

func (*DelegationAgent) Delegate

func (a *DelegationAgent) Delegate(ctx context.Context, targetAgentID string, query string, preserveMemory bool) (string, error)

Delegate delegates a task to another agent

type HandoffRequest

type HandoffRequest struct {
	// TargetAgentID is the ID of the agent to hand off to
	TargetAgentID string

	// Reason explains why the handoff is happening
	Reason string

	// Context contains additional context for the target agent
	Context map[string]interface{}

	// Query is the query to send to the target agent
	Query string

	// PreserveMemory indicates whether to copy memory to the target agent
	PreserveMemory bool
}

HandoffRequest represents a request to hand off to another agent

type HandoffResult

type HandoffResult struct {
	// AgentID is the ID of the agent that handled the request
	AgentID string

	// Response is the response from the agent
	Response string

	// Completed indicates whether the task was completed
	Completed bool

	// NextHandoff is the next handoff request, if any
	NextHandoff *HandoffRequest
}

HandoffResult represents the result of a handoff

type LLMOrchestrator

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

LLMOrchestrator orchestrates the execution of a query using multiple agents

func NewLLMOrchestrator

func NewLLMOrchestrator(registry *AgentRegistry, planner interfaces.LLM) *LLMOrchestrator

NewLLMOrchestrator creates a new LLM orchestrator

func (*LLMOrchestrator) Execute

func (o *LLMOrchestrator) Execute(ctx context.Context, query string) (string, error)

Execute executes a query using the orchestrator

func (*LLMOrchestrator) WithLogger

func (o *LLMOrchestrator) WithLogger(logger logging.Logger) *LLMOrchestrator

WithLogger sets the logger for the orchestrator

type LLMRouter

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

LLMRouter uses an LLM to determine which agent should handle a request

func NewLLMRouter

func NewLLMRouter(llm interfaces.LLM) *LLMRouter

NewLLMRouter creates a new LLM router

func (*LLMRouter) Route

func (r *LLMRouter) Route(ctx context.Context, query string, context map[string]interface{}) (string, error)

Route determines which agent should handle a request

func (*LLMRouter) WithLogger

func (r *LLMRouter) WithLogger(logger logging.Logger) *LLMRouter

WithLogger sets the logger for the router

type Orchestrator

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

Orchestrator orchestrates handoffs between agents

func NewOrchestrator

func NewOrchestrator(registry *AgentRegistry, router Router) *Orchestrator

NewOrchestrator creates a new orchestrator

func (*Orchestrator) HandleRequest

func (o *Orchestrator) HandleRequest(ctx context.Context, query string, initialContext map[string]interface{}) (*HandoffResult, error)

HandleRequest handles a request, potentially routing it through multiple agents

func (*Orchestrator) WithLogger

func (o *Orchestrator) WithLogger(logger logging.Logger) *Orchestrator

WithLogger sets the logger for the orchestrator

type Plan

type Plan struct {
	// Steps is the list of steps in the plan
	Steps []Step `json:"steps"`

	// FinalAgentID is the ID of the agent that should provide the final response
	FinalAgentID string `json:"final_agent_id"`
}

Plan represents an orchestration plan

type Router

type Router interface {
	Route(ctx context.Context, query string, context map[string]interface{}) (string, error)
}

Router determines which agent should handle a request

type SimpleRouter

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

SimpleRouter routes requests based on a simple keyword matching

func NewSimpleRouter

func NewSimpleRouter() *SimpleRouter

NewSimpleRouter creates a new simple router

func (*SimpleRouter) AddRoute

func (r *SimpleRouter) AddRoute(keyword string, agentID string)

AddRoute adds a route to the router

func (*SimpleRouter) Route

func (r *SimpleRouter) Route(ctx context.Context, query string, context map[string]interface{}) (string, error)

Route determines which agent should handle a request

type Step

type Step struct {
	// AgentID is the ID of the agent to execute
	AgentID string `json:"agent_id"`

	// Input is the input to provide to the agent
	Input string `json:"input"`

	// Description explains the purpose of this step
	Description string `json:"description"`

	// DependsOn lists the IDs of steps that must complete before this one
	DependsOn []string `json:"depends_on,omitempty"`
}

Step represents a single step in an orchestration plan

type Task

type Task struct {
	// ID is the unique identifier for the task
	ID string

	// AgentID is the ID of the agent to execute the task
	AgentID string

	// Input is the input to provide to the agent
	Input string

	// Dependencies are the IDs of tasks that must complete before this one
	Dependencies []string

	// Status is the current status of the task
	Status TaskStatus

	// Result is the result of the task
	Result string

	// Error is any error that occurred during execution
	Error error
}

Task represents a task to be executed by an agent

type TaskStatus

type TaskStatus string

TaskStatus represents the status of a task

const (
	// TaskPending indicates the task is pending
	TaskPending TaskStatus = "pending"

	// TaskRunning indicates the task is running
	TaskRunning TaskStatus = "running"

	// TaskCompleted indicates the task is completed
	TaskCompleted TaskStatus = "completed"

	// TaskFailed indicates the task failed
	TaskFailed TaskStatus = "failed"
)

type Workflow

type Workflow struct {
	// Tasks is the list of tasks in the workflow
	Tasks []*Task

	// Results is a map of task IDs to results
	Results map[string]string

	// Errors is a map of task IDs to errors
	Errors map[string]error

	// FinalTaskID is the ID of the task that produces the final result
	FinalTaskID string
}

Workflow represents a workflow of tasks

func NewWorkflow

func NewWorkflow() *Workflow

NewWorkflow creates a new workflow

func (*Workflow) AddTask

func (w *Workflow) AddTask(id string, agentID string, input string, dependencies []string)

AddTask adds a task to the workflow

func (*Workflow) SetFinalTask

func (w *Workflow) SetFinalTask(id string)

SetFinalTask sets the final task

Jump to

Keyboard shortcuts

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