---
title: Sandboxes
slug: sandboxes
summary: Know where your Function and Agent code runs, what each sandbox gets, what it can reach, and how to stop one.
---

# Sandboxes

Code you publish to LimiLake runs in an isolated sandbox on the server, never on a shared machine with another Workspace. A sandbox has a copy of your Workspace, the LimiLake SDK, a short-lived token and a fixed share of CPU and memory. It has no provider credentials.

## What runs where

| What | Where it runs |
|---|---|
| A Function Run (a scheduled run, `limilake function invoke`, a run started from an App) | A new sandbox for each run, deleted when the run ends |
| A Function's HTTP routes | A warm sandbox per Function revision and identity, shared by its callers |
| An Agent run (`agent.run()`, a chat, a scheduled Agent) | The agent's own sandbox, kept between its runs until it is idle |
| The code editor in the web app | Its own sandbox for your editing session |
| `limilake dev`, `limilake function serve`, `limilake function invoke --local` | Your own machine |

The local commands run your code in the Workspace's Python environment on your machine. Lake queries, AI calls and Connection calls still go to the live platform and are authorized there, exactly as in a sandbox. Use them for breakpoints and fast reloads, and use `limilake function invoke` without `--local` to test in a real sandbox. See [Running](./functions.md#running).

## What is shared and what is not

Each Function Run gets its own sandbox with a clean checkout of the Workspace, and the sandbox is deleted when the run ends. Files a run writes to disk are gone with it, and two runs never see each other's files or memory. Keep anything the next run needs in a Lakehouse table.

An agent works differently. A run uses the agent's sandbox when one is still live, and the sandbox stays between runs until it has been idle for a while. A run with the same `session=` name returns to the same agent, so it keeps its conversation; a run without `session=` creates a new agent. Two runs of one agent never run at the same time. Because the transcript is stored outside the sandbox, the conversation survives even when the sandbox is gone. See [Sessions](./agents-reference.md#sessions-and-tier-1-memory).

A Function's HTTP routes share one warm sandbox between requests; see [Warm and cold HTTP routes](#warm-and-cold-http-routes).

Sandboxes are never shared between Workspaces.

## Resources and time

Every sandbox can use up to 2 CPU cores and 4 GiB of memory. A run that needs more memory than that fails. You cannot raise these limits from code.

A Function Run may take 30 minutes by default. Set `timeout=` on the Function to allow from 1 minute to 24 hours:

```python
fn = limilake.function(
    id="123e4567-e89b-42d3-a456-426614174003",
    name="rebuild-sales",
    timeout="2h",
)
```

A run that passes its timeout ends with status `timed_out`.

## Warm and cold HTTP routes

A Function's HTTP routes run in a warm server that stays up between requests, so a request to a warm server starts at once.

- There is one server per Function revision and identity. A `run_as="assigned"` Function shares one server between all its callers. A `run_as="caller"` Function gets a separate server for each person who calls it.
- A server with no requests for 30 minutes is stopped. A push that changes the Function starts a new server for the new revision on the next request.
- The first request to a stopped server is a cold start. LimiLake holds that request for up to 30 seconds while the server starts, then answers it. Later requests are warm again.
- A Function serves at most `concurrency_limit` requests at the same time (default 4, from 1 to 100). A call from a published App that finds every slot busy waits up to 30 seconds for one, then gets `429`. A direct call gets `429` at once.
- A request body may be up to 32 MiB, or 1 MiB when the call comes from a published App. An asynchronous request (`Prefer: respond-async`) may run for up to 15 minutes.

## Network

A sandbox can reach:

- LimiLake itself: your Lakehouses, AI models, documents, the Workspace Git repository and your Connections.
- The public internet, for example to download a package or call a public API.

A sandbox cannot reach private network ranges, so a service on your own internal network is out of reach. Expose it through a public HTTP API and call it with a [Connection](./connections.md).

## Secrets

Provider credentials never enter the sandbox. When your code calls `limilake.connections`, the request leaves the sandbox without a credential, and LimiLake adds it on the way out to the provider. Your code, its logs and the sandbox's disk never hold the secret. The only exception is a Connection that allows revealing its material to code that asks for it; see [Revealing material](./connections-reference.md#revealing-material).

## Identity

The token inside a sandbox is not a copy of your login. It carries the authority of the identity the code runs as, and every call is checked against that identity's live Workspace Access Level. If someone loses access to the Workspace, calls made with their authority start to fail at once.

An Agent run gets a narrower token still, and an Agent cannot start another Agent: a call to `agent.run()` from inside an Agent's sandbox is refused. See [Scope](./agents-reference.md#scope-and-what-a-code-invoked-agent-can-do).

## Stopping a run

To stop a Function Run, find its `execution_id` with `limilake function logs` and cancel it. This also stops its sandbox:

```bash
limilake function logs functions/rebuild-sales/function.py --workspace finance
limilake execution cancel <execution-id>
```

To stop any live sandbox, such as a warm HTTP server or an editor session, use its sandbox ID from the **Sandboxes** page in the web app's settings:

```bash
limilake sandbox cancel <sandbox-id>
```

Both commands need `editor` or `owner` on the Workspace. A stopped HTTP server starts again on its next request.

## Limits at a glance

| Limit | Value |
|---|---|
| CPU per sandbox | 2 cores |
| Memory per sandbox | 4 GiB |
| Function Run timeout | 30 minutes by default, 1 minute to 24 hours with `timeout=` |
| Idle HTTP server | Stopped after 30 minutes without requests |
| Cold start hold | Up to 30 seconds |
| Concurrent HTTP requests per Function | `concurrency_limit`, default 4, at most 100 |
| Wait for a free slot from a published App | Up to 30 seconds, then `429` |
| HTTP request body | 32 MiB, or 1 MiB from a published App |
| Asynchronous HTTP request | Up to 15 minutes |
| Outbound network | LimiLake services and the public internet, no private network ranges |

## Next steps

- [Functions](./functions.md): write the code that runs in a sandbox.
- [Schedules](./schedules.md): run a Function on a schedule.
- [Connections](./connections.md): call providers without secrets in your code.
