> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bow.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Run code in a report

> What people see when an agent runs code in a sandbox: the run in the chat, approvals, files saved to the report, and limits.

When sandboxes are on and you have access to an environment, an agent in a report can run code for you. Ask in plain words, for example:

* "Convert the attached spreadsheet to one CSV per sheet."
* "Install `matplotlib` and save a bar chart of this table as a PNG."
* "Run this script on the file I uploaded and tell me what it prints."

The first run in a report creates the report's sandbox. Later runs in the same report reuse it, with its files and installed packages still there.

> [!NOTE]
>
> Sandboxes are available in reports. If the agent says it has no sandbox, an admin has not turned sandboxes on, or you have not been given the permission or an environment. See [Who can use sandboxes](https://docs.bow.ai/sandboxes/overview.md#who-can-use-sandboxes).

## What a run looks like

Each run is one row in the chat. It shows the language and the first line of what ran. While it runs, the row shows the stage (**Starting the sandbox**, **Installing packages**, **Running**, **Saving files**) and the environment and network it runs with. When it ends, the row shows how long it took, and a label if it did not complete: **Failed**, **Timed out**, **Cancelled** or **Could not run**.

The row is collapsed. Select it to see the details: the code or command, the output and errors, the exit code, the packages installed, and the time limit. Output streams in while the run is in progress.

Files the run saved to the report are listed under the row, always visible. Select a file to open or download it; images are shown inline.

> [!NOTE]
>
> Code and output are hidden from people who do not have the **View generated code** permission. They still see that a run happened, how it ended, and its files.

## Files

Inside the sandbox the agent works under `/workspace`:

| Path | What it is for |
| - | - |
| `/workspace/inputs` | Files of the report that the agent passed into the run. Nothing from the report is in the sandbox unless the agent passes it in |
| `/workspace/outputs` | Results. Every new or changed file here is saved to the report after the run |
| Anywhere else in `/workspace` | Working files. Kept between runs, but lost when the sandbox is deleted or recreated |

Only files of the same report can be passed in.

A run can save up to 50 files, each up to 100 MB, and 500 MB in total. Files over a limit are skipped and listed in the run's details with the reason.

## Packages and the network

What a run can download depends on the environment's network policy:

* **No network**: nothing can be downloaded and packages cannot be installed. The run uses what is in the image.
* **Allowed domains only**: by default the pip, npm and Go package registries, so installing packages works. Other sites are refused.
* **Full internet**: public sites over HTTP and HTTPS.

The agent is told which of these applies before it runs anything, so it does not try downloads that cannot work. Installed packages stay in the sandbox for later runs.

## Approvals

An environment can be set to ask before a run. The chat then shows **Run this in the sandbox?** with the code that would run and why it is asking. Select **Allow** or **Deny**. A run nobody answers within four minutes does not happen.

The agent always asks before it deletes a report's sandbox, because deleting removes the sandbox's files and installed packages. Files already saved to the report are kept.

## Notices on a run

Small labels under a run tell you when something about the sandbox itself changed:

| Label | Meaning |
| - | - |
| **New sandbox** | This run created the report's sandbox |
| **Resumed** | The sandbox had been stopped and was started again. Its files are still there |
| **Fresh filesystem** | The sandbox was recreated. Files outside `/workspace/outputs` and installed packages are gone |
| **Report files put back** | After a recreation, the files this report had saved were copied back in |
| **Restored from a snapshot** | After a recreation, the whole workspace came back from its last snapshot |
| **Deletion scheduled** | The sandbox will be deleted soon for being unused or for its age. An admin can pin or extend it |
| **Processes left running** | A program the run started is still running in the sandbox |

## Limits

* **One run at a time** per sandbox. A second run while one is in progress is refused.
* **Time**: a run is stopped when it passes the environment's timeout, at most one hour.
* **Output**: the agent reads the last 20 KB of the output and of the errors. The run's details in the chat show the same; longer output is marked as shortened.
* **Running sandboxes per person**: set by your admin, 3 by default. When you reach it, wait for a sandbox to stop or ask the agent to delete one.
* **Languages**: Python, Node, Go and shell, as far as the environment's image has them.

Stopping the agent's reply in the chat also stops a run in progress.

## When the sandbox goes away

A sandbox is stopped after a while without runs and started again on the next one, with its files. It is deleted when it has been stopped for too long, when it reaches its maximum lifetime, or when its report is deleted. After a deletion the next run creates a new sandbox, and the files the report had saved are put back into it.

So keep what matters under `/workspace/outputs`, or ask the agent to save it there. See [Manage sandboxes](https://docs.bow.ai/sandboxes/manage.md) for the timings.

## Related

* [Sandbox](https://docs.bow.ai/sandboxes/overview.md)
* [Environments](https://docs.bow.ai/sandboxes/environments.md)
* [Reports](https://docs.bow.ai/using-bow/reports.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.