Add both for the best behaviour: the tool gives the capability, the skill gives the judgement. The tool works on its own, but the skill makes the agent use it reliably (and recover from errors).
Add it to an agent
- Open your agent → Capabilities → Add capability.
- Pick Code Interpreter (category Data). The server URL is pre-filled — nothing to type.
- (Recommended) Add Code Interpreter (skill) as well.
- (Recommended) Set the tool’s permission to Ask first so the user approves each run — see Tool permissions.
The execute_python tool
The tool returns a compact result: the script’s
result (stdout / return value), any logs, and on failure an error object (code, message, stack). It does not render anything in the chat by itself — to visualize the numbers, pair it with the Dataviz skill.
Reading an attached file (CSV / Excel)
To analyse a file the user attached, pass its URL infiles, then read it in code — never paste the file’s contents into the prompt:
Sandbox & limits
- Prefer the standard library (
csv,json,statistics,math,datetime) — always available. - Heavier libraries (
pandas,openpyxl, …) only work if your operator added them to the allow-list. If an import is rejected, fall back to a standard-library approach. - Supported files: CSV and Excel (PDF is not supported).
- No internet: the code cannot fetch URLs or call APIs. Pass data in via
filesor the prompt.
Errors & retry
The tool always returns a result. On failureisError is true and the payload carries the traceback. The Code Interpreter skill instructs the agent to:
- read the traceback, fix the code, and run again (up to two retries);
- on an
ImportErrorfrom the allow-list, switch to a standard-library approach (or tell the user the library is unavailable); - on
CodeSandboxUnreachable(infra), not retry immediately and tell the user it is temporarily unavailable; - never fabricate a result when the code failed.
Pairing with Dataviz
The Code Interpreter is the compute layer; it returns data, not visuals. To turn results into a chart or dashboard, combine it with the Dataviz skill, which renders interactive charts in the canvas (HTML + JS / Chart.js). A typical flow:- Code Interpreter — read the CSV, compute the monthly totals.
- Dataviz — render those totals as a bar chart in the canvas.