mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
Make tool call json decode error recoverable (#8233)
This commit is contained in:
@@ -76,7 +76,7 @@ def response_to_actions(
|
||||
try:
|
||||
arguments = json.loads(tool_call.function.arguments)
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
raise RuntimeError(
|
||||
raise FunctionCallValidationError(
|
||||
f'Failed to parse tool call arguments: {tool_call.function.arguments}'
|
||||
) from e
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ def response_to_actions(
|
||||
try:
|
||||
arguments = json.loads(tool_call.function.arguments)
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
raise RuntimeError(
|
||||
raise FunctionCallValidationError(
|
||||
f'Failed to parse tool call arguments: {tool_call.function.arguments}'
|
||||
) from e
|
||||
|
||||
|
||||
@@ -215,6 +215,6 @@ def test_invalid_json_arguments():
|
||||
}
|
||||
],
|
||||
)
|
||||
with pytest.raises(RuntimeError) as exc_info:
|
||||
with pytest.raises(FunctionCallValidationError) as exc_info:
|
||||
response_to_actions(response)
|
||||
assert 'Failed to parse tool call arguments' in str(exc_info.value)
|
||||
|
||||
Reference in New Issue
Block a user