|
6 | 6 | """ |
7 | 7 |
|
8 | 8 | from abc import ABC, abstractmethod |
9 | | -from typing import Any, Callable, Generator, Literal, Protocol, Union, cast |
| 9 | +from typing import Any, Callable, Generator, Literal, Protocol, Union |
10 | 10 |
|
11 | 11 | from typing_extensions import TypedDict |
12 | 12 |
|
@@ -172,7 +172,7 @@ class AgentTool(ABC): |
172 | 172 | """Abstract base class for all SDK tools. |
173 | 173 |
|
174 | 174 | This class defines the interface that all tool implementations must follow. Each tool must provide its name, |
175 | | - specification, and implement an invoke method that executes the tool's functionality. |
| 175 | + specification, and implement a stream method that executes the tool's functionality. |
176 | 176 | """ |
177 | 177 |
|
178 | 178 | _is_dynamic: bool |
@@ -214,25 +214,6 @@ def supports_hot_reload(self) -> bool: |
214 | 214 | """ |
215 | 215 | return False |
216 | 216 |
|
217 | | - def invoke(self, tool_use: ToolUse, *args: Any, **kwargs: dict[str, Any]) -> ToolResult: |
218 | | - """Execute the tool's functionality with the given tool use request. |
219 | | -
|
220 | | - Args: |
221 | | - tool_use: The tool use request containing tool ID and parameters. |
222 | | - *args: Positional arguments to pass to the tool. |
223 | | - **kwargs: Keyword arguments to pass to the tool. |
224 | | -
|
225 | | - Returns: |
226 | | - The result of the tool execution. |
227 | | - """ |
228 | | - events = self.stream(tool_use, *args, **kwargs) |
229 | | - |
230 | | - try: |
231 | | - while True: |
232 | | - next(events) |
233 | | - except StopIteration as stop: |
234 | | - return cast(ToolResult, stop.value) |
235 | | - |
236 | 217 | @abstractmethod |
237 | 218 | # pragma: no cover |
238 | 219 | def stream(self, tool_use: ToolUse, *args: Any, **kwargs: dict[str, Any]) -> ToolGenerator: |
|
0 commit comments