User GuidesDeliver
Code Execution (Sandbox Python)
Run Python in an isolated sandbox to compute results, transform data and create files from your documents
Code Execution (Sandbox Python)
Overview
Code execution lets the assistant write and run Python in an isolated sandbox during a turn. Use it for calculations, data cleaning, parsing uploaded files and producing artifacts such as charts or spreadsheets that require deterministic processing rather than language-model reasoning.
Prerequisites
- The sandbox is enabled by a platform administrator (
SANDBOX_ENABLED). When it is off, code execution tools are unavailable and the assistant works without them. - Files you want to process are in the workspace knowledge base or attached to the chat.
- Enough credits and a reasonable timeout for the workload.
Step-by-step
- Ask for the computation or transformation, naming the file and the expected output.
- The assistant writes Python, runs it in the sandbox and shows the result or the generated artifact.
- Review the code and output. Ask for changes; the assistant re-runs in a fresh sandbox.
- Download any generated file from the chat or Artifacts.
- If the task is long-running, split it into smaller steps so each turn stays within the execution timeout.
Example
Read the reimbursements spreadsheet from the knowledge base, calculate total spend per cost centre, flag rows above the policy cap, and produce a bar chart plus a summary CSV.
Expected result
- Code and output visible in the turn, with errors shown if the run fails.
- Generated files saved as artifacts you can download.
- Numbers reproducible from the shown code and the stated input file.
Limits and troubleshooting
- The sandbox has no network access. Downloads from URLs and API calls fail; add the data as a document or attachment first.
- The sandbox is ephemeral: state does not persist between turns. Write intermediate results to files if you need them later.
- Disabled sandbox (
SANDBOX_ENABLED=false) removes the tool entirely. Ask an administrator to enable it in Admin → System → Sandbox. - Long or memory-heavy jobs hit execution limits. Filter or sample data, then run again.
- Generated artifacts are stored per turn; download the ones you need before the conversation gets long.