> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Code interpreter

> Sandboxed code execution in ClickHouse Agents

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

export const galaxyOnClick = eventName => () => {
  try {
    if (typeof window !== "undefined" && window.galaxy && eventName) {
      window.galaxy.track(eventName, {
        interaction: "click"
      });
    }
  } catch (e) {}
};

export const BetaBadge = ({link, galaxyTrack, galaxyEvent}) => {
  if (link) {
    return <a href={link} target="_blank" rel="noopener noreferrer" className="betaBadge" onClick={galaxyTrack && galaxyEvent ? galaxyOnClick(galaxyEvent) : undefined}>
                <Icon />
                <span>Beta</span>
            </a>;
  }
  return <div className="betaBadge">
            <Icon />
            <span>
                Beta feature. 
                <u>
                    <a href="/docs/beta-and-experimental-features#beta-features">
                        Learn more.
                    </a>
                </u>
            </span>
        </div>;
};

The code interpreter lets an agent execute code in a managed sandbox. Use it for computation, data transformation, format conversion, plotting, and anything else better done in code than in natural language.

<h2 id="enable-it">
  Enable the code interpreter
</h2>

In the Agent Builder, enable **Run Code** in the **Capabilities** section, then save. The agent decides when to run code based on the user's request and the agent's instructions.

<Image img="https://mintcdn.com/private-7c7dfe99-fix-nav-issues/huP88Vza7bEG09HU/images/cloud/agent-builder/run-code/run-code.png?fit=max&auto=format&n=huP88Vza7bEG09HU&q=85&s=06891a5870718ef780f120e541ba171f" alt="Run Code section of the Capabilities panel with the Run Code checkbox enabled and an Upload to Code Environment button" size="sm" width="616" height="1412" data-path="images/cloud/agent-builder/run-code/run-code.png" />

<h2 id="supported-languages">
  Supported languages
</h2>

The sandbox is a Unix environment with two general-purpose runtimes and a few shell utilities:

* **Python 3** - the default for data tasks.
* **Node.js (JavaScript)** - when an agent prefers JS for the job.
* **Bash** and **sh** - shell scripting for chaining commands and quick I/O.
* **AWK** and **sed** - line-oriented text processing.
* **bc** - arbitrary-precision math.

Agents reach for Python first for anything involving data parsing, transformation, or computation.

<Tip>
  Reserve the shell tools for tasks that genuinely benefit from a one-liner.
</Tip>

<h2 id="files">
  Files
</h2>

Users can upload files into a conversation; the code interpreter has access to them in the sandbox working directory. Code can also write output files (CSVs, plots, archives) which appear in the conversation as downloadable attachments.

<h2 id="sandbox-isolation">
  Sandbox isolation
</h2>

Each execution runs in an ephemeral sandbox with no network access and no persistent storage. Sessions don't share state — variables and files from one run don't carry into the next unless the agent explicitly re-loads them.

Plan-specific resource limits (memory, files per run, monthly request quotas) apply. Errors and stderr are surfaced in the conversation alongside stdout.

<h2 id="when-to-use-it">
  When to use it
</h2>

Reach for the code interpreter when the answer requires deterministic computation that a language model can't produce reliably by reasoning alone.
Typical cases include:

* Parsing a CSV or JSON file the user uploaded.
* Computing summary statistics or running a quick simulation.
* Converting between formats (Parquet, JSON, CSV).
* Generating a plot from query results.

<Tip>
  Avoid it for tasks the model can already answer from context.
  Code execution adds latency and consumes quota.
</Tip>
