Documentation
¶
Index ¶
- Constants
- func NewAggregatorAgent(def agent.AgentDef, rt agent.Runtime) (agent.Agent, error)
- func NewClassifierAgent(def agent.AgentDef, rt agent.Runtime) (agent.Agent, error)
- func NewPlannerAgent(def agent.AgentDef, rt agent.Runtime) (agent.Agent, error)
- func NewReActAgent(def agent.AgentDef, rt agent.Runtime) (agent.Agent, error)
- func NewReActAgentWithClient(def agent.AgentDef, rt agent.Runtime, client OpenAIClient) (agent.Agent, error)
- func NewReActAgentWithProvider(def agent.AgentDef, rt agent.Runtime, client OpenAIClient, ...) (agent.Agent, error)
- type AgentInput
- type AggregationResult
- type AggregationStats
- type AggregatorAgent
- type AggregatorConfig
- type AlternativeClass
- type AlternativeStep
- type BackupPlan
- type BaseAgent
- func (b *BaseAgent) DefaultExecute(ctx context.Context, input *agent.Message) (*agent.Message, error)
- func (b *BaseAgent) DefaultStart(ctx context.Context) error
- func (b *BaseAgent) GetContext() context.Context
- func (b *BaseAgent) InitContext(ctx context.Context)
- func (b *BaseAgent) Name() string
- func (b *BaseAgent) Ready() bool
- func (b *BaseAgent) Role() string
- func (b *BaseAgent) SetReady(ready bool)
- func (b *BaseAgent) Stop(ctx context.Context) error
- type Category
- type ClassificationMetrics
- type ClassificationResult
- type ClassifierAgent
- func (c *ClassifierAgent) Execute(ctx context.Context, input *agent.Message) (*agent.Message, error)
- func (c *ClassifierAgent) Name() string
- func (c *ClassifierAgent) Ready() bool
- func (c *ClassifierAgent) Role() string
- func (c *ClassifierAgent) Start(ctx context.Context) error
- func (c *ClassifierAgent) Stop(ctx context.Context) error
- type ClassifierConfig
- type ConflictResolution
- type Example
- type ExamplePlan
- type GoalNode
- type GuidedStepResult
- type Logger
- type MCTSNode
- type MetacognitionModule
- type MockOpenAIClient
- func (m *MockOpenAIClient) AddResponse(resp openai.ChatCompletionResponse, err error)
- func (m *MockOpenAIClient) CreateChatCompletion(ctx context.Context, req openai.ChatCompletionRequest) (openai.ChatCompletionResponse, error)
- func (m *MockOpenAIClient) GetCalls() []openai.ChatCompletionRequest
- func (m *MockOpenAIClient) Reset()
- type OpenAIClient
- type PlanExecutionHistory
- type PlanStep
- type PlannerAgent
- type PlannerConfig
- type ProblemAnalysis
- type Producer
- type ReActAgent
- func (r *ReActAgent) ConnectMCPServers(ctx context.Context, serverConfigs []mcp.ServerConfig) error
- func (r *ReActAgent) Execute(ctx context.Context, input *agent.Message) (*agent.Message, error)
- func (r *ReActAgent) ExecuteWithSession(ctx context.Context, input *agent.Message, sess SessionProvider) (*agent.Message, error)
- func (r *ReActAgent) SetProvider(prov provider.Provider)
- func (r *ReActAgent) Start(ctx context.Context) error
- type ReasoningBranch
- type ReasoningPlan
- type RiskAssessment
- type RiskFactor
- type SemanticCluster
- type SessionProvider
Constants ¶
const ( // LLM-powered strategies StrategyConsensus = "consensus" StrategyWeighted = "weighted" StrategySemantic = "semantic" StrategyHierarchical = "hierarchical" StrategyRAG = "rag_based" // Deterministic strategies (non-LLM) StrategyVotingMajority = "voting_majority" StrategyVotingUnanimous = "voting_unanimous" StrategyVotingWeighted = "voting_weighted" StrategyVotingConfidence = "voting_confidence" )
Aggregation strategies
const ( StrategyChainOfThought = "chain_of_thought" StrategyTreeOfThought = "tree_of_thought" StrategyReActPlanning = "react_planning" StrategyMonteCarlo = "monte_carlo" StrategyBackwardChaining = "backward_chaining" StrategyHierarchicalPlan = "hierarchical_plan" // Renamed to avoid conflict )
Planning strategies
Variables ¶
This section is empty.
Functions ¶
func NewAggregatorAgent ¶
NewAggregatorAgent creates a new AI-powered aggregator agent
func NewClassifierAgent ¶
NewClassifierAgent creates a new AI-powered classifier agent
func NewPlannerAgent ¶
NewPlannerAgent creates a new AI-powered planner agent
func NewReActAgent ¶
NewReActAgent creates a new ReActAgent with provider-based initialization
func NewReActAgentWithClient ¶
func NewReActAgentWithClient(def agent.AgentDef, rt agent.Runtime, client OpenAIClient) (agent.Agent, error)
NewReActAgentWithClient creates a new ReActAgent with a custom client (useful for testing)
Types ¶
type AgentInput ¶
type AgentInput struct {
AgentName string `json:"agent_name"`
Content string `json:"content"`
Timestamp time.Time `json:"timestamp"`
Confidence float64 `json:"confidence,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Embedding []float64 `json:"embedding,omitempty"`
}
AgentInput represents input from a single agent
type AggregationResult ¶
type AggregationResult struct {
AggregatedContent string `json:"aggregated_content"`
Sources []string `json:"sources"`
Strategy string `json:"strategy_used"`
ConflictsSolved []ConflictResolution `json:"conflicts_resolved,omitempty"`
ConsensusLevel float64 `json:"consensus_level"`
SummaryInsights string `json:"summary_insights,omitempty"`
TokensUsed int `json:"tokens_used"`
ProcessingTimeMs int64 `json:"processing_time_ms"`
SemanticClusters []SemanticCluster `json:"semantic_clusters,omitempty"`
}
AggregationResult with AI-enhanced insights
type AggregationStats ¶
type AggregationStats struct {
TotalAggregations int
AvgConsensusLevel float64
ConflictsResolved int
TokensUsed int
ProcessingTimes []time.Duration
}
AggregationStats tracks AI performance metrics
type AggregatorAgent ¶
type AggregatorAgent struct {
*BaseAgent
// contains filtered or unexported fields
}
AggregatorAgent implements AI-powered output aggregation
type AggregatorConfig ¶
type AggregatorConfig struct {
AggregationStrategy string `yaml:"aggregation_strategy"`
ConflictResolution string `yaml:"conflict_resolution"`
DeduplicationMethod string `yaml:"deduplication_method"`
SummarizationEnabled bool `yaml:"summarization_enabled"`
MaxInputSources int `yaml:"max_input_sources"`
TimeoutMs int `yaml:"timeout_ms"`
SemanticSimilarity float64 `yaml:"semantic_similarity_threshold"`
WeightedAggregation map[string]float64 `yaml:"source_weights"`
ConsensusThreshold float64 `yaml:"consensus_threshold"`
Temperature float64 `yaml:"temperature"`
MaxTokens int `yaml:"max_tokens"`
}
AggregatorConfig holds AI-specific configuration for aggregation
type AlternativeClass ¶
type AlternativeStep ¶
type AlternativeStep struct {
Action string `json:"action"`
Reasoning string `json:"reasoning"`
TradeOffs string `json:"trade_offs"`
}
AlternativeStep represents an alternative approach
type BackupPlan ¶
type BackupPlan struct {
TriggerCondition string `json:"trigger_condition"`
AlternativeSteps []PlanStep `json:"alternative_steps"`
Description string `json:"description"`
}
BackupPlan for contingency planning
type BaseAgent ¶
type BaseAgent struct {
// contains filtered or unexported fields
}
BaseAgent provides common functionality for all agents Embed this in your agent structs to automatically implement the Agent interface
func NewBaseAgent ¶
NewBaseAgent creates a new base agent
func (*BaseAgent) DefaultExecute ¶
func (b *BaseAgent) DefaultExecute(ctx context.Context, input *agent.Message) (*agent.Message, error)
DefaultExecute provides a default Execute implementation that returns not implemented Override this in your agent
func (*BaseAgent) DefaultStart ¶
DefaultStart provides a default Start implementation that returns not implemented Override this in your agent
func (*BaseAgent) GetContext ¶
GetContext returns the agent's context If the context is not initialized, returns context.Background()
func (*BaseAgent) InitContext ¶
InitContext initializes the context for async execution
type Category ¶
type Category struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Keywords []string `yaml:"keywords"`
Examples []string `yaml:"examples"`
}
Category represents a classification category with metadata for better LLM understanding
type ClassificationMetrics ¶
type ClassificationMetrics struct {
Timestamp time.Time
InputLength int
ResponseLatency time.Duration
TokensUsed int
Confidence float64
Success bool
}
ClassificationMetrics for AI observability
type ClassificationResult ¶
type ClassificationResult struct {
Category string `json:"category"`
Confidence float64 `json:"confidence"`
Reasoning string `json:"reasoning"`
Alternatives []AlternativeClass `json:"alternatives,omitempty"`
TokensUsed int `json:"tokens_used"`
PromptStrategy string `json:"prompt_strategy"`
}
ClassificationResult with AI-specific metrics
type ClassifierAgent ¶
type ClassifierAgent struct {
// contains filtered or unexported fields
}
ClassifierAgent implements AI-powered content classification
func (*ClassifierAgent) Execute ¶
func (c *ClassifierAgent) Execute(ctx context.Context, input *agent.Message) (*agent.Message, error)
Execute performs synchronous classification
func (*ClassifierAgent) Ready ¶
func (c *ClassifierAgent) Ready() bool
Ready returns whether the agent is ready
type ClassifierConfig ¶
type ClassifierConfig struct {
Categories []Category `yaml:"categories"`
UseEmbeddings bool `yaml:"use_embeddings"`
ConfidenceThreshold float64 `yaml:"confidence_threshold"`
MultiLabel bool `yaml:"multi_label"`
FewShotExamples []Example `yaml:"few_shot_examples"`
Temperature float64 `yaml:"temperature"`
MaxTokens int `yaml:"max_tokens"`
}
ClassifierConfig holds AI-specific configuration for classification
type ConflictResolution ¶
type ConflictResolution struct {
Topic string `json:"topic"`
Sources []string `json:"conflicting_sources"`
Resolution string `json:"resolution"`
Reasoning string `json:"reasoning"`
}
ConflictResolution describes how conflicts were resolved
type Example ¶
type Example struct {
Input string `yaml:"input"`
Category string `yaml:"category"`
Reason string `yaml:"reason"`
}
Example for few-shot learning
type ExamplePlan ¶
type ExamplePlan struct {
Problem string `yaml:"problem"`
Steps []string `yaml:"steps"`
Explanation string `yaml:"explanation"`
}
ExamplePlan for few-shot planning
type GoalNode ¶ added in v0.4.0
type GoalNode struct {
Goal string
Preconditions []string
Subgoals []*GoalNode
Action string
StepNumber int
}
GoalNode represents a goal in backward chaining
type GuidedStepResult ¶ added in v0.5.0
type GuidedStepResult struct {
Iteration int `json:"iteration"`
ToolName string `json:"tool_name"`
Arguments any `json:"arguments,omitempty"`
Result any `json:"result,omitempty"`
Error error `json:"error,omitempty"`
}
GuidedStepResult represents the result of a single tool execution in guided mode
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
type MCTSNode ¶ added in v0.4.0
type MCTSNode struct {
Step *PlanStep
Parent *MCTSNode
Children []*MCTSNode
Visits int
Value float64
IsLeaf bool
}
MCTSNode represents a node in the Monte Carlo Tree Search
type MetacognitionModule ¶
type MetacognitionModule struct {
SuccessPatterns []string
FailurePatterns []string
LearningInsights map[string]float64
}
MetacognitionModule for self-reflection and improvement
type MockOpenAIClient ¶
type MockOpenAIClient struct {
// contains filtered or unexported fields
}
MockOpenAIClient is a mock implementation of OpenAIClient for testing
func NewMockOpenAIClient ¶
func NewMockOpenAIClient() *MockOpenAIClient
NewMockOpenAIClient creates a new mock OpenAI client
func (*MockOpenAIClient) AddResponse ¶
func (m *MockOpenAIClient) AddResponse(resp openai.ChatCompletionResponse, err error)
AddResponse adds a response to return from CreateChatCompletion
func (*MockOpenAIClient) CreateChatCompletion ¶
func (m *MockOpenAIClient) CreateChatCompletion(ctx context.Context, req openai.ChatCompletionRequest) (openai.ChatCompletionResponse, error)
CreateChatCompletion implements OpenAIClient.CreateChatCompletion
func (*MockOpenAIClient) GetCalls ¶
func (m *MockOpenAIClient) GetCalls() []openai.ChatCompletionRequest
GetCalls returns all recorded calls to CreateChatCompletion
type OpenAIClient ¶
type OpenAIClient interface {
CreateChatCompletion(ctx context.Context, req openai.ChatCompletionRequest) (openai.ChatCompletionResponse, error)
}
OpenAIClient interface for testability
type PlanExecutionHistory ¶
type PlanExecutionHistory struct {
PlanID string
Problem string
StepsCompleted int
TotalSteps int
Success bool
ExecutionTime time.Duration
TokensUsed int
}
PlanExecutionHistory tracks plan performance
type PlanStep ¶
type PlanStep struct {
StepNumber int `json:"step_number"`
Action string `json:"action"`
Reasoning string `json:"reasoning"`
Prerequisites []int `json:"prerequisites,omitempty"`
ExpectedOutcome string `json:"expected_outcome"`
Complexity string `json:"complexity"`
CanParallelize bool `json:"can_parallelize"`
Alternatives []AlternativeStep `json:"alternatives,omitempty"`
Confidence float64 `json:"confidence"`
EstimatedTokens int `json:"estimated_tokens,omitempty"`
}
PlanStep represents a single step in the reasoning chain
type PlannerAgent ¶
type PlannerAgent struct {
*BaseAgent
// contains filtered or unexported fields
}
PlannerAgent implements AI-powered Chain-of-Thought planning
type PlannerConfig ¶
type PlannerConfig struct {
PlanningStrategy string `yaml:"planning_strategy"`
MaxSteps int `yaml:"max_steps"`
StepDetailLevel string `yaml:"step_detail_level"`
EnableBacktracking bool `yaml:"enable_backtracking"`
EnableSelfCritique bool `yaml:"enable_self_critique"`
ReasoningDepth int `yaml:"reasoning_depth"`
ParallelizableSteps bool `yaml:"parallelizable_steps"`
IncludeAlternatives bool `yaml:"include_alternatives"`
Temperature float64 `yaml:"temperature"`
MaxTokens int `yaml:"max_tokens"`
ExamplePlans []ExamplePlan `yaml:"example_plans"`
}
PlannerConfig holds AI-specific configuration for planning
type ProblemAnalysis ¶
type ProblemAnalysis struct {
Type string `json:"problem_type"`
Domain string `json:"domain"`
Constraints []string `json:"constraints"`
Resources []string `json:"available_resources"`
KeyChallenges []string `json:"key_challenges"`
Assumptions []string `json:"assumptions"`
}
ProblemAnalysis breaks down the problem
type Producer ¶
type Producer struct {
// contains filtered or unexported fields
}
type ReActAgent ¶
type ReActAgent struct {
*BaseAgent // Provides Name(), Role(), Ready(), Stop()
// contains filtered or unexported fields
}
func (*ReActAgent) ConnectMCPServers ¶
func (r *ReActAgent) ConnectMCPServers(ctx context.Context, serverConfigs []mcp.ServerConfig) error
ConnectMCPServers connects to MCP servers from config
func (*ReActAgent) ExecuteWithSession ¶ added in v0.3.0
func (r *ReActAgent) ExecuteWithSession(ctx context.Context, input *agent.Message, sess SessionProvider) (*agent.Message, error)
ExecuteWithSession performs session-aware execution with conversation history. This implements the session.SessionAwareAgent interface.
func (*ReActAgent) SetProvider ¶
func (r *ReActAgent) SetProvider(prov provider.Provider)
SetProvider sets the LLM provider for this agent
type ReasoningBranch ¶ added in v0.4.0
type ReasoningBranch struct {
Plan *ReasoningPlan
Score float64
}
ReasoningBranch represents a reasoning path in Tree-of-Thought
type ReasoningPlan ¶
type ReasoningPlan struct {
Problem string `json:"problem"`
Analysis ProblemAnalysis `json:"analysis"`
Steps []PlanStep `json:"steps"`
ExecutionStrategy string `json:"execution_strategy"`
CriticalPath []int `json:"critical_path"`
ParallelGroups [][]int `json:"parallel_groups,omitempty"`
BackupPlans []BackupPlan `json:"backup_plans,omitempty"`
SuccessCriteria []string `json:"success_criteria"`
RiskAssessment RiskAssessment `json:"risk_assessment"`
TotalComplexity string `json:"total_complexity"`
EstimatedDuration string `json:"estimated_duration"`
TokensUsed int `json:"tokens_used"`
PlanningStrategy string `json:"planning_strategy"`
SelfCritique string `json:"self_critique,omitempty"`
}
ReasoningPlan with Chain-of-Thought structure
type RiskAssessment ¶
type RiskAssessment struct {
OverallRisk string `json:"overall_risk"`
RiskFactors []RiskFactor `json:"risk_factors"`
MitigationSteps []string `json:"mitigation_steps"`
}
RiskAssessment evaluates plan risks
type RiskFactor ¶
type SemanticCluster ¶
type SemanticCluster struct {
ClusterID string `json:"cluster_id"`
Members []string `json:"member_agents"`
CoreConcept string `json:"core_concept"`
Similarity float64 `json:"avg_similarity"`
}
SemanticCluster groups semantically similar inputs
type SessionProvider ¶ added in v0.3.0
type SessionProvider interface {
GetMessages(ctx context.Context) ([]*publicAgent.Message, error)
}
SessionProvider is a minimal interface for session access during execution. This avoids import cycles with pkg/session.