From 55330289a8fa5a2d9be1a188689590363b186886 Mon Sep 17 00:00:00 2001 From: Xingyao Wang Date: Fri, 8 Nov 2024 15:50:50 +0000 Subject: [PATCH] handle function call validation error --- openhands/controller/agent_controller.py | 8 +++++++- openhands/core/exceptions.py | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/openhands/controller/agent_controller.py b/openhands/controller/agent_controller.py index 2ee30e130ca3..f2b4b0dc9b77 100644 --- a/openhands/controller/agent_controller.py +++ b/openhands/controller/agent_controller.py @@ -10,6 +10,7 @@ from openhands.controller.stuck import StuckDetector from openhands.core.config import AgentConfig, LLMConfig from openhands.core.exceptions import ( + FunctionCallValidationError, LLMMalformedActionError, LLMNoActionError, LLMResponseError, @@ -468,7 +469,12 @@ async def _step(self) -> None: action = self.agent.step(self.state) if action is None: raise LLMNoActionError('No action was returned') - except (LLMMalformedActionError, LLMNoActionError, LLMResponseError) as e: + except ( + LLMMalformedActionError, + LLMNoActionError, + LLMResponseError, + FunctionCallValidationError, + ) as e: self.event_stream.add_event( ErrorObservation( content=str(e), diff --git a/openhands/core/exceptions.py b/openhands/core/exceptions.py index 1a95dc2c44b5..0c0a771191b4 100644 --- a/openhands/core/exceptions.py +++ b/openhands/core/exceptions.py @@ -102,7 +102,8 @@ class FunctionCallConversionError(Exception): This typically happens when there's a malformed message (e.g., missing tags). But not due to LLM output. """ - pass + def __init__(self, message): + super().__init__(message) class FunctionCallValidationError(Exception): @@ -111,4 +112,5 @@ class FunctionCallValidationError(Exception): This typically happens when the LLM outputs unrecognized function call / parameter names / values. """ - pass + def __init__(self, message): + super().__init__(message)