The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): mirror misplaced-arg recovery on the terminal side
kshitija3bcb2c23265
diff --git a/tests/tools/test_code_execution.py b/tests/tools/test_code_execution.pyindex 10aab8bf0eb..8e60206e38e 100644--- a/tests/tools/test_code_execution.py+++ b/tests/tools/test_code_execution.py@@ -577,6 +577,18 @@ class TestExecuteCodeEdgeCases(unittest.TestCase):self.assertIn("terminal(command=...)", result["error"])self.assertIn("execute_code(code=...)", result["error"])+ def test_terminal_code_argument_points_to_execute_code(self):+ """Mirror recovery: terminal(code=...) names the stray argument and+ redirects to execute_code, instead of the opaque+ 'Invalid command: expected string, got NoneType'."""+ from tools.terminal_tool import _handle_terminal+ result = json.loads(_handle_terminal({"code": "print(1)"}, task_id="test"))+ self.assertIn("error", result)+ self.assertIn("'code' parameter", result["error"])+ self.assertIn("execute_code(code=...)", result["error"])+ self.assertIn("terminal(command=...)", result["error"])+ self.assertNotIn("NoneType", result["error"])+def test_empty_code_explains_required_parameter(self):for code in ("", None):with self.subTest(code=code):diff --git a/tools/terminal_tool.py b/tools/terminal_tool.pyindex 0c1f742f393..16f1a53ecc0 100644--- a/tools/terminal_tool.py+++ b/tools/terminal_tool.py@@ -3786,6 +3786,17 @@ TERMINAL_SCHEMA = {def _handle_terminal(args, **kw):+ # Mirror of execute_code's misplaced-argument recovery: models sometimes+ # send execute_code's ``code`` argument here. Without this, the call+ # falls through to command=None and fails with "Invalid command:+ # expected string, got NoneType" — naming neither the stray argument+ # nor the right tool.+ if "command" not in args and "code" in args:+ return tool_error(+ "terminal received a 'code' parameter, but it requires a shell "+ "command in 'command'. Use execute_code(code=...) for Python; "+ "for shell, retry as terminal(command=...)."+ )return terminal_tool(command=args.get("command"),background=args.get("background", False),