-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool_runtime.py
More file actions
32 lines (28 loc) · 1.11 KB
/
tool_runtime.py
File metadata and controls
32 lines (28 loc) · 1.11 KB
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
from models import AuthorizeRequest, ToolExecutionResult, StructuredError
def execute(request: AuthorizeRequest) -> ToolExecutionResult:
if request.tool_name == "read_file":
path = request.normalized_args["path"]
#阶段8专门留一个可控失败点,用于打通 execution failed 的流程
if path == "/safe/raise.txt":
return ToolExecutionResult(
request_id=request.request_id,
success=False,
error=StructuredError(
code="READ_FILE_EXEC_ERROR",
message="mock read_file execution failure",
),
)
#阶段7只做 mock 执行成功,不做真实文件读取
return ToolExecutionResult(
request_id=request.request_id,
success=True,
output=f"mock-read:{path}",
)
return ToolExecutionResult(
request_id=request.request_id,
success=False,
error=StructuredError(
code="UNSUPPORTED_TOOL",
message=f"unsupported tool: {request.tool_name}",
),
)