MCPcopy Create free account
hub / github.com/HKUDS/AutoAgent / execute_command

Function execute_command

autoagent/tools/terminal_tools.py:314–327  ·  view source on GitHub ↗

Execute a command in the system shell. Use this function when there is a need to run a system command, and execute programs. Args: command: The command to execute in the system shell. Returns: A string representation of the exit code and output of the command.

(command: str, context_variables)

Source from the content-addressed store, hash-verified

312@register_tool("execute_command")
313@process_terminal_response
314def execute_command(command: str, context_variables) -> str:
315 """
316 Execute a command in the system shell. Use this function when there is a need to run a system command, and execute programs.
317 Args:
318 command: The command to execute in the system shell.
319 Returns:
320 A string representation of the exit code and output of the command.
321 """
322 env: Union[DockerEnv, LocalEnv] = context_variables.get("code_env", LocalEnv())
323 try:
324 response = env.run_command(command, print_stream)
325 return response
326 except Exception as e:
327 return f"[ERROR] Error running command: {str(e)}"
328
329def print_stream(text):
330 console = Console()

Callers

nothing calls this directly

Calls 3

LocalEnvClass · 0.90
getMethod · 0.80
run_commandMethod · 0.45

Tested by

no test coverage detected