MCPcopy Create free account
hub / github.com/SamuelSchmidgall/AgentLaboratory / execute_command

Method execute_command

mlesolver.py:99–120  ·  view source on GitHub ↗
(self, *args)

Source from the content-addressed store, hash-verified

97 )
98
99 def execute_command(self, *args) -> str:
100 # args[0] -> N (int)
101 # args[1] -> M (int)
102 # args[2] -> old code
103 # args[3] -> new lines to replace
104 # args[4] -> new lines to replace
105 try:
106 args = args[0]
107 current_code = args[2]
108 lines_to_add = list(reversed(args[3]))
109 lines_to_replace = list(reversed(range(args[0], args[1]+1)))
110 for _ln in lines_to_replace:
111 current_code.pop(_ln)
112 for _line in lines_to_add:
113 current_code.insert(args[0], _line)
114 new_code = "\n".join(current_code)
115 code_exec = f"{args[4]}\n{new_code}"
116 code_ret = execute_code(code_exec)
117 if "CODE EXECUTION ERROR" in code_ret: return (False, None, code_ret)
118 return (True, current_code, code_ret)
119 except Exception as e:
120 return (False, None, str(e))
121
122 def matches_command(self, cmd_str) -> bool:
123 if "```EDIT" in cmd_str: return True

Callers 1

process_commandMethod · 0.45

Calls 1

execute_codeFunction · 0.85

Tested by

no test coverage detected