Skip to content

Commit

Permalink
handle function call validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyaoww committed Nov 8, 2024
1 parent 4fb2f07 commit 5533028
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion openhands/controller/agent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 4 additions & 2 deletions openhands/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class FunctionCallConversionError(Exception):
This typically happens when there's a malformed message (e.g., missing <function=...> tags). But not due to LLM output.
"""

pass
def __init__(self, message):
super().__init__(message)


class FunctionCallValidationError(Exception):
Expand All @@ -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)

0 comments on commit 5533028

Please sign in to comment.