| 306 | } |
| 307 | |
| 308 | func NewTaskListTool() coretools.Tool { |
| 309 | return newTaskTool("TaskList", "List all direct child tasks spawned by the current agent scope, including their status, usage, and result metadata.", TaskListInput{}, func(_ context.Context, execCtx coretools.ExecutionContext, _ any) (string, error) { |
| 310 | rt, scope, err := runtimeAndScope(execCtx) |
| 311 | if err != "" { |
| 312 | return err, nil |
| 313 | } |
| 314 | records := rt.ListTasks(scope) |
| 315 | tasks := make([]map[string]any, 0, len(records)) |
| 316 | for _, record := range records { |
| 317 | tasks = append(tasks, serializeTaskPayload(record.ToMap())) |
| 318 | } |
| 319 | payload := map[string]any{"tasks": tasks} |
| 320 | return jsonString(payload), nil |
| 321 | }) |
| 322 | } |
| 323 | |
| 324 | func NewTaskGetTool() coretools.Tool { |
| 325 | return newTaskTool("TaskGet", "Get the latest details for one direct child task by task_id, including status, result text, error text, usage, and lifecycle metadata.", TaskGetInput{}, func(_ context.Context, execCtx coretools.ExecutionContext, input any) (string, error) { |