Documentation
¶
Overview ¶
Package planning provides task decomposition and strategy planning capabilities for agents.
Index ¶
- Constants
- type AgentExecutor
- func (e *AgentExecutor) Cancel(planID string) error
- func (e *AgentExecutor) Execute(ctx context.Context, plan *Plan) (*PlanResult, error)
- func (e *AgentExecutor) ExecuteStep(ctx context.Context, step *Step) (*StepResult, error)
- func (e *AgentExecutor) GetStatus(planID string) (*PlanStatus, error)
- func (e *AgentExecutor) Pause(planID string) error
- func (e *AgentExecutor) Resume(planID string) error
- type AgentRegistry
- type BackwardChainingStrategy
- type DecompositionStrategy
- type DefaultOptimizer
- type DependencyValidator
- type ExecutionState
- type ExecutorOption
- type ExpectedOutcome
- type HierarchicalStrategy
- type MockAgent
- func (m *MockAgent) Batch(ctx context.Context, inputs []*core.AgentInput) ([]*core.AgentOutput, error)
- func (m *MockAgent) Capabilities() []string
- func (m *MockAgent) Description() string
- func (m *MockAgent) Invoke(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error)
- func (m *MockAgent) Name() string
- func (m *MockAgent) Pipe(next core.Runnable[*core.AgentOutput, any]) core.Runnable[*core.AgentInput, any]
- func (m *MockAgent) SetInvokeFn(...)
- func (m *MockAgent) Stream(ctx context.Context, input *core.AgentInput) (<-chan core.StreamChunk[*core.AgentOutput], error)
- func (m *MockAgent) WithCallbacks(callbacks ...core.Callback) core.Runnable[*core.AgentInput, *core.AgentOutput]
- func (m *MockAgent) WithConfig(config core.RunnableConfig) core.Runnable[*core.AgentInput, *core.AgentOutput]
- type MockLLMClient
- func (m *MockLLMClient) Chat(ctx context.Context, messages []llm.Message) (*llm.CompletionResponse, error)
- func (m *MockLLMClient) Complete(ctx context.Context, req *llm.CompletionRequest) (*llm.CompletionResponse, error)
- func (m *MockLLMClient) IsAvailable() bool
- func (m *MockLLMClient) Provider() constants.Provider
- type MockLogger
- func (m *MockLogger) Debug(args ...interface{})
- func (m *MockLogger) Debugf(template string, args ...interface{})
- func (m *MockLogger) Debugw(msg string, keysAndValues ...interface{})
- func (m *MockLogger) Error(args ...interface{})
- func (m *MockLogger) Errorf(template string, args ...interface{})
- func (m *MockLogger) Errorw(msg string, keysAndValues ...interface{})
- func (m *MockLogger) Fatal(args ...interface{})
- func (m *MockLogger) Fatalf(template string, args ...interface{})
- func (m *MockLogger) Fatalw(msg string, keysAndValues ...interface{})
- func (m *MockLogger) Flush() error
- func (m *MockLogger) Info(args ...interface{})
- func (m *MockLogger) Infof(template string, args ...interface{})
- func (m *MockLogger) Infow(msg string, keysAndValues ...interface{})
- func (m *MockLogger) SetLevel(level loggercore.Level)
- func (m *MockLogger) Warn(args ...interface{})
- func (m *MockLogger) Warnf(template string, args ...interface{})
- func (m *MockLogger) Warnw(msg string, keysAndValues ...interface{})
- func (m *MockLogger) With(keyValues ...interface{}) loggercore.Logger
- func (m *MockLogger) WithCallerSkip(skip int) loggercore.Logger
- func (m *MockLogger) WithCtx(ctx context.Context, keyValues ...interface{}) loggercore.Logger
- type MockMemoryManager
- func (m *MockMemoryManager) AddCase(ctx context.Context, caseMemory *interfaces.Case) error
- func (m *MockMemoryManager) AddConversation(ctx context.Context, conv *interfaces.Conversation) error
- func (m *MockMemoryManager) Clear(ctx context.Context) error
- func (m *MockMemoryManager) ClearConversation(ctx context.Context, sessionID string) error
- func (m *MockMemoryManager) Delete(ctx context.Context, key string) error
- func (m *MockMemoryManager) DeleteCase(ctx context.Context, caseID string) error
- func (m *MockMemoryManager) GetCase(ctx context.Context, caseID string) (*interfaces.Case, error)
- func (m *MockMemoryManager) GetConversationHistory(ctx context.Context, sessionID string, limit int) ([]*interfaces.Conversation, error)
- func (m *MockMemoryManager) Retrieve(ctx context.Context, key string) (interface{}, error)
- func (m *MockMemoryManager) SearchSimilarCases(ctx context.Context, query string, limit int) ([]*interfaces.Case, error)
- func (m *MockMemoryManager) Store(ctx context.Context, key string, value interface{}) error
- func (m *MockMemoryManager) UpdateCase(ctx context.Context, caseMemory *interfaces.Case) error
- type NoOpStrategy
- type OptimizationAgent
- type Phase
- type Plan
- type PlanConstraints
- type PlanExecutor
- type PlanMetrics
- type PlanOptimizer
- type PlanResult
- type PlanStatus
- type PlanStrategy
- type PlanValidator
- type Planner
- type PlannerOption
- type PlanningAgent
- type ResourceValidator
- type RetryPolicy
- type SmartPlanner
- func (p *SmartPlanner) AddValidator(validator PlanValidator)
- func (p *SmartPlanner) CreatePlan(ctx context.Context, goal string, constraints PlanConstraints) (*Plan, error)
- func (p *SmartPlanner) DecomposePlan(ctx context.Context, plan *Plan, step *Step) ([]*Step, error)
- func (p *SmartPlanner) OptimizePlan(ctx context.Context, plan *Plan) (*Plan, error)
- func (p *SmartPlanner) RefinePlan(ctx context.Context, plan *Plan, feedback string) (*Plan, error)
- func (p *SmartPlanner) RegisterStrategy(name string, strategy PlanStrategy)
- func (p *SmartPlanner) ValidatePlan(ctx context.Context, plan *Plan) (bool, []string, error)
- type Step
- type StepResult
- type StepStatus
- type StepType
- type StrategyAgent
- type TaskDecompositionAgent
- type TimeValidator
- type ValidationAgent
Constants ¶
const ( AgentPlanning = "planning_agent" AgentTaskDecomposition = "task_decomposition_agent" AgentStrategy = "strategy_agent" )
Agent names
const ( DescPlanning = "Creates and executes plans to achieve goals" DescTaskDecomposition = "Decomposes complex tasks into manageable subtasks" DescStrategyAgent = "Selects and applies planning strategies to optimize plans" )
Agent descriptions
const ( StrategyDecomposition = "decomposition" StrategyBackwardChaining = "backward_chaining" StrategyHierarchical = "hierarchical" StrategyForwardChaining = "forward_chaining" StrategyGoalOriented = "goal_oriented" )
Strategy names
const ( StatusPending = "pending" StatusInProgress = "in_progress" StatusCompleted = "completed" StatusFailed = "failed" StatusCanceled = "canceled" )
Plan statuses
const ( DefaultMaxSteps = 20 DefaultMaxDuration = 3600 // seconds DefaultMaxParallelism = 5 DefaultRetryAttempts = 3 )
Plan constraints defaults
const ( ErrPlanningFailed = "planning failed" ErrPlanExecutionFailed = "plan execution failed" ErrInvalidPlan = "invalid plan" ErrStepFailed = "step execution failed" ErrDependencyNotMet = "dependency not met" ErrTimeoutExceeded = "timeout exceeded" )
Planning error messages
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentExecutor ¶
type AgentExecutor struct {
// contains filtered or unexported fields
}
AgentExecutor executes plans using agents
func NewAgentExecutor ¶
func NewAgentExecutor(logger loggercore.Logger, opts ...ExecutorOption) *AgentExecutor
NewAgentExecutor creates a new agent-based plan executor
func (*AgentExecutor) Cancel ¶
func (e *AgentExecutor) Cancel(planID string) error
Cancel cancels plan execution
func (*AgentExecutor) Execute ¶
func (e *AgentExecutor) Execute(ctx context.Context, plan *Plan) (*PlanResult, error)
Execute executes a plan
func (*AgentExecutor) ExecuteStep ¶
func (e *AgentExecutor) ExecuteStep(ctx context.Context, step *Step) (*StepResult, error)
ExecuteStep executes a single step (implements interface)
func (*AgentExecutor) GetStatus ¶
func (e *AgentExecutor) GetStatus(planID string) (*PlanStatus, error)
GetStatus gets the current status of a plan
func (*AgentExecutor) Pause ¶
func (e *AgentExecutor) Pause(planID string) error
Pause pauses plan execution
func (*AgentExecutor) Resume ¶
func (e *AgentExecutor) Resume(planID string) error
Resume resumes plan execution
type AgentRegistry ¶
type AgentRegistry struct {
// contains filtered or unexported fields
}
AgentRegistry manages available agents
func NewAgentRegistry ¶
func NewAgentRegistry() *AgentRegistry
NewAgentRegistry creates a new agent registry
func (*AgentRegistry) GetAgent ¶
func (r *AgentRegistry) GetAgent(name string) core.Agent
GetAgent gets an agent by name
func (*AgentRegistry) RegisterAgent ¶
func (r *AgentRegistry) RegisterAgent(name string, agent core.Agent)
RegisterAgent registers an agent
type BackwardChainingStrategy ¶
type BackwardChainingStrategy struct{}
BackwardChainingStrategy works backward from goal to current state
func (*BackwardChainingStrategy) Apply ¶
func (s *BackwardChainingStrategy) Apply(ctx context.Context, plan *Plan, constraints PlanConstraints) (*Plan, error)
func (*BackwardChainingStrategy) Name ¶
func (s *BackwardChainingStrategy) Name() string
type DecompositionStrategy ¶
type DecompositionStrategy struct{}
DecompositionStrategy breaks down complex goals into simpler steps
func (*DecompositionStrategy) Apply ¶
func (s *DecompositionStrategy) Apply(ctx context.Context, plan *Plan, constraints PlanConstraints) (*Plan, error)
func (*DecompositionStrategy) Name ¶
func (s *DecompositionStrategy) Name() string
type DefaultOptimizer ¶
type DefaultOptimizer struct{}
DefaultOptimizer provides basic plan optimization
type DependencyValidator ¶
type DependencyValidator struct{}
DependencyValidator validates step dependencies
type ExecutionState ¶
type ExecutionState struct {
Plan *Plan
Status PlanStatus
StartTime time.Time
EndTime time.Time
StepResults map[string]*StepResult
CurrentStep string
PauseChan chan struct{}
CancelChan chan struct{}
// contains filtered or unexported fields
}
ExecutionState tracks the state of a plan execution
type ExecutorOption ¶
type ExecutorOption func(*AgentExecutor)
ExecutorOption configures the executor
func WithMaxConcurrency ¶
func WithMaxConcurrency(max int) ExecutorOption
WithMaxConcurrency sets the maximum concurrent step executions
func WithRetryPolicy ¶
func WithRetryPolicy(policy RetryPolicy) ExecutorOption
WithRetryPolicy sets the retry policy
type ExpectedOutcome ¶
type ExpectedOutcome struct {
Description string `json:"description"`
Criteria []string `json:"criteria"`
Metrics map[string]interface{} `json:"metrics,omitempty"`
}
ExpectedOutcome defines what we expect from a step
type HierarchicalStrategy ¶
type HierarchicalStrategy struct {
// contains filtered or unexported fields
}
HierarchicalStrategy creates multi-level plans
func (*HierarchicalStrategy) Apply ¶
func (s *HierarchicalStrategy) Apply(ctx context.Context, plan *Plan, constraints PlanConstraints) (*Plan, error)
func (*HierarchicalStrategy) Name ¶
func (s *HierarchicalStrategy) Name() string
type MockAgent ¶
type MockAgent struct {
// contains filtered or unexported fields
}
MockAgent is a complete mock agent for testing
func NewMockAgent ¶
func (*MockAgent) Batch ¶
func (m *MockAgent) Batch(ctx context.Context, inputs []*core.AgentInput) ([]*core.AgentOutput, error)
func (*MockAgent) Capabilities ¶
func (*MockAgent) Description ¶
func (*MockAgent) Invoke ¶
func (m *MockAgent) Invoke(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error)
func (*MockAgent) SetInvokeFn ¶
func (m *MockAgent) SetInvokeFn(fn func(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error))
SetInvokeFn sets a custom invoke function for testing
func (*MockAgent) Stream ¶
func (m *MockAgent) Stream(ctx context.Context, input *core.AgentInput) (<-chan core.StreamChunk[*core.AgentOutput], error)
func (*MockAgent) WithCallbacks ¶
func (m *MockAgent) WithCallbacks(callbacks ...core.Callback) core.Runnable[*core.AgentInput, *core.AgentOutput]
func (*MockAgent) WithConfig ¶
func (m *MockAgent) WithConfig(config core.RunnableConfig) core.Runnable[*core.AgentInput, *core.AgentOutput]
type MockLLMClient ¶
type MockLLMClient struct {
CompleteFn func(ctx context.Context, req *llm.CompletionRequest) (*llm.CompletionResponse, error)
ChatFn func(ctx context.Context, messages []llm.Message) (*llm.CompletionResponse, error)
ProviderFn func() constants.Provider
IsAvailableFn func() bool
}
MockLLMClient is a complete mock LLM client for testing
func (*MockLLMClient) Chat ¶
func (m *MockLLMClient) Chat(ctx context.Context, messages []llm.Message) (*llm.CompletionResponse, error)
func (*MockLLMClient) Complete ¶
func (m *MockLLMClient) Complete(ctx context.Context, req *llm.CompletionRequest) (*llm.CompletionResponse, error)
func (*MockLLMClient) IsAvailable ¶
func (m *MockLLMClient) IsAvailable() bool
func (*MockLLMClient) Provider ¶
func (m *MockLLMClient) Provider() constants.Provider
type MockLogger ¶
type MockLogger struct{}
MockLogger is a complete mock logger for testing
func (*MockLogger) Debug ¶
func (m *MockLogger) Debug(args ...interface{})
func (*MockLogger) Debugf ¶
func (m *MockLogger) Debugf(template string, args ...interface{})
func (*MockLogger) Debugw ¶
func (m *MockLogger) Debugw(msg string, keysAndValues ...interface{})
func (*MockLogger) Error ¶
func (m *MockLogger) Error(args ...interface{})
func (*MockLogger) Errorf ¶
func (m *MockLogger) Errorf(template string, args ...interface{})
func (*MockLogger) Errorw ¶
func (m *MockLogger) Errorw(msg string, keysAndValues ...interface{})
func (*MockLogger) Fatal ¶
func (m *MockLogger) Fatal(args ...interface{})
func (*MockLogger) Fatalf ¶
func (m *MockLogger) Fatalf(template string, args ...interface{})
func (*MockLogger) Fatalw ¶
func (m *MockLogger) Fatalw(msg string, keysAndValues ...interface{})
func (*MockLogger) Flush ¶
func (m *MockLogger) Flush() error
func (*MockLogger) Info ¶
func (m *MockLogger) Info(args ...interface{})
func (*MockLogger) Infof ¶
func (m *MockLogger) Infof(template string, args ...interface{})
func (*MockLogger) Infow ¶
func (m *MockLogger) Infow(msg string, keysAndValues ...interface{})
func (*MockLogger) SetLevel ¶
func (m *MockLogger) SetLevel(level loggercore.Level)
func (*MockLogger) Warn ¶
func (m *MockLogger) Warn(args ...interface{})
func (*MockLogger) Warnf ¶
func (m *MockLogger) Warnf(template string, args ...interface{})
func (*MockLogger) Warnw ¶
func (m *MockLogger) Warnw(msg string, keysAndValues ...interface{})
func (*MockLogger) With ¶
func (m *MockLogger) With(keyValues ...interface{}) loggercore.Logger
func (*MockLogger) WithCallerSkip ¶
func (m *MockLogger) WithCallerSkip(skip int) loggercore.Logger
func (*MockLogger) WithCtx ¶
func (m *MockLogger) WithCtx(ctx context.Context, keyValues ...interface{}) loggercore.Logger
type MockMemoryManager ¶
type MockMemoryManager struct {
AddConversationFn func(ctx context.Context, conv *interfaces.Conversation) error
GetConversationHistoryFn func(ctx context.Context, sessionID string, limit int) ([]*interfaces.Conversation, error)
ClearConversationFn func(ctx context.Context, sessionID string) error
AddCaseFn func(ctx context.Context, caseMemory *interfaces.Case) error
SearchSimilarCasesFn func(ctx context.Context, query string, limit int) ([]*interfaces.Case, error)
GetCaseFn func(ctx context.Context, caseID string) (*interfaces.Case, error)
UpdateCaseFn func(ctx context.Context, caseMemory *interfaces.Case) error
DeleteCaseFn func(ctx context.Context, caseID string) error
StoreFn func(ctx context.Context, key string, value interface{}) error
RetrieveFn func(ctx context.Context, key string) (interface{}, error)
DeleteFn func(ctx context.Context, key string) error
}
MockMemoryManager is a complete mock memory manager for testing
func (*MockMemoryManager) AddCase ¶
func (m *MockMemoryManager) AddCase(ctx context.Context, caseMemory *interfaces.Case) error
func (*MockMemoryManager) AddConversation ¶
func (m *MockMemoryManager) AddConversation(ctx context.Context, conv *interfaces.Conversation) error
func (*MockMemoryManager) Clear ¶
func (m *MockMemoryManager) Clear(ctx context.Context) error
Clear removes all memory (implements MemoryManager interface)
func (*MockMemoryManager) ClearConversation ¶
func (m *MockMemoryManager) ClearConversation(ctx context.Context, sessionID string) error
func (*MockMemoryManager) Delete ¶
func (m *MockMemoryManager) Delete(ctx context.Context, key string) error
Delete removes stored data by key
func (*MockMemoryManager) DeleteCase ¶
func (m *MockMemoryManager) DeleteCase(ctx context.Context, caseID string) error
func (*MockMemoryManager) GetCase ¶
func (m *MockMemoryManager) GetCase(ctx context.Context, caseID string) (*interfaces.Case, error)
func (*MockMemoryManager) GetConversationHistory ¶
func (m *MockMemoryManager) GetConversationHistory(ctx context.Context, sessionID string, limit int) ([]*interfaces.Conversation, error)
func (*MockMemoryManager) Retrieve ¶
func (m *MockMemoryManager) Retrieve(ctx context.Context, key string) (interface{}, error)
Retrieve fetches stored data by key
func (*MockMemoryManager) SearchSimilarCases ¶
func (m *MockMemoryManager) SearchSimilarCases(ctx context.Context, query string, limit int) ([]*interfaces.Case, error)
func (*MockMemoryManager) Store ¶
func (m *MockMemoryManager) Store(ctx context.Context, key string, value interface{}) error
Store persists key-value data
func (*MockMemoryManager) UpdateCase ¶
func (m *MockMemoryManager) UpdateCase(ctx context.Context, caseMemory *interfaces.Case) error
type NoOpStrategy ¶
type NoOpStrategy struct{}
NoOpStrategy does nothing (used as fallback)
func (*NoOpStrategy) Apply ¶
func (s *NoOpStrategy) Apply(ctx context.Context, plan *Plan, constraints PlanConstraints) (*Plan, error)
func (*NoOpStrategy) Name ¶
func (s *NoOpStrategy) Name() string
type OptimizationAgent ¶
OptimizationAgent optimizes plans for efficiency
func NewOptimizationAgent ¶
func NewOptimizationAgent(optimizer PlanOptimizer) *OptimizationAgent
NewOptimizationAgent creates a new optimization agent
func (*OptimizationAgent) Execute ¶
func (a *OptimizationAgent) Execute(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error)
Execute optimizes a plan
type Plan ¶
type Plan struct {
ID string `json:"id"`
Goal string `json:"goal"`
Strategy string `json:"strategy"`
Steps []*Step `json:"steps"`
Dependencies map[string][]string `json:"dependencies"` // step ID -> dependent step IDs
Context map[string]interface{} `json:"context"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Status PlanStatus `json:"status"`
Metrics *PlanMetrics `json:"metrics,omitempty"`
}
Plan represents a structured plan for achieving a goal
type PlanConstraints ¶
type PlanConstraints struct {
MaxSteps int `json:"max_steps,omitempty"`
MaxDuration time.Duration `json:"max_duration,omitempty"`
RequiredSteps []string `json:"required_steps,omitempty"`
ForbiddenSteps []string `json:"forbidden_steps,omitempty"`
Resources map[string]interface{} `json:"resources,omitempty"`
Priority int `json:"priority,omitempty"`
}
PlanConstraints defines constraints for plan creation
type PlanExecutor ¶
type PlanExecutor interface {
// Execute executes a plan
Execute(ctx context.Context, plan *Plan) (*PlanResult, error)
// ExecuteStep executes a single step
ExecuteStep(ctx context.Context, step *Step) (*StepResult, error)
// Pause pauses plan execution
Pause(planID string) error
// Resume resumes plan execution
Resume(planID string) error
// Cancel cancels plan execution
Cancel(planID string) error
// GetStatus gets the current status of a plan
GetStatus(planID string) (*PlanStatus, error)
}
PlanExecutor executes plans using agents
type PlanMetrics ¶
type PlanMetrics struct {
TotalSteps int `json:"total_steps"`
CompletedSteps int `json:"completed_steps"`
FailedSteps int `json:"failed_steps"`
SkippedSteps int `json:"skipped_steps"`
TotalDuration time.Duration `json:"total_duration"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time,omitempty"`
SuccessRate float64 `json:"success_rate"`
}
PlanMetrics tracks plan execution metrics
type PlanOptimizer ¶
type PlanOptimizer interface {
// Optimize optimizes a plan
Optimize(ctx context.Context, plan *Plan) (*Plan, error)
}
PlanOptimizer optimizes plans for efficiency
type PlanResult ¶
type PlanResult struct {
PlanID string `json:"plan_id"`
Success bool `json:"success"`
CompletedSteps int `json:"completed_steps"`
FailedSteps int `json:"failed_steps"`
SkippedSteps int `json:"skipped_steps"`
TotalDuration time.Duration `json:"total_duration"`
StepResults map[string]*StepResult `json:"step_results"`
Error error `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
PlanResult contains the result of executing a plan
type PlanStatus ¶
type PlanStatus string
PlanStatus represents the status of a plan
const ( PlanStatusDraft PlanStatus = "draft" PlanStatusReady PlanStatus = "ready" PlanStatusExecuting PlanStatus = "executing" PlanStatusCompleted PlanStatus = "completed" PlanStatusFailed PlanStatus = "failed" PlanStatusCancelled PlanStatus = "cancelled" )
type PlanStrategy ¶
type PlanStrategy interface {
// Apply applies the strategy to a plan
Apply(ctx context.Context, plan *Plan, constraints PlanConstraints) (*Plan, error)
// Name returns the strategy name
Name() string
}
PlanStrategy defines a strategy for plan creation and refinement
type PlanValidator ¶
type PlanValidator interface {
// Validate checks if a plan is valid
Validate(ctx context.Context, plan *Plan) (bool, []string, error)
}
PlanValidator validates plans for feasibility
type Planner ¶
type Planner interface {
// CreatePlan creates a plan for achieving a goal
CreatePlan(ctx context.Context, goal string, constraints PlanConstraints) (*Plan, error)
// RefinePlan refines an existing plan based on feedback
RefinePlan(ctx context.Context, plan *Plan, feedback string) (*Plan, error)
// DecomposePlan breaks down a plan into more detailed steps
DecomposePlan(ctx context.Context, plan *Plan, step *Step) ([]*Step, error)
// OptimizePlan optimizes a plan for efficiency
OptimizePlan(ctx context.Context, plan *Plan) (*Plan, error)
// ValidatePlan validates that a plan is feasible
ValidatePlan(ctx context.Context, plan *Plan) (bool, []string, error)
}
Planner interface for creating and managing plans
type PlannerOption ¶
type PlannerOption func(*SmartPlanner)
PlannerOption configures the planner
func WithMaxDepth ¶
func WithMaxDepth(depth int) PlannerOption
WithMaxDepth sets the maximum planning depth
func WithOptimizer ¶
func WithOptimizer(optimizer PlanOptimizer) PlannerOption
WithOptimizer sets the plan optimizer
func WithTimeout ¶
func WithTimeout(timeout time.Duration) PlannerOption
WithTimeout sets the planning timeout
type PlanningAgent ¶
PlanningAgent is an agent that creates and executes plans
func NewPlanningAgent ¶
func NewPlanningAgent(planner Planner, executor PlanExecutor) *PlanningAgent
NewPlanningAgent creates a new planning agent
func (*PlanningAgent) Execute ¶
func (a *PlanningAgent) Execute(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error)
Execute implements the Agent interface
type ResourceValidator ¶
type ResourceValidator struct{}
ResourceValidator validates resource constraints
type RetryPolicy ¶
type RetryPolicy struct {
MaxRetries int `json:"max_retries"`
RetryDelay time.Duration `json:"retry_delay"`
BackoffFactor float64 `json:"backoff_factor"`
}
RetryPolicy defines retry behavior for failed steps
type SmartPlanner ¶
type SmartPlanner struct {
// contains filtered or unexported fields
}
SmartPlanner uses LLM and memory to create intelligent plans
func NewSmartPlanner ¶
func NewSmartPlanner(llmClient llm.Client, mem interfaces.MemoryManager, opts ...PlannerOption) *SmartPlanner
NewSmartPlanner creates a new smart planner
func (*SmartPlanner) AddValidator ¶
func (p *SmartPlanner) AddValidator(validator PlanValidator)
AddValidator adds a plan validator
func (*SmartPlanner) CreatePlan ¶
func (p *SmartPlanner) CreatePlan(ctx context.Context, goal string, constraints PlanConstraints) (*Plan, error)
CreatePlan creates a plan for achieving a goal
func (*SmartPlanner) DecomposePlan ¶
DecomposePlan breaks down a plan step into more detailed sub-steps
func (*SmartPlanner) OptimizePlan ¶
OptimizePlan optimizes a plan for efficiency
func (*SmartPlanner) RefinePlan ¶
RefinePlan refines an existing plan based on feedback
func (*SmartPlanner) RegisterStrategy ¶
func (p *SmartPlanner) RegisterStrategy(name string, strategy PlanStrategy)
RegisterStrategy registers a planning strategy
func (*SmartPlanner) ValidatePlan ¶
ValidatePlan validates that a plan is feasible
type Step ¶
type Step struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Type StepType `json:"type"`
Agent string `json:"agent,omitempty"` // Agent to execute this step
Parameters map[string]interface{} `json:"parameters,omitempty"`
Expected *ExpectedOutcome `json:"expected,omitempty"`
Priority int `json:"priority"`
EstimatedDuration time.Duration `json:"estimated_duration,omitempty"`
Status StepStatus `json:"status"`
Result *StepResult `json:"result,omitempty"`
}
Step represents a single step in a plan
type StepResult ¶
type StepResult struct {
Success bool `json:"success"`
Output interface{} `json:"output"`
Error string `json:"error,omitempty"`
Duration time.Duration `json:"duration"`
Timestamp time.Time `json:"timestamp"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
StepResult contains the execution result of a step
type StepStatus ¶
type StepStatus string
StepStatus represents the status of a step
const ( StepStatusPending StepStatus = "pending" StepStatusReady StepStatus = "ready" StepStatusExecuting StepStatus = "executing" StepStatusCompleted StepStatus = "completed" StepStatusFailed StepStatus = "failed" StepStatusSkipped StepStatus = "skipped" )
type StrategyAgent ¶
StrategyAgent selects and applies planning strategies
func NewStrategyAgent ¶
func NewStrategyAgent() *StrategyAgent
NewStrategyAgent creates a new strategy agent
func (*StrategyAgent) Execute ¶
func (a *StrategyAgent) Execute(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error)
Execute selects and applies a strategy to a plan
func (*StrategyAgent) RegisterStrategy ¶
func (a *StrategyAgent) RegisterStrategy(name string, strategy PlanStrategy)
RegisterStrategy registers a new strategy
type TaskDecompositionAgent ¶
TaskDecompositionAgent decomposes complex tasks into subtasks
func NewTaskDecompositionAgent ¶
func NewTaskDecompositionAgent(planner Planner) *TaskDecompositionAgent
NewTaskDecompositionAgent creates a new task decomposition agent
func (*TaskDecompositionAgent) Execute ¶
func (a *TaskDecompositionAgent) Execute(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error)
Execute decomposes a task into subtasks
type ValidationAgent ¶
ValidationAgent validates plans for feasibility
func NewValidationAgent ¶
func NewValidationAgent() *ValidationAgent
NewValidationAgent creates a new validation agent
func (*ValidationAgent) AddValidator ¶
func (a *ValidationAgent) AddValidator(validator PlanValidator)
AddValidator adds a validator
func (*ValidationAgent) Execute ¶
func (a *ValidationAgent) Execute(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error)
Execute validates a plan