MCPcopy Create free account
hub / github.com/astercloud/aster / NewExecutionPlanManager

Function NewExecutionPlanManager

pkg/agent/execution_plan.go:51–88  ·  view source on GitHub ↗

NewExecutionPlanManager 创建执行计划管理器

(agent *Agent)

Source from the content-addressed store, hash-verified

49
50// NewExecutionPlanManager 创建执行计划管理器
51func NewExecutionPlanManager(agent *Agent) *ExecutionPlanManager {
52 // 创建生成器和执行器
53 generator := executionplan.NewGenerator(agent.provider, agent.toolMap)
54 executor := executionplan.NewExecutor(
55 agent.toolMap,
56 executionplan.WithOnStepStart(func(plan *executionplan.ExecutionPlan, step *executionplan.Step) {
57 agentLog.Debug(context.Background(), "execution plan step started", map[string]any{
58 "plan_id": plan.ID,
59 "step_index": step.Index,
60 "step_id": step.ID,
61 "tool_name": step.ToolName,
62 "description": step.Description,
63 })
64 }),
65 executionplan.WithOnStepComplete(func(plan *executionplan.ExecutionPlan, step *executionplan.Step) {
66 agentLog.Debug(context.Background(), "execution plan step completed", map[string]any{
67 "plan_id": plan.ID,
68 "step_index": step.Index,
69 "step_id": step.ID,
70 "duration_ms": step.DurationMs,
71 })
72 }),
73 executionplan.WithOnStepFailed(func(plan *executionplan.ExecutionPlan, step *executionplan.Step, err error) {
74 agentLog.Warn(context.Background(), "execution plan step failed", map[string]any{
75 "plan_id": plan.ID,
76 "step_index": step.Index,
77 "step_id": step.ID,
78 "error": err.Error(),
79 })
80 }),
81 )
82
83 return &ExecutionPlanManager{
84 agent: agent,
85 generator: generator,
86 executor: executor,
87 }
88}
89
90// SetCallbacks 设置回调函数
91func (m *ExecutionPlanManager) SetCallbacks(

Callers 1

ExecutionPlanMethod · 0.85

Calls 8

NewGeneratorFunction · 0.92
NewExecutorFunction · 0.92
WithOnStepStartFunction · 0.92
WithOnStepCompleteFunction · 0.92
WithOnStepFailedFunction · 0.92
DebugMethod · 0.65
WarnMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected