Skip to content

The agent that grows with you

feat(tests): add tests for execute_code error mesages

Elisa Martinez Abade8607417d7ca
diff --git a/tests/tools/test_code_execution.py b/tests/tools/test_code_execution.py
index e6369b80039..15bf58a97e9 100644
--- a/tests/tools/test_code_execution.py
+++ b/tests/tools/test_code_execution.py
@@ -47,6 +47,7 @@ from tools.code_execution_tool import (
_TOOL_DOC_LINES,
_execute_remote,
)
+from tools.registry import registry
def _mock_handle_function_call(function_name, function_args, task_id=None, user_task=None):
@@ -564,6 +565,31 @@ class TestEnvVarFiltering(unittest.TestCase):
class TestExecuteCodeEdgeCases(unittest.TestCase):
+ def test_command_argument_points_to_terminal(self):
+ result = json.loads(registry.dispatch(
+ "execute_code",
+ {"command": "git status"},
+ task_id="test",
+ enabled_tools=list(SANDBOX_ALLOWED_TOOLS),
+ ))
+ self.assertIn("error", result)
+ self.assertIn("'command' parameter", result["error"])
+ self.assertIn("terminal(command=...)", result["error"])
+ self.assertIn("execute_code(code=...)", result["error"])
+
+ def test_empty_code_explains_required_parameter(self):
+ for code in ("", None):
+ with self.subTest(code=code):
+ result = json.loads(registry.dispatch(
+ "execute_code",
+ {"code": code},
+ task_id="test",
+ ))
+ self.assertIn("error", result)
+ self.assertIn("non-empty 'code' parameter", result["error"])
+ self.assertIn("Python source", result["error"])
+ self.assertIn("terminal(command=...)", result["error"])
+
def test_windows_returns_error(self):
"""When SANDBOX_AVAILABLE is False (e.g. when the backend deems
the sandbox unusable for this environment), execute_code returns