File size: 925 Bytes
1499363
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""TaskStop tool — stop a running background task.

Modeled after Claude Code's TaskStopTool.
"""

from __future__ import annotations

from pydantic import BaseModel, Field

from ..base import BaseTool, ToolContext


class TaskStopInput(BaseModel):
    task_id: str = Field(description="The task ID to stop")


class TaskStopTool(BaseTool):
    name = "TaskStop"
    description = (
        "Stop a running background task. "
        "Use when a background command is taking too long or is no longer needed."
    )
    input_schema = TaskStopInput
    prompt = (
        "# TaskStop tool usage\n"
        "- Stop a running background task by its task ID.\n"
        "- Use when a command is taking too long, producing wrong output, or is no longer needed.\n"
    )

    def call(self, context: ToolContext, *, task_id: str) -> str:
        from scider.core.task import TaskManager

        return TaskManager.stop(task_id)