Skip to content

Commit 4abda02

Browse files
Fix ToolError
1 parent 7195d24 commit 4abda02

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/askui/tools/anthropic/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from abc import ABCMeta, abstractmethod
22
from dataclasses import dataclass, fields, replace
3-
from typing import Any
3+
from typing import Any, Optional
44

55
from anthropic.types.beta import BetaToolUnionParam
66

@@ -74,9 +74,10 @@ class ToolError(Exception):
7474
7575
Args:
7676
message (str): The error message.
77-
result (ToolResult): The ToolResult that caused the error.
77+
result (ToolResult, optional): The ToolResult that caused the error.
7878
"""
7979

80-
def __init__(self, message: str, result: ToolResult):
80+
def __init__(self, message: str, result: Optional[ToolResult] = None):
8181
self.message = message
8282
self.result = result
83+
super().__init__(self.message)

src/askui/tools/anthropic/computer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def __call__(
278278
if coordinate is not None:
279279
raise ToolError(f"coordinate is not accepted for {action}")
280280
if not isinstance(text, str):
281-
raise ToolError(output=f"{text} must be a string")
281+
raise ToolError(f"{text} must be a string")
282282

283283
if action == "key":
284284
if text in KEYSYM_MAP.keys():
@@ -312,7 +312,7 @@ def __call__(
312312
return self.screenshot()
313313
if action == "cursor_position":
314314
# TODO: Implement in the future
315-
return ToolError("cursor_position is not implemented by this agent")
315+
raise ToolError("cursor_position is not implemented by this agent")
316316
if action == "left_click":
317317
self.controller_client.click("left")
318318
return ToolResult()

0 commit comments

Comments
 (0)