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

Method executeAsync

pkg/middleware/subagent.go:330–361  ·  view source on GitHub ↗

executeAsync 异步执行子代理

(ctx context.Context, subagentType, description string, parentContext map[string]any, timeout time.Duration)

Source from the content-addressed store, hash-verified

328
329// executeAsync 异步执行子代理
330func (t *TaskTool) executeAsync(ctx context.Context, subagentType, description string, parentContext map[string]any, timeout time.Duration) (any, error) {
331 // 构建子代理配置
332 config := &builtin.SubagentConfig{
333 Type: subagentType,
334 Prompt: description,
335 Timeout: timeout,
336 ParentContext: parentContext,
337 Metadata: map[string]string{
338 "subagent_type": subagentType,
339 "description": description,
340 },
341 }
342
343 // 启动子代理
344 instance, err := t.middleware.manager.StartSubagent(ctx, config)
345 if err != nil {
346 return map[string]any{
347 "ok": false,
348 "error": fmt.Sprintf("failed to start subagent: %v", err),
349 }, nil
350 }
351
352 saLog.Info(ctx, "started async subagent", map[string]any{"subagent": subagentType, "task_id": instance.ID})
353
354 return map[string]any{
355 "ok": true,
356 "task_id": instance.ID,
357 "subagent_type": subagentType,
358 "status": instance.Status,
359 "message": "SubAgent started in background. Use query_subagent to check status and get results.",
360 }, nil
361}
362
363func (t *TaskTool) Prompt() string {
364 // 获取可用的子代理列表

Callers 1

ExecuteMethod · 0.95

Calls 2

StartSubagentMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected