| 348 | } |
| 349 | |
| 350 | func NewTaskStopTool() coretools.Tool { |
| 351 | return newTaskTool("TaskStop", "Stop one direct child task. Queued workers are killed immediately; running workers are cancelled and converge to killed.", TaskStopInput{}, func(_ context.Context, execCtx coretools.ExecutionContext, input any) (string, error) { |
| 352 | rt, scope, err := runtimeAndScope(execCtx) |
| 353 | if err != "" { |
| 354 | return err, nil |
| 355 | } |
| 356 | in := derefTaskStop(input) |
| 357 | result := rt.StopTask(in.TaskID, scope) |
| 358 | if text, ok := result.(string); ok { |
| 359 | return text, nil |
| 360 | } |
| 361 | return jsonString(serializeTaskResult(result)), nil |
| 362 | }) |
| 363 | } |
| 364 | |
| 365 | func NewSendMessageTool() coretools.Tool { |
| 366 | return newTaskTool("SendMessage", "Send a new prompt to an existing reusable worker. This only succeeds when the target worker is idle and ready for more work.", SendMessageInput{}, func(_ context.Context, execCtx coretools.ExecutionContext, input any) (string, error) { |