@@ -612,3 +612,34 @@ def test_edit_file_fuzzy_tolerates_indentation_differences(project_dir):
612612
613613 assert "Successfully edited" in result
614614 assert "return 2" in Path (file_path ).read_text (encoding = "utf-8" )
615+
616+
617+ def test_tool_executor_refuses_temporarily_disabled_tool (monkeypatch ):
618+ """A call to a disabled tool must be refused without executing it, even though the
619+ tool is present in DEFAULT_TOOLS (the model can emit calls the server never
620+ declared to it, and unpatched servers forward them verbatim)."""
621+ import render_machine .agent .tool_executor as tool_executor_module
622+ from render_machine .agent .tool_executor import ToolExecutor
623+
624+ monkeypatch .setattr (tool_executor_module , "TEMPORARILY_DISABLED_TOOLS" , {"run_command" })
625+
626+ executed = []
627+ executor = ToolExecutor ({"run_command" : lambda args , ctx : executed .append (args ) or "ran" })
628+ results = executor .execute_calls ([{"id" : "c1" , "name" : "run_command" , "args" : {"command" : "ls" }}], None )
629+
630+ assert executed == []
631+ assert results [0 ]["call_id" ] == "c1"
632+ assert "temporarily disabled" in results [0 ]["output" ]
633+ assert "run_command" in results [0 ]["output" ]
634+
635+
636+ def test_tool_executor_runs_tools_not_in_disabled_set (monkeypatch ):
637+ import render_machine .agent .tool_executor as tool_executor_module
638+ from render_machine .agent .tool_executor import ToolExecutor
639+
640+ monkeypatch .setattr (tool_executor_module , "TEMPORARILY_DISABLED_TOOLS" , set ())
641+
642+ executor = ToolExecutor ({"run_command" : lambda args , ctx : "ran: " + args ["command" ]})
643+ results = executor .execute_calls ([{"id" : "c1" , "name" : "run_command" , "args" : {"command" : "ls" }}], None )
644+
645+ assert results [0 ]["output" ] == "ran: ls"
0 commit comments