Documentation
¶
Index ¶
Constants ¶
const ( // DefaultMaxSteps is the default maximum number of steps allowed per request. DefaultMaxSteps = 10 // DefaultMaxParallelTasks is the default maximum number of tasks that can run in parallel. DefaultMaxParallelTasks = 10 // DefaultRetryAttempts is the default number of retry attempts for failed operations. DefaultRetryAttempts = 3 // DefaultSimilarTasksLimit is the default limit for similar task search results. DefaultSimilarTasksLimit = 3 // DefaultSimilarityThreshold is the default similarity threshold for task matching. // Tasks with similarity below this value will be filtered out. DefaultSimilarityThreshold = 0.5 // DefaultContextHistoryLength is the default maximum number of messages to keep in context. DefaultContextHistoryLength = 10 // DefaultSummaryLength is the default maximum length for result summaries in characters. DefaultSummaryLength = 200 )
Default configuration constants for LeaderAgent.
const ( // DefaultTaskTimeout is the default timeout for task execution. DefaultTaskTimeout = 5 * time.Minute // DefaultDispatchTimeout is the default timeout for task dispatch operations. DefaultDispatchTimeout = 2 * time.Minute // DefaultAggregationTimeout is the default timeout for result aggregation. DefaultAggregationTimeout = 1 * time.Minute )
Timeout constants for LeaderAgent operations.
const SortByCreatedAt = "created_at"
SortByCreatedAt sorts items by TaskResult.CreatedAt (newest first).
const SortByNone = "none"
SortByNone disables sorting; items remain in their original order.
const SortByPriority = "priority"
SortByPriority sorts items by the associated Task.Priority (descending).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
Agent represents the Leader Agent interface.
func New ¶
func New( id string, parser ProfileParser, planner TaskPlanner, dispatcher TaskDispatcher, aggregator ResultAggregator, msgQueue *ahp.MessageQueue, hbMon *ahp.HeartbeatMonitor, memMgr memory.MemoryManager, cfg *LeaderAgentConfig, ) Agent
New creates a new LeaderAgent instance.
type LeaderAgentConfig ¶
LeaderAgentConfig holds configuration for LeaderAgent.
func DefaultLeaderAgentConfig ¶
func DefaultLeaderAgentConfig() *LeaderAgentConfig
DefaultLeaderAgentConfig returns default configuration.
type LocalMessageSender ¶
type LocalMessageSender struct {
// contains filtered or unexported fields
}
LocalMessageSender sends messages to local agent queues.
func NewLocalMessageSender ¶
func NewLocalMessageSender() *LocalMessageSender
NewLocalMessageSender creates a new LocalMessageSender.
func (*LocalMessageSender) RegisterQueue ¶
func (s *LocalMessageSender) RegisterQueue(agentAddr string, queue *ahp.MessageQueue)
RegisterQueue registers a message queue for an agent address.
func (*LocalMessageSender) Send ¶
func (s *LocalMessageSender) Send(ctx context.Context, agentAddr string, msg *ahp.AHPMessage) error
Send sends a message to the specified agent address.
type MessageSender ¶
type MessageSender interface {
Send(ctx context.Context, agentAddr string, msg *ahp.AHPMessage) error
}
MessageSender sends messages to sub-agents (for distributed deployment).
type ProfileParser ¶
type ProfileParser interface {
Parse(ctx context.Context, input string) (*models.UserProfile, error)
}
ProfileParser parses user profile from input.
func NewProfileParser ¶
func NewProfileParser( llmAdapter output.LLMAdapter, template *output.TemplateEngine, promptTpl string, validator *output.Validator, maxRetries int, ) ProfileParser
NewProfileParser creates a new ProfileParser with LLM support.
type ResultAggregator ¶
type ResultAggregator interface {
Aggregate(ctx context.Context, results []*models.TaskResult, tasks []*models.Task) (*models.RecommendResult, error)
}
ResultAggregator aggregates results from sub-agents.
func NewResultAggregator ¶
func NewResultAggregator(enableDedupe bool, maxItems int, sortBy string) ResultAggregator
NewResultAggregator creates a new ResultAggregator. sortBy controls the ordering of aggregated items and must be one of: SortByNone ("none"), SortByPriority ("priority"), or SortByCreatedAt ("created_at"). An unrecognised value is treated as SortByNone.
type SubAgentConfig ¶
type SubAgentConfig struct {
ID string
Type string
Triggers []string
Priority int // Optional. Defaults to 1 if unset or <= 0.
}
SubAgentConfig represents sub agent configuration (mirrors config.SubAgentConfig). SubAgentConfig defines a sub-agent that can be dispatched by the planner.
type TaskDispatcher ¶
type TaskDispatcher interface {
Dispatch(ctx context.Context, tasks []*models.Task) ([]*models.TaskResult, error)
RegisterExecutor(agentType models.AgentType, fn func(ctx context.Context, task *models.Task) (*models.TaskResult, error))
}
TaskDispatcher dispatches tasks to sub-agents.
func NewTaskDispatcher ¶
func NewTaskDispatcher(agentRegistry map[models.AgentType]string, maxParallel int, timeout int, sender MessageSender) TaskDispatcher
NewTaskDispatcher creates a new TaskDispatcher.
type TaskExecutorFunc ¶
TaskExecutorFunc is a function type for executing tasks directly.
type TaskPlanner ¶
type TaskPlanner interface {
Plan(ctx context.Context, profile *models.UserProfile, inputText string) ([]*models.Task, error)
}
TaskPlanner plans tasks based on user profile and input text.
func NewTaskPlanner ¶
func NewTaskPlanner(maxTasks int) TaskPlanner
NewTaskPlanner creates a new TaskPlanner.
func NewTaskPlannerWithConfig ¶
func NewTaskPlannerWithConfig(maxTasks int, subAgents []SubAgentConfig) TaskPlanner
NewTaskPlannerWithConfig creates a TaskPlanner with sub-agent configuration.