fix(tools): mirror misplaced-arg recovery on the terminal side
Whole-bug-class sibling of the execute_code fix: terminal(code=...) — the reverse confusion — fell through to command=None and failed with 'Invalid command: expected string, got NoneType', naming neither the stray 'code' argument nor execute_code as the right tool. Mirror the guard in _handle_terminal (verified live: the opaque NoneType error reproduces on main). Mutation-checked: removing the guard fails the new regression test.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user