Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
Name() string
Execute(ctx context.Context, message string) iter.Seq2[*session.Event, error]
}
Agent 接口定义 简化版本,实际应该从主 Agent 包导入
type LoopAgent ¶
type LoopAgent struct {
// contains filtered or unexported fields
}
LoopAgent 循环执行子 Agent 直到满足终止条件 参考 Google ADK-Go 的 LoopAgent 设计
使用场景: - 代码迭代优化直到满足质量要求 - 多轮对话直到用户满意 - 任务重试直到成功或达到最大次数
func (*LoopAgent) MaxIterations ¶
CurrentIteration 返回当前迭代次数(仅用于监控)
type LoopConfig ¶
type LoopConfig struct {
// Name Agent 名称
Name string
// SubAgents 子 Agent 列表(按顺序执行)
SubAgents []Agent
// MaxIterations 最大迭代次数(0 表示无限制,需要依赖 StopCondition)
MaxIterations uint
// StopCondition 自定义停止条件(可选)
// 如果未提供,默认检查 event.Actions.Escalate
StopCondition StopCondition
}
LoopConfig LoopAgent 配置
type ParallelAgent ¶
type ParallelAgent struct {
// contains filtered or unexported fields
}
ParallelAgent 并行执行多个子 Agent 参考 Google ADK-Go 的 ParallelAgent 设计
使用场景: - 同时运行不同算法进行比较 - 生成多个候选响应供后续评估 - 并行处理独立的任务
func NewParallelAgent ¶
func NewParallelAgent(cfg ParallelConfig) (*ParallelAgent, error)
NewParallelAgent 创建并行 Agent
func (*ParallelAgent) AddSubAgent ¶
func (a *ParallelAgent) AddSubAgent(agent Agent)
AddSubAgent 动态添加子 Agent
type ParallelConfig ¶
type ParallelConfig struct {
// Name Agent 名称
Name string
// SubAgents 子 Agent 列表
SubAgents []Agent
// MaxConcurrent 最大并发数(0 表示无限制)
MaxConcurrent int
}
ParallelConfig ParallelAgent 配置
type SequentialAgent ¶
type SequentialAgent struct {
*LoopAgent
}
SequentialAgent 顺序执行子 Agent 参考 Google ADK-Go 的 SequentialAgent 设计
实际上是 LoopAgent 的特例(MaxIterations=1)
使用场景: - 多步骤工作流(分析 -> 规划 -> 执行) - 流水线处理(预处理 -> 处理 -> 后处理) - 阶段性任务(收集信息 -> 分析 -> 决策)
func NewSequentialAgent ¶
func NewSequentialAgent(cfg SequentialConfig) (*SequentialAgent, error)
NewSequentialAgent 创建顺序 Agent
type SequentialConfig ¶
type SequentialConfig struct {
// Name Agent 名称
Name string
// SubAgents 子 Agent 列表(严格按顺序执行一次)
SubAgents []Agent
// StopOnError 遇到错误时是否停止(默认 true)
StopOnError bool
}
SequentialConfig SequentialAgent 配置
type StopCondition ¶
StopCondition 停止条件函数 返回 true 表示应该停止循环