Skip to content

Python Execution

The python tool lets agents execute Python code in their sandboxed workspace. It’s useful for data processing, calculations, file manipulation, and anything that’s easier to express as a script than a shell command.

python(
code: "import json\nwith open('data.json') as f:\n data = json.load(f)\nprint(len(data['items']))"
)
ParameterTypeRequiredDescription
codestringyesPython code to execute

The code runs with python3 in the agent’s workspace directory. Standard output and errors are captured and returned to the agent as a tool result.

Execution has a 30-second timeout. If the script exceeds this, it’s killed and the agent gets a timeout error.

ScenarioTool
Data processing and analysispython
File parsing (CSV, JSON, XML)python
Math and calculationspython
Installing packages, running buildsshell
System commands (ls, curl, git)shell
Quick file operationsshell

Python execution runs inside the same sandbox as the shell tool. Filesystem access is restricted to the agent’s workspace, and network access is controlled by the agent’s sandbox settings.

See CLI Execution for sandbox configuration details.