|
20 | 20 | from pydantic import BaseModel, ConfigDict, Field, PrivateAttr |
21 | 21 | from typing_extensions import Self |
22 | 22 |
|
| 23 | +from askui.models.exceptions import AutomationError |
23 | 24 | from askui.models.shared.agent_message_param import ( |
24 | 25 | Base64ImageSourceParam, |
25 | 26 | CacheControlEphemeralParam, |
@@ -384,10 +385,8 @@ def is_agent_os_initialized(self) -> bool: |
384 | 385 | return self._agent_os is not None |
385 | 386 |
|
386 | 387 |
|
387 | | -class AgentException(Exception): |
388 | | - """ |
389 | | - Exception raised by the agent. |
390 | | - """ |
| 388 | +class AgentError(Exception): |
| 389 | + """Unfixable error raised by the agent that terminates execution immediately.""" |
391 | 390 |
|
392 | 391 | def __init__(self, message: str): |
393 | 392 | self.message = message |
@@ -647,7 +646,7 @@ def _run_regular_tool( |
647 | 646 | content=_convert_to_content(tool_result), |
648 | 647 | tool_use_id=tool_use_block_param.id, |
649 | 648 | ) |
650 | | - except AgentException: |
| 649 | + except (AgentError, AutomationError): |
651 | 650 | raise |
652 | 651 | except Exception as e: # noqa: BLE001 |
653 | 652 | error_message = getattr(e, "message", str(e)) |
@@ -691,6 +690,8 @@ def _run_mcp_tool( |
691 | 690 | content=_convert_to_content(result), |
692 | 691 | tool_use_id=tool_use_block_param.id, |
693 | 692 | ) |
| 693 | + except AutomationError: |
| 694 | + raise |
694 | 695 | except Exception as e: # noqa: BLE001 |
695 | 696 | logger.warning( |
696 | 697 | "MCP tool failed", |
|
0 commit comments