# Configuration of Environment Variables

Source: https://agenta.ai/docs/self-host/reference/configuration

Agenta encodes the same nesting at three layers: the environment variable name,
the Python `env.py` attribute path, and the Helm `values.yaml` path. Every
section below lists the canonical names in those three forms.

For deprecated/legacy environment variable names that still work via fallback,
see [Deprecated environment variables](#deprecated-environment-variables) at
the bottom.

:::tip Kubernetes / Helm
For Helm deployments, set the `values.yaml` path instead of the env var. The
chart maps every value to the same canonical env var internally.
:::

:::note Helm-only pre-existing Secret
The Helm chart accepts a single Helm-only key, `secrets.existingSecret`, that
points at a pre-created Kubernetes Secret. When set, the chart will not create
or update the Secret object; it just wires `envFrom`/`secretKeyRef` references
to the name you provide. Your Secret must contain the canonical env-var keys
(`AGENTA_AUTH_KEY`, `AGENTA_CRYPT_KEY`, `AGENTA_SERVICES_INTERNAL_KEY`, `POSTGRES_PASSWORD`, and any optional
keys such as `SUPERTOKENS_API_KEY`, `OPENAI_API_KEY`, OAuth client secrets,
etc.). See [Deploy to Kubernetes Secrets](https://agenta.ai/docs/self-host/deploy/deploy-to-kubernetes.md#secrets).
This key has no env-var or `env.py` equivalent.
:::

## Agenta core

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_WEB_URL` | `agenta.web_url` | `agenta.webUrl` |
| `AGENTA_APP_ORIGINS` | `agenta.app_origins` | n/a |
| `AGENTA_SERVICES_URL` | `agenta.services_url` | `agenta.servicesUrl` |
| `AGENTA_API_URL` | `agenta.api_url` | `agenta.apiUrl` |
| `AGENTA_API_INTERNAL_URL` | `agenta.api_internal_url` | `agenta.apiInternalUrl` |
| `AGENTA_AUTH_KEY` | `agenta.auth_key` | `agenta.authKey` |
| `AGENTA_CRYPT_KEY` | `agenta.crypt_key` | `agenta.cryptKey` |
| `AGENTA_SERVICES_INTERNAL_KEY` | `agenta.services_internal_key` | `agenta.servicesInternalKey` |
| `AGENTA_RUNNER_TOKEN` | n/a (read by the runner and its caller) | `agenta.runnerToken` |

A new install does not set `AGENTA_LICENSE` for the API. The env file examples set
`POSTGRES_DB_PREFIX` instead. See [postgres](#postgres).

Existing installs that set AGENTA_LICENSE keep working; new installs do not need it.

On such an install, the API reads `AGENTA_LICENSE` only for the default database names. Each of
the three databases gets its name on its own: from its `POSTGRES_URI_*` variable, else from
`POSTGRES_DB_PREFIX`, else from `AGENTA_LICENSE`. `ee` gives `agenta_ee_core`,
`agenta_ee_tracing` and `agenta_ee_supertokens`. Any other value, or no value, gives `agenta_oss_*`.
The web container still reads it to pick the classic web (`/w`) build, and the services container
reads it for [provider keys from the environment](#llm-provider-api-keys). For this reason, the
Enterprise env file examples and the Helm value `agenta.license` keep it. It does not decide the
plan or the features: a [license key](#license) does.

:::warning Do not change or remove `AGENTA_LICENSE` on an install that has data
A database that has neither its `POSTGRES_URI_*` variable nor `POSTGRES_DB_PREFIX` set then opens
another database name, which is empty, and the install looks as if its data is gone. To move to a paid plan, add a
[license key](https://agenta.ai/docs/self-host/reference/license-keys.md) instead.
:::

`AGENTA_AUTH_KEY`, `AGENTA_CRYPT_KEY`, `AGENTA_SERVICES_INTERNAL_KEY`, and `AGENTA_RUNNER_TOKEN`
are required secrets: the examples ship them as `replace-me` and you must set a real value for
each. See [Agent runner](#routing-and-authentication) for the runner token.

`AGENTA_APP_ORIGINS` lists every other address your deployment's app answers on, comma separated.
Set it only when there is more than one. A deployment reachable at a single address needs nothing
here, and `AGENTA_WEB_URL` is always used first whether or not you set this.

It matters for the MCP consent flow. When someone authorizes an MCP server, the page the provider
returns to has to hand the result back to the window that opened it, and it can only do that by
naming that window's address exactly. A deployment reachable at a tunnel and at a local address is
two addresses, so listing only one means everyone using the other watches the `Connect` dialog wait
out its three-minute timeout, even though the server was authorized and the connection is sitting
there ready behind the dialog. Listing both addresses fixes that.

Give origins only, with no path:

```bash
AGENTA_APP_ORIGINS=https://agenta.example.com,http://localhost:8680
```

Anything without a scheme and a host is ignored, and a repeat of `AGENTA_WEB_URL` is dropped rather
than listed twice. Addresses have to be declared here rather than worked out from the request,
because the address a browser used to reach the page is something the caller can set. The API's own
address is never used, so a deployment that publishes no app address sends the result nowhere.

`AGENTA_SERVICES_INTERNAL_KEY` proves to the API that a caller **is** the platform runtime (the
Services container), as opposed to a browser or an ApiKey holder reaching the same public route.
Only a caller holding it can be issued a credential that reads write-only secret values (a run
whose connection stores such a secret otherwise fails with a misleading "provide the provider key
in this run's environment" error). Set the **same** value on the API and the Services container;
generate it the same way as the other keys:

```bash
openssl rand -hex 32
```

There is no fallback to `AGENTA_AUTH_KEY` — the API refuses to start (`AGENTA_SERVICES_INTERNAL_KEY
is required and must not use the placeholder. ...`) while this is unset or still `replace-me`. It
is never sent to the runner or into a sandbox.

## Agenta access

The first four variables (allowed/blocked domains and emails, allowed owner
emails) apply to both the open source and Enterprise editions. See
[Restrict Sign-ups and Organization Creation](https://agenta.ai/docs/self-host/access-control/restrict-organization-creation.md)
for how they behave. The plan and role variables are Enterprise-only; see
[Dynamic Access Controls](https://agenta.ai/docs/self-host/access-control/dynamic-access-controls.md).

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_ACCESS_ALLOWED_DOMAINS` | `agenta.access.allowed_domains` | `agenta.access.allowedDomains` |
| `AGENTA_ACCESS_ALLOWED_OWNER_EMAILS` | `agenta.access.allowed_owner_emails` | `agenta.access.allowedOwnerEmails` |
| `AGENTA_ACCESS_BLOCKED_DOMAINS` | `agenta.access.blocked_domains` | `agenta.access.blockedDomains` |
| `AGENTA_ACCESS_BLOCKED_EMAILS` | `agenta.access.blocked_emails` | `agenta.access.blockedEmails` |
| `AGENTA_ACCESS_MAX_OWNED_ORGANIZATIONS` | `agenta.access.max_owned_organizations` | `agenta.access.maxOwnedOrganizations` |
| `AGENTA_ACCESS_TRUSTED_PROXY_HOPS` | `agenta.access.trusted_proxy_hops` | `agenta.access.trustedProxyHops` |
| `AGENTA_ACCESS_TRUST_CLOUDFLARE_IP` | `agenta.access.trust_cloudflare_ip` | `agenta.access.trustCloudflareIp` |
| `AGENTA_ACCESS_DEFAULT_PLAN` | `agenta.access.default_plan` | `agenta.access.defaultPlan` |
| `AGENTA_ACCESS_DEFAULT_PLAN_OVERLAY` | `agenta.access.default_plan_overlay` | `agenta.access.defaultPlanOverlay` |
| `AGENTA_ACCESS_EMAIL_DISABLED` | `agenta.access.email_disabled` | `agenta.access.emailDisabled` |
| `AGENTA_ACCESS_PERSONAL_ACCOUNTS_ENABLED` | `agenta.access.personal_accounts_enabled` | `agenta.access.personalAccountsEnabled` |
| `AGENTA_ACCESS_PLANS` | `agenta.access.plans` | `agenta.access.plans` |
| `AGENTA_ACCESS_ROLES` | `agenta.access.roles` | `agenta.access.roles` |
| `AGENTA_ACCESS_ROLES_OVERLAY` | `agenta.access.roles_overlay` | `agenta.access.rolesOverlay` |

The API limits sign-in code and sign-up requests per client IP, and sends the client IP to
Turnstile. Set `AGENTA_ACCESS_TRUSTED_PROXY_HOPS` to the number of proxies in front of the API
that append to `X-Forwarded-For`, so the API reads the IP those proxies saw and ignores entries a
client adds itself. The bundled Traefik and nginx setups need `1`. When it is unset, the API
uses the first `X-Forwarded-For` entry, which a client can set. The API reads `CF-Connecting-IP`
only when `AGENTA_ACCESS_TRUST_CLOUDFLARE_IP` is `true`. Turn it on only when Cloudflare proxies
every request to the API.

`AGENTA_ACCESS_PERSONAL_ACCOUNTS_ENABLED` defaults to `true`. People can then store their own
accounts (custom secrets, Composio connections, MCP sign-ins), and an agent's `user` items use
them. Set it to `false` to turn this off. While it is `false`, the API refuses person-owned
writes and account choices, and a run leaves every `user` item out. During an upgrade, set it to
`false` until every API pod, services pod and runner runs a release that supports personal accounts.
On Kubernetes, set `agenta.access.personalAccountsEnabled`. The chart default is `true`, and the chart renders it into the API, worker, cron, services and alembic pods. To keep the old behavior during an upgrade, set it to `false`, and set it back to `true` once every pod runs the release.

## Agenta AI services

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_AI_SERVICES_API_KEY` | `agenta.ai_services.api_key` | `agenta.aiServices.apiKey` |
| `AGENTA_AI_SERVICES_API_URL` | `agenta.ai_services.api_url` | `agenta.aiServices.apiUrl` |
| `AGENTA_AI_SERVICES_ENVIRONMENT_SLUG` | `agenta.ai_services.environment_slug` | `agenta.aiServices.environmentSlug` |
| `AGENTA_AI_SERVICES_REFINE_PROMPT_KEY` | `agenta.ai_services.refine_prompt_key` | `agenta.aiServices.refinePromptKey` |

## Agenta billing

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_BILLING_CATALOG` | `agenta.billing.catalog` | `agenta.billing.catalog` |
| `AGENTA_BILLING_PRICING` | `agenta.billing.pricing` | `agenta.billing.pricing` |

## Agenta API

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_API_CACHING_ENABLED` | `agenta.api.caching.enabled` | `agenta.api.caching.enabled` |
| `AGENTA_API_THROTTLING_BOOKKEEPING_CAPACITY` | `agenta.api.throttling.bookkeeping_capacity` | Not mapped; set it in the API's environment |
| `AGENTA_API_THROTTLING_BOOKKEEPING_RATE` | `agenta.api.throttling.bookkeeping_rate` | Not mapped; set it in the API's environment |
| `AGENTA_API_TRACING_QUERY_DEFAULT_LIMIT` | `agenta.api.tracing.query_default_limit` | Not mapped; set it in the API's environment |
| `AGENTA_API_TRACING_QUERY_MAX_LIMIT` | `agenta.api.tracing.query_max_limit` | Not mapped; set it in the API's environment |

The two throttling variables apply to Enterprise Edition deployments, which throttle API requests
per organization and plan. They size a separate budget for the agent runtime's own calls: the
runner's heartbeats, turn and record reads, approvals, mount signing and credential refresh, sent
with a run's credential. These calls do not spend the plan's budget. The value is in requests per
minute per organization, and the default for both is `60000`. When an organization's plan allows
more for these requests, the plan's larger budget applies. The routes that count as these calls are listed in `api/ee/src/middlewares/throttling.py`
(`_BOOKKEEPING_ROUTES`). Every other request, including tool calls the model makes, spends the
plan's budget.

The two tracing variables bound one page of a span or trace list query: `POST /api/spans/query`,
`POST /api/traces/query` and the legacy `POST /api/tracing/spans/query`. A request with no
`windowing.limit` returns `AGENTA_API_TRACING_QUERY_DEFAULT_LIMIT` rows (default `100`). A larger
`windowing.limit` is lowered to `AGENTA_API_TRACING_QUERY_MAX_LIMIT` (default `1000`). With
`focus` set to `trace`, the limit counts traces. When a page is full, the response has a
`windowing` object; send it back as `windowing` to read the next page. A query that filters only on
`trace_id` returns whole traces and has no limit. A higher maximum lets one request use more API
memory: agent run spans can be hundreds of KB each.

## Agenta logging

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_LOGGING_CONSOLE_ENABLED` | `agenta.logging.console_enabled` | `agenta.logging.consoleEnabled` |
| `AGENTA_LOGGING_CONSOLE_LEVEL` | `agenta.logging.console_level` | `agenta.logging.consoleLevel` |
| `AGENTA_LOGGING_FILE_ENABLED` | `agenta.logging.file_enabled` | `agenta.logging.fileEnabled` |
| `AGENTA_LOGGING_FILE_LEVEL` | `agenta.logging.file_level` | `agenta.logging.fileLevel` |
| `AGENTA_LOGGING_FILE_PATH` | `agenta.logging.file_path` | `agenta.logging.filePath` |
| `AGENTA_LOGGING_OTLP_ENABLED` | `agenta.logging.otlp_enabled` | `agenta.logging.otlpEnabled` |
| `AGENTA_LOGGING_OTLP_LEVEL` | `agenta.logging.otlp_level` | `agenta.logging.otlpLevel` |

## Agenta OTLP

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_OTLP_MAX_BATCH_BYTES` | `agenta.otlp.max_batch_bytes` | `agenta.otlp.maxBatchBytes` |

## Agenta redaction

The online redaction filter scrubs known credential/secret **values** out of error responses,
persisted records, spans, and logs on the invoke path (detective control, not preventive; see
[docs/design/online-redaction](https://github.com/agenta-ai/agenta/blob/main/docs/design/online-redaction/specs.md)).
The filter redacts a value only when it is a live secret the platform resolved for the request,
never by guessing at shape or entropy.

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_REDACTION_MODE` | `agenta.redaction.mode` | `agenta.redaction.mode` |
| `AGENTA_REDACTED_PREFIXES` | `agenta.redaction.prefixes` | `agenta.redaction.prefixes` |
| `AGENTA_REDACTED_SUFFIXES` | `agenta.redaction.suffixes` | `agenta.redaction.suffixes` |
| `AGENTA_REDACTED_BLOCKLIST` | `agenta.redaction.blocklist` | `agenta.redaction.blocklist` |
| `AGENTA_REDACTED_ALLOWLIST` | `agenta.redaction.allowlist` | `agenta.redaction.allowlist` |

- `AGENTA_REDACTION_MODE`: `off` or `known` (default `known`). `pattern` and `full` are accepted
  but currently behave as `known`; setting either logs a warning.
- `AGENTA_REDACTED_PREFIXES` / `_SUFFIXES` / `_BLOCKLIST` select env var **names**, not values:
  any process env var whose name starts with a prefix, ends with a suffix, or equals/contains a
  blocklist entry has its **value** seeded into the deny-set. Each is comma-separated and
  **merges onto its built-in default** (concatenation, never a replace); you only ever add
  more names to catch, you can't narrow the defaults. The prefix default is **empty** (opt-in
  only, since a broad service prefix over-seeds non-secret config like hostnames/regions); the
  suffix default covers the common credential-shaped endings (`_KEY`, `_SECRET`, `_TOKEN`,
  `_AUTHTOKEN`, `_PASSWORD`, `_CREDENTIALS`, `_KEY_ID`, `_SECRET_ID`, `_TOKEN_ID`); the
  blocklist default is `AWS_BEARER_TOKEN_BEDROCK` (a real secret whose name matches no suffix).
- `AGENTA_REDACTED_ALLOWLIST` is different: it's a list of literal **values** (booleans/flags
  such as `true`/`false`/`1`/`0`) that are never redacted even if a secret-named env var holds
  one. Otherwise a flag like `SOME_FEATURE_KEY=true` would redact every "true" in output. It
  also merges (union) onto its built-in default; add values here that your deployment uses as
  flags but that also happen to sit in a secret-suffixed env var.
- Safe default is unset. Leaving all four unset keeps prefix empty, suffix/blocklist/allowlist
  at their built-in defaults.

## Agenta SDK errors

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_SDK_ERRORS_INCLUDE_STACKTRACE` | n/a (read directly by the SDK) | n/a |

An invoke that fails answers with the failure's type, message and code, and the Python
traceback goes to the service log. Set `AGENTA_SDK_ERRORS_INCLUDE_STACKTRACE=true` to put the
traceback in the response body as well, which is worth doing while you are running the service
yourself and reading failures in your own browser instead of in the log. It defaults to `false`
and is read on each call, so changing it needs no restart.

:::warning
The traceback exposes the service's internals to whoever called the route: absolute module
paths, the service's own layout, and the source line of every frame between the route and the
handler. The playground calls this route from a browser. Leave this off on any deployment other
people can reach.
:::

## Agenta services

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_SERVICES_CODE_SANDBOX_RUNNER` | `agenta.services.code.sandbox_runner` | `agenta.services.code.sandboxRunner` |
| `AGENTA_SERVICES_CODE_SANDBOX_TIMEOUT` | n/a (SDK-side) | n/a |
| `AGENTA_SERVICES_CODE_SANDBOX_WAIT_TIMEOUT` | n/a (SDK-side) | n/a |
| `AGENTA_SERVICES_ENV_PROVIDER_KEYS_ENABLED` | n/a (SDK-side) | `services.env.AGENTA_SERVICES_ENV_PROVIDER_KEYS_ENABLED` |
| `AGENTA_SERVICES_MIDDLEWARE_AUTH_ENABLED` | n/a (SDK-side) | `agenta.services.middleware.authEnabled` |
| `AGENTA_SERVICES_MIDDLEWARE_CACHING_ENABLED` | `agenta.services.middleware.caching_enabled` | `agenta.services.middleware.cachingEnabled` |
| `AGENTA_SERVICES_PATH_PREFIX` | n/a (read by the services entrypoint) | `services.env.AGENTA_SERVICES_PATH_PREFIX` |

`AGENTA_SERVICES_PATH_PREFIX` is the public path prefix the services backend strips from an inbound
request. The default is `/services`. The backend strips it in a loop, so a request arrives correctly
whether your proxy forwards the prefix or strips it first. Set the variable to an empty string to
turn the strip off. The platform API strips a leading `/api` the same way, and that prefix is not
configurable.

:::warning Choosing a code runner
`AGENTA_SERVICES_CODE_SANDBOX_RUNNER` selects how [custom-code evaluators](https://agenta.ai/docs/1.0/evaluation/configure-evaluators/custom-evaluator) execute:

- `daytona`: runs each evaluation in its own isolated Daytona sandbox. Use it when people you do not fully trust can write evaluator code. It requires the [daytona](#daytona-code-evaluator) credentials below.
- `local` (default): runs the code in the services process with no sandbox restrictions. The code can do anything the services process can do. The deployment logs a warning while it is active.
- `restricted`: runs the code in the services process (RestrictedPython) and limits which builtins and imports it can use. It is not an isolation boundary.

Use `local` or `restricted` only when everyone who can create evaluators is trusted. Agenta Cloud uses `daytona`.

The legacy `AGENTA_SERVICES_SANDBOX_RUNNER` is still accepted as a fallback.

`AGENTA_SERVICES_CODE_SANDBOX_TIMEOUT` sets the hard timeout, in seconds, for one custom-code evaluator run (default `45`). A run that takes longer fails with an evaluator error. Keep it below the services worker timeout (`60` seconds in the default deployment).

Each services worker runs at most 16 custom-code evaluator runs at a time. `AGENTA_SERVICES_CODE_SANDBOX_WAIT_TIMEOUT` sets how long, in seconds, a run waits for a free slot when all 16 are busy (default `10`). A run that is still waiting after that time fails with "Custom code runs are at capacity (16 in progress). Try again later." Set it to `0` to fail at once. The run timeout starts only when the run gets a slot. The API gives one evaluator call `60` seconds, so keep the wait plus the run timeout below `60`.
:::

## Agent runner

Agent workflows run through a separate `runner` service that executes agent code, either inside its
own container (`local`) or in a Daytona cloud sandbox. This section lists every operator-facing
runner variable, its default, its Helm path, and the errors an invalid value produces.

The runner parses all of its `AGENTA_RUNNER_*` variables once before it starts listening. An
invalid value fails startup with the error shown in [Startup validation](#startup-validation).

For the model behind these settings, see [How agents run](https://agenta.ai/docs/self-host/concepts/how-agents-run.md).
The local subscription mount variables (`PI_CODING_AGENT_DIR` and `CLAUDE_CONFIG_DIR`) are covered
by [Use your own subscription](https://agenta.ai/docs/self-host/agents/use-your-own-subscription.md).

`AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS` and `AGENTA_RUNNER_DEFAULT_SANDBOX_PROVIDER` are read by
both the runner and the Services API. Setting the enabled list to `daytona` only keeps agent code
out of the runner container on a shared deployment. See
[Sandbox isolation and security](https://agenta.ai/docs/self-host/concepts/sandbox-isolation-and-security.md).

The bundled Compose env examples group these variables under `Agenta - Agent runner` in the same
order as the sections below, so the file and this page mirror each other.

### Service

Set on the `runner` service.

| Variable | Role | Default | Secret | Helm |
|---|---|---|---|---|
| `AGENTA_RUNNER_HOST` | Bind interface | `127.0.0.1` | no | `agentRunner.env.AGENTA_RUNNER_HOST` |
| `AGENTA_RUNNER_PORT` | Bind port | `8765` | no | Chart-managed (`8765`) |
| `AGENTA_RUNNER_CONCURRENCY_LIMIT` | Maximum concurrent runs | `1000` | no | `agentRunner.env.AGENTA_RUNNER_CONCURRENCY_LIMIT` |
| `AGENTA_RUNNER_LOG_LEVEL` | Log verbosity | `silent` | no | `agentRunner.logLevel` |
| `AGENTA_RUNNER_REPLICA_ID` | Runner identity: the platform binds each turn to one runner by this id | Random per process when unset | no | Chart-managed (the pod name) |
| `AGENTA_RUNNER_REPLICA_ADDRESS` | URL that reaches this runner directly, where the platform sends Stop for its turns | Empty (use `AGENTA_RUNNER_INTERNAL_URL`) | no | Chart-managed (`http://<pod IP>:<port>`) |
| `AGENTA_RUNNER_SHUTDOWN_WAIT_SECONDS` | Seconds a stopping runner lets its running turns finish before it cancels them | `0` | no | `agentRunner.shutdownWaitSeconds` (default: the grace period minus 100 with `RollingUpdate`, `0` with `Recreate`) |

Every variable on this page treats an empty value as unset, so leaving a line blank selects the
default rather than an empty string.

The code default host is `127.0.0.1`. The bundled Compose files set `AGENTA_RUNNER_HOST=0.0.0.0`
so the Services container can reach the runner across the Compose network. `AGENTA_RUNNER_PORT` and
`AGENTA_RUNNER_CONCURRENCY_LIMIT` must be positive integers.

`AGENTA_RUNNER_REPLICA_ID` is not only a log label. The platform binds each turn to the first runner
that reports it, and refuses the same turn from a runner with a different id. Every runner must
therefore have its own id. When the value is unset the runner generates a fresh id on each start.
The bundled `gh` Compose files set `local-runner-1`, which is safe because Compose runs one runner.
The bundled `dev` Compose files leave it unset, so the runner generates an id on each start. The Helm
chart sets the pod name, and the render fails when `agentRunner.env` or `agentRunner.extraEnv`
sets this variable.

`AGENTA_RUNNER_REPLICA_ADDRESS` is where the platform API sends Stop for a turn that this runner
runs, and where Services sends the session's follow-up messages. Leave it empty when one runner
sits behind `AGENTA_RUNNER_INTERNAL_URL`, as in Compose. The Helm chart sets it to the pod IP and
the runner port, so the API and Services must be able to reach runner pods directly: a
NetworkPolicy that blocks API or Services traffic to runner pod IPs breaks Stop and follow-up
routing. The platform stores the
address only when the runner presents its runner token.

When a runner gets SIGTERM, it refuses new turns with a 503 and keeps Stop and Kill open. It lets
its running turns finish for `AGENTA_RUNNER_SHUTDOWN_WAIT_SECONDS`, cancels the turns that still
run, and deletes its sandboxes. The default `0` cancels at once, because Docker Compose stops a
container 10 seconds after SIGTERM. The Helm chart sets the wait from the pod's grace period when the runner rolls out with
`RollingUpdate`, to `0` when it uses `Recreate` (the local sandbox), or from
`agentRunner.shutdownWaitSeconds`, and the render fails when `agentRunner.env` or
`agentRunner.extraEnv` sets this variable.

:::warning Helm upgrade: remove chart-owned runner variables
The Helm chart sets these four variables itself:

- `AGENTA_RUNNER_REPLICA_ID`
- `AGENTA_RUNNER_SHUTDOWN_WAIT_SECONDS`
- `AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS`
- `AGENTA_RUNNER_DEFAULT_SANDBOX_PROVIDER`

If your values file sets any of them under `agentRunner.env` or `agentRunner.extraEnv`, remove those
lines before you upgrade. Otherwise `helm upgrade` fails with `CONFIGURATION ERROR`, and the error
names the variable and the key to remove from. Earlier docs told Helm users to set
`agentRunner.env.AGENTA_RUNNER_REPLICA_ID`. That setting is no longer allowed.

Use the chart values instead:

```yaml
agentRunner:
  shutdownWaitSeconds: 30
  providers:
    enabled: [daytona]
    default: daytona
    daytona:
      apiKeySecretRef:
        name: agenta-runner-daytona
        key: api-key
```

The Secret named in `apiKeySecretRef` holds your Daytona API key. The chart injects it as
`AGENTA_RUNNER_DAYTONA_API_KEY`. The runner needs it when Daytona is enabled.

`agentRunner.providers.enabled` and `agentRunner.providers.default` accept `local`, `daytona` and
`inprocess`. The chart sets the replica id to the pod name; there is no value to set.
:::

The local sandbox is single-runner only: its sessions live on one runner's disk. To run multiple
runners, use the Daytona provider.

### Routing and authentication

These locate the runner and authenticate the call. Two of the three are caller-side: the Services
API and its SDK read them, not the runner. The platform API also reads the locator and token
directly. It calls the runner to cancel a turn when a user presses Stop (`POST /cancel`), and to tear down a sandbox
for the session `kill` verb (`POST /kill` on the runner). It is a second, independent caller of the
same runner HTTP surface, not routed through Services, so both containers need both values.

| Variable | Role | Read by | Default | Secret | Helm |
|---|---|---|---|---|---|
| `AGENTA_RUNNER_INTERNAL_URL` | Runner locator | Services API and the platform API (both caller-side) | Compose: `http://runner:8765` on both callers (the `gh.local` and `gh.ssl` files set it on `api` from v0.115.3) | no | `agentRunner.externalUrl`, else derived from `agentRunner.enabled` |
| `AGENTA_RUNNER_TOKEN` | Shared request credential | Services and the platform API send it; runner verifies it | **Required — no default** | yes | `agenta.runnerToken`, or `agentRunner.auth.tokenSecretRef` to source it from your own Secret |
| `AGENTA_RUNNER_TIMEOUT_SECONDS` | Idle timeout the caller allows on the run request | Services API and SDK (caller-side) | `1980` | no | n/a |

`AGENTA_RUNNER_TOKEN` is **required**, like `AGENTA_AUTH_KEY`. The runner refuses to start without
it and rejects an un-tokened request with `401`, so there is no unauthenticated mode. It carries a
run's plaintext provider keys, so set the **same** value on the runner and on the service that calls
it:

```bash
openssl rand -hex 32
```

The bundled examples ship `AGENTA_RUNNER_TOKEN=replace-me`; replace it before you deploy. On
Kubernetes, set `agenta.runnerToken` (the chart fails to render without it), or set
`agentRunner.auth.tokenSecretRef` to read the value from a Secret your own vault populates.

The token is defense in depth on top of network isolation, not a replacement for it: keep the runner
on a private network and never publish its port.

`AGENTA_RUNNER_TOKEN` is the same credential across all parties. It does not belong to a sandbox or
a harness. The runner refuses to start without it and rejects any un-tokened request with `401`;
there is no unauthenticated mode. Set the same value on the runner, the Services API, and the
platform API; in Helm, point `agentRunner.auth.tokenSecretRef` at a Secret holding it — the chart
injects the same value into the runner, Services, and API deployments.

`AGENTA_RUNNER_TIMEOUT_SECONDS` bounds idle time on the caller's streaming transport, not the total
run duration, and the runner never reads it. The runner enforces its own deadlines through
[Run limits](#run-limits). Set the caller timeout above the runner's idle timeout, or the caller
gives up on a run the runner still considers healthy.

### Sandbox providers

Read by both the runner and the Services API, so the operator sets each value once and hosting
templates apply it to both.

| Variable | Role | Default | Helm |
|---|---|---|---|
| `AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS` | Providers this deployment can use | `local` | `agentRunner.providers.enabled` (list, rendered comma-joined) |
| `AGENTA_RUNNER_DEFAULT_SANDBOX_PROVIDER` | Provider used when a run does not choose | `local` | `agentRunner.providers.default` |

The Helm chart checks `agentRunner.providers` before it allows more than one runner pod or a
rolling update, and the render fails when `agentRunner.env` or `agentRunner.extraEnv` sets either
variable. Set them with `agentRunner.providers.enabled` and `agentRunner.providers.default`.

Rules:

- Values are lowercase provider ids separated by commas. The known ids are `local`, `daytona` and
  `inprocess` (see [In-process](#in-process)).
- Unset enabled providers means exactly `local`.
- An explicitly empty list is invalid, and so is an empty entry inside the list.
- Unknown ids and duplicate ids are invalid.
- `inprocess` is enabled wherever `daytona` is enabled. You do not add it to the list. The runner
  adds it after the listed providers, so `daytona` stays the default. A list without `daytona`
  (for example `local`) does not enable `inprocess`. You cannot turn `inprocess` off while `daytona`
  is enabled. The web app does not offer `inprocess` as a choice: an agent chooses `daytona`, and
  the runner picks the provider by harness (see [In-process](#in-process)).
- The default must be one of the enabled providers.
- A run may select any enabled provider. A run that selects a known but disabled provider fails
  before any working directory, mount, secret, or sandbox is created. There is no fallback to
  another provider.

The enabled list applies to the whole deployment, not to a user or a run. It decides what isolation
a run can get; see
[Sandbox isolation and security](https://agenta.ai/docs/self-host/concepts/sandbox-isolation-and-security.md).

### Daytona

Read by the `runner` service. Required only when `daytona` is enabled.

| Variable | Role | Default | Secret | Helm |
|---|---|---|---|---|
| `AGENTA_RUNNER_DAYTONA_API_KEY` | Provisioning credential | Unset | yes | `agentRunner.providers.daytona.apiKeySecretRef` |
| `AGENTA_RUNNER_DAYTONA_API_URL` | Daytona API locator | Unset | no | `...daytona.apiUrl` |
| `AGENTA_RUNNER_DAYTONA_TARGET` | Region or target | Unset | no | `...daytona.target` |
| `AGENTA_RUNNER_DAYTONA_SNAPSHOT` | Snapshot to start from | Runner's pinned `agenta-agent-sandbox-v8` | no | `...daytona.snapshot` |
| `AGENTA_RUNNER_DAYTONA_IMAGE` | Image to start from | Unset | no | `...daytona.image` |
| `AGENTA_RUNNER_DAYTONA_AUTOSTOP_MINUTES` | Idle minutes before stop | `15` | no | `...daytona.autostopMinutes` |
| `AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES` | Idle minutes before delete | `30` | no | `...daytona.autodeleteMinutes` |
| `AGENTA_RUNNER_DAYTONA_OPAQUE_SECRETS` | Set to `off` to stop hiding API keys from the sandbox | Unset (hiding is on) | no | `...daytona.opaqueSecrets` |

When neither `AGENTA_RUNNER_DAYTONA_SNAPSHOT` nor `AGENTA_RUNNER_DAYTONA_IMAGE` is set, the runner
starts from its pinned default snapshot `agenta-agent-sandbox-v8`. The two variables are mutually
exclusive. The autostop and autodelete values must be positive integers. See
[Run agents in a cloud sandbox (Daytona)](https://agenta.ai/docs/self-host/agents/daytona.md) for the setup flow,
and [Customize the agent runtime](https://agenta.ai/docs/self-host/agents/customize-the-agent-runtime.md) for the
CPU, memory, and disk each sandbox gets.

#### Hiding API keys from the sandbox

A Daytona run hides its model and MCP API keys from the sandbox, and this is on by default. The
runner stores each key as a Daytona Secret restricted to the one hostname that key authenticates
against, and puts a placeholder in the sandbox instead. Daytona substitutes the real value into
outbound requests to that host, so the model call and the MCP call still work. Requests to any
other host carry only the placeholder.

This matters because an agent writes and runs its own code. Without it, a prompt injection that
persuades the agent to print its own environment prints your keys.

The credential a run uses to call the Agenta model gateway is hidden the same way, restricted to
the gateway's hostname. Two cases keep it a plain environment variable, as in earlier versions: a
gateway URL that cannot carry a single public hostname restriction (for example plain HTTP, an IP
address, a port other than the default, or an internal hostname such as `localhost` or one ending in
`.internal` or `.local`), and a Daytona API key without
the Secrets permission on a run that has no other key to hide. The runner logs the second case.

:::warning Upgrading from a version before v0.108.1 requires a key change
The permission this needs is new, and enabling it is not optional.

A Daytona API key is minted with a set of permissions, and a key that can create sandboxes does
**not** automatically have the separate permission to manage Secrets. If your key lacks it, every
Daytona run that carries a model or MCP key fails at sandbox creation as soon as you upgrade.

Grant the key in `AGENTA_RUNNER_DAYTONA_API_KEY` permission to manage Secrets, or reissue it with
that permission, before upgrading. The failure names this variable and the permission, so it is
recognizable, but the runs still fail until the key is fixed.

The runner never falls back to sending model or MCP keys as plaintext on its own, because silently doing the
unprotected thing is worse than stopping. If you would rather not grant the permission, set
`AGENTA_RUNNER_DAYTONA_OPAQUE_SECRETS=off` and keys go to the sandbox as plain environment
variables, exactly as they did before v0.108.1.
:::

**Turning it off.** Set `AGENTA_RUNNER_DAYTONA_OPAQUE_SECRETS=off`. The values `false`, `0`, `no`,
`disabled`, and `plaintext` work too. Anything the runner does not recognize leaves hiding on, so a
typo in this variable cannot silently remove the protection.

In Helm, quote the value. YAML reads a bare `off` as the boolean `false`, and the chart's
`values.schema.json` types `opaqueSecrets` as a string, so an unquoted value fails the install with
`agentRunner.providers.daytona.opaqueSecrets: Invalid type. Expected: string, given: boolean`.

```yaml
agentRunner:
  providers:
    daytona:
      opaqueSecrets: "off" # quote it: a bare off is a YAML boolean
```

**What `process_local` means.** Setting the variable to `process_local` is the same as leaving it
unset, and the name states the cleanup guarantee: the runner tracks the Secret records it created
in its own memory and deletes them when the sandbox goes away. Restart the runner while sandboxes
are live and those records are orphaned in your Daytona account until you remove them. A future
mode will add durable tracking, which is why the setting takes a mode name rather than a plain
`on`.

**What cannot be hidden.** Keys that a provider SDK signs with locally instead of sending, which
today means the AWS access keys used for Bedrock and the Google service account credentials used
for Vertex AI, still reach the sandbox in full. Nothing Daytona substitutes on the way out can help
there, because the secret never leaves the sandbox in the first place. Those runs work normally;
they just do not get this protection.

:::warning The bare `DAYTONA_*` variables configure a different sandbox
`DAYTONA_API_KEY`, `DAYTONA_API_URL`, `DAYTONA_TARGET`, `DAYTONA_SNAPSHOT`, and
`DAYTONA_SNAPSHOT_CODE` configure the code evaluator's sandbox, which runs custom evaluator code.
The agent runner reads only the `AGENTA_RUNNER_DAYTONA_*` names in the table above.

The two may point at the same Daytona account, so the key, the URL, and the target may hold the
same values. The snapshot may not: the evaluator's snapshot (for example `daytona-small`) has no
agent harness installed, so an agent booted into it cannot run.
:::

### In-process

Read by the `runner` service, and only when `inprocess` is enabled: when `daytona` or `inprocess` is
in `AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS`. With `inprocess`, the Pi harness runs inside the runner
process, and a Daytona sandbox, one per conversation, runs the agent's file tools and commands. The
sandbox starts on the first tool call. `inprocess` runs only the `pi_core` harness, and it needs
the durable store (see [Store](#store-durable-object-store)).

Enabling `inprocess` makes `AGENTA_RUNNER_DAYTONA_API_KEY` required. The command sandboxes use the
Daytona connection above (key, URL, target) and, unless you set a snapshot below, its snapshot or
image. A model provider key (for example `OPENAI_API_KEY`) or a cloud credential (for example
`AWS_ACCESS_KEY_ID`) in the runner's own environment is not allowed with `inprocess`, because every
in-process session would use it. What the runner does at start:

- Without `local` in the list, no enabled provider reads these variables from the runner
  environment. The runner removes them from its own environment and logs a warning that names
  them (never their values). `inprocess` stays on.
- With `local` in the list, the local harness processes inherit the runner environment, so the
  variables stay. If `inprocess` is only enabled through `daytona`, the runner starts without
  `inprocess` and logs a warning. If you listed `inprocess` or made it the default, the runner does
  not start.

Set `AGENTA_RUNNER_INPROCESS_ALLOW_ENV_KEYS=true` only on a deployment that must keep such a key.

`daytona` and `inprocess` are one choice, and the harness picks the provider. When both are enabled,
a Pi (`pi_core`) run in a session runs `inprocess`, and a Claude Code or Codex run runs on `daytona`.
This applies to an agent saved with either value; the saved agent does not change. A Pi run without
a session runs on `daytona`, because `inprocess` keeps its files on the session's drive. The runner
logs each routed run as `[sandbox-routing] harness=<harness> chosen=<saved> runs=<provider>`, and the
trace's workflow span records the provider that ran as `ag.meta.agent.sandbox`. Set
`AGENTA_RUNNER_INPROCESS_FOR_PI=false` to run each agent on the provider it names, for example on a
deployment without the durable store.

| Variable | Role | Default | Secret | Helm |
|---|---|---|---|---|
| `AGENTA_RUNNER_INPROCESS_SANDBOX_SNAPSHOT` | Snapshot for the command sandboxes | The `daytona` provider's snapshot or image | no | `agentRunner.env.AGENTA_RUNNER_INPROCESS_SANDBOX_SNAPSHOT` |
| `AGENTA_RUNNER_INPROCESS_SANDBOX_LABELS` | Labels added to every command sandbox, as `key=value,key=value` | Unset | no | `agentRunner.env.AGENTA_RUNNER_INPROCESS_SANDBOX_LABELS` |
| `AGENTA_RUNNER_INPROCESS_IDLE_STOP_MS` | Stop a command sandbox after this long without a tool call | `300000` (5 minutes) | no | `agentRunner.env.AGENTA_RUNNER_INPROCESS_IDLE_STOP_MS` |
| `AGENTA_RUNNER_INPROCESS_MAX_RUNNING_SANDBOXES` | Command sandboxes this runner keeps running at once | `40` | no | `agentRunner.env.AGENTA_RUNNER_INPROCESS_MAX_RUNNING_SANDBOXES` |
| `AGENTA_RUNNER_INPROCESS_MAX_SESSIONS` | In-process sessions this runner hosts at once | `200` | no | `agentRunner.env.AGENTA_RUNNER_INPROCESS_MAX_SESSIONS` |
| `AGENTA_RUNNER_INPROCESS_ALLOW_ENV_KEYS` | Start even when a model provider key is in the runner's environment | `false` | no | `agentRunner.env.AGENTA_RUNNER_INPROCESS_ALLOW_ENV_KEYS` |
| `AGENTA_RUNNER_INPROCESS_FOR_PI` | Run Pi `inprocess` and Claude Code and Codex on `daytona` for an agent that chose `daytona` or `inprocess`. `true` or `false` | `true` | no | `agentRunner.env.AGENTA_RUNNER_INPROCESS_FOR_PI` |

The command sandboxes take the `daytona` provider's `AGENTA_RUNNER_DAYTONA_AUTOSTOP_MINUTES` and
`AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES`. A command sandbox holds nothing durable (the session and
agent folders are in the store), so a sandbox left by a runner that stopped is removed by Daytona on
those intervals.

### Warm sessions and scale

A session stays warm between turns so a follow-up turn skips a cold start. Both providers pool
sessions, but they budget different things: the Daytona pool budgets billed compute, and the local
pool budgets host memory inside the runner container. All of these are read by the `runner` service,
and all are safe to leave unset.

Daytona, one warm sandbox per parked session:

| Variable | Role | Default | Secret | Helm |
|---|---|---|---|---|
| `AGENTA_RUNNER_DAYTONA_SESSION_IDLE_TTL_MS` | How long a sandbox stays running with its live session after a clean turn | `120000` (2 minutes) | no | `...daytona.sessionIdleTtlMs` |
| `AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM` | How many idle sandboxes may stay running between turns | `20` | no | `...daytona.sessionMaxWarm` |

Set `AGENTA_RUNNER_DAYTONA_SESSION_IDLE_TTL_MS` to `0` to stop a sandbox after each turn. There is
no separate enable flag. `AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM` bounds idle spend only; it never
blocks an active turn. Overflow sandboxes park in the stopped state.

:::warning[Keep the idle TTL below the autostop window]
`AGENTA_RUNNER_DAYTONA_SESSION_IDLE_TTL_MS` must stay below
`AGENTA_RUNNER_DAYTONA_AUTOSTOP_MINUTES`. Autostop is Daytona's own idle timer, and it does not
know about the runner's warm pool. If the TTL is the longer of the two, Daytona stops a sandbox the
runner still believes is warm: the next turn takes the cold path anyway, and you paid for the warm
window without getting it. The defaults (2 minutes against 15) satisfy this. Raise autostop first
whenever you raise the TTL.
:::

Local, one pooled harness process per parked session inside the runner container:

| Variable | Role | Default | Secret | Helm |
|---|---|---|---|---|
| `AGENTA_RUNNER_SESSION_POOL_MAX` | How many local sessions may stay pooled | `8` | no | `agentRunner.env.AGENTA_RUNNER_SESSION_POOL_MAX` |
| `AGENTA_RUNNER_SESSION_TTL_MS` | Idle lifetime of a pooled local session | `60000` (1 minute) | no | `agentRunner.env.AGENTA_RUNNER_SESSION_TTL_MS` |
| `AGENTA_RUNNER_SESSION_APPROVAL_TTL_MS` | Idle lifetime while a run waits for a human approval | `300000` (5 minutes) | no | `agentRunner.env.AGENTA_RUNNER_SESSION_APPROVAL_TTL_MS` |
| `AGENTA_RUNNER_SESSION_KEEPALIVE` | Whether local sessions are reused at all | Enabled | no | `agentRunner.env.AGENTA_RUNNER_SESSION_KEEPALIVE` |

Local keep-alive is on by default. Set `AGENTA_RUNNER_SESSION_KEEPALIVE=off` (`0`, `false`, and `no`
also work) to make every local turn take the cold path, which lowers the runner container's memory
ceiling and raises the latency of a follow-up turn. The approval TTL applies while a run waits on a
human approval, so it does not expire a session that is waiting on a person. These four apply to
the `local` provider only; Daytona ignores them and uses the two variables above.

A Daytona sandbox moves through three states:

| State | When | Billing |
|---|---|---|
| Running | While a turn executes, and during the warm window after a clean turn | Compute and disk |
| Stopped | After `AGENTA_RUNNER_DAYTONA_AUTOSTOP_MINUTES` idle minutes | Disk only; restart is cheap and the session reloads on the same instance |
| Deleted | After `AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES` idle minutes | None; the next turn creates a fresh sandbox and reloads the working directory from the store |

### Run limits

Four deadlines bound a single run. Whichever limit trips first aborts the run and releases its
sandbox, its mount, and its socket. All four are read by the `runner` service and apply to every
provider.

| Variable | Role | Default | Secret | Helm |
|---|---|---|---|---|
| `AGENTA_RUNNER_RUN_TOTAL_TIMEOUT_MS` | Hard deadline for one run, measured from the first message | `2700000` (45 minutes) | no | `agentRunner.env.AGENTA_RUNNER_RUN_TOTAL_TIMEOUT_MS` |
| `AGENTA_RUNNER_RUN_IDLE_TIMEOUT_MS` | Longest gap between two progress events before the run is abandoned | `1800000` (30 minutes) | no | `agentRunner.env.AGENTA_RUNNER_RUN_IDLE_TIMEOUT_MS` |
| `AGENTA_RUNNER_RUN_TTFB_TIMEOUT_MS` | Longest wait for the first response after the run starts | `480000` (8 minutes) | no | `agentRunner.env.AGENTA_RUNNER_RUN_TTFB_TIMEOUT_MS` |
| `AGENTA_RUNNER_TOOL_CALL_TIMEOUT_MS` | Longest a single tool call may take. Also the longest a shell command may run | `1800000` (30 minutes) | no | `agentRunner.env.AGENTA_RUNNER_TOOL_CALL_TIMEOUT_MS` |

Four rules govern how they interact:

- A run paused for a human approval is exempt from all four. The pause freezes every timer.
- The idle timeout must stay below the total deadline, or it could never fire first. A value at or
  above the total is clamped to half the total, and the runner logs the clamp rather than failing to
  start.
- The TTFB timer only covers the wait for the first response. The first progress event of any kind
  cancels it and arms the idle timer instead.
- A shell command that runs longer than `AGENTA_RUNNER_TOOL_CALL_TIMEOUT_MS` is stopped, and the
  agent receives a "command timed out" result and continues the turn. This applies to Pi on every
  provider. Claude Code gets the same limit as its command timeout; it stops the command or moves
  it to the background, and the turn continues. The run is aborted only when a tool call returns no result two minutes
  after the limit, for example a Codex command or a tool that did not stop. The idle timeout does
  not apply while a tool call runs.

`AGENTA_RUNNER_RUN_TTFB_RETRIES` sets how many times the runner runs a turn again when the model
sends nothing before the TTFB timeout. The default is `1` and the range is `0` to `3`. Set it to `0`
to turn the retry off. In Helm, set `agentRunner.env.AGENTA_RUNNER_RUN_TTFB_RETRIES`.

An invalid value (not a number, or negative) falls back to the default for that variable. These are
the runner's own deadlines and are unrelated to `AGENTA_RUNNER_TIMEOUT_SECONDS`, which is the
caller's idle timeout on the streaming transport.

### Harness startup

Before a run sends its first message, the runner opens a session with the harness. One deadline
bounds that step.

| Variable | Role | Default | Secret | Helm |
|---|---|---|---|---|
| `AGENTA_RUNNER_ACP_INIT_TIMEOUT_MS` | Longest wait for the harness to answer when a run opens its session | `120000` (2 minutes) | no | `agentRunner.env.AGENTA_RUNNER_ACP_INIT_TIMEOUT_MS` |

When the deadline passes, the run fails with the code `harness_init_timeout` and the message
`The <harness> harness did not start within 2 minutes`, and the runner releases its sandbox. This
deadline covers only the step before the first message. The run limits above cover everything
after it. An invalid value falls back to the default.

The runner image ships a pinned Codex adapter. At startup, the runner copies it into the data
directory that the harness daemon reads (`$XDG_DATA_HOME`, or `$HOME/.local/share`). A container
started with a different `HOME`, as in [Use your own subscription](https://agenta.ai/docs/self-host/agents/use-your-own-subscription.md),
then uses the pinned adapter and does not download one on its first Codex run. The runner logs one
line for what it did:

```text
[adapter-seed] seeded the pinned Codex adapter into the daemon data dir: /home/node/.local/share/sandbox-agent/bin/agent_processes -> /tmp/.local/share/sandbox-agent (950ms)
[adapter-seed] skipped: the daemon data dir is the baked pin (/home/node/.local/share/sandbox-agent)
```

The runner never overwrites an adapter that is already in the data directory.

### Callback API

Set both on the `runner` service. The runner calls the API back for session heartbeats,
conversation persistence, working-directory mount signing, and the trace-export fallback.

| Variable | Role | Default | Helm |
|---|---|---|---|
| `AGENTA_API_INTERNAL_URL` | Where the runner sends its callbacks | Compose: `http://api:8000` | Wired by the chart |
| `AGENTA_API_URL` | Which trace endpoints the runner recognizes as this deployment | Unset | Wired by the chart |

The two answer different questions, and setting one does not cover the other.

`AGENTA_API_INTERNAL_URL` is an address. Point it at the API as reached from inside the runner
container (its Compose or cluster service name, for example `http://api:8000`), not the public URL,
which does not resolve inside a container. If it is unset, the runner falls back to `AGENTA_API_URL`
and then to the base inferred from each request.

`AGENTA_API_URL` is an identity. Every run arrives carrying the trace endpoint the API built from
its own public base, for example `https://agenta.example.com/api/otlp/v1/traces`. The runner uses
that endpoint to decide whether the run's credential belongs to this platform or to a third-party
OTLP collector the caller aimed the run at, and it forwards the credential to platform calls only in
the first case. It cannot make that call from the internal address alone, because the internal hop
never appears in a dispatched run.

Set `AGENTA_API_URL` to the same public API base the `api` and `services` containers use. When it is
unset, the runner logs a warning at startup, treats every run's credential as belonging to this
platform, and logs a second warning naming the endpoint it could not attribute. Runs keep working;
credentials aimed at a third-party collector are no longer kept out of platform calls.

### Internal settings

The runner reads two more variables that exist for debugging and for custom sandbox images. They
are not part of the supported configuration surface and may change without notice. Leave them unset
on a normal deployment.

- `AGENTA_RUNNER_DEBUG_TOOLS`: when set to any value, the runner logs verbose tool-callback
  diagnostics to standard error. Unset by default.
- `AGENTA_AGENT_SANDBOX_PI_DIR`: where the Pi agent directory lives *inside* a Daytona sandbox,
  defaulting to `/home/sandbox/.pi/agent`. This describes the sandbox image's own layout, not the
  deployment. Change it only if you build a custom snapshot that puts Pi somewhere else.

### Startup validation

The runner fails to start when configuration is invalid, before it listens. The exact messages:

| Cause | Error |
|---|---|
| Token not set | `AGENTA_RUNNER_TOKEN is required. Generate a secret (e.g. \`openssl rand -hex 32\`) and set the SAME value on the runner and on the service that calls it.` |
| Enabled list is set but empty | `AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS is set but empty; unset it for the default 'local', or list at least one provider.` |
| Empty entry in the enabled list | `AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS has an empty entry in '<list>'.` |
| Unknown provider id in the enabled list | `AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS lists unknown provider '<id>'; known providers: local, daytona, inprocess.` |
| Duplicate provider id | `AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS lists provider '<id>' more than once.` |
| Default is an unknown provider | `AGENTA_RUNNER_DEFAULT_SANDBOX_PROVIDER is unknown provider '<id>'; known providers: local, daytona, inprocess.` |
| Default not in the enabled set | `AGENTA_RUNNER_DEFAULT_SANDBOX_PROVIDER '<id>' is not in the enabled set [<list>]. Add it to AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS or change the default.` |
| Daytona enabled without a key | `AGENTA_RUNNER_DAYTONA_API_KEY is required when 'daytona' is in AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS.` |
| `inprocess` enabled without a Daytona key | `AGENTA_RUNNER_DAYTONA_API_KEY is required when 'inprocess' is in AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS: its tool calls run in a Daytona sandbox.` |
| `inprocess` listed (or the default) together with `local`, and a model provider key in the runner environment | `The 'inprocess' provider is enabled but the runner environment holds credential variable(s) <names>; Pi would use them for every in-process session. Remove them, or set AGENTA_RUNNER_INPROCESS_ALLOW_ENV_KEYS=true.` |
| A label entry without `=` | `AGENTA_RUNNER_INPROCESS_SANDBOX_LABELS entry '<entry>' is not in the form key=value.` |
| `AGENTA_RUNNER_INPROCESS_FOR_PI` other than `true` or `false` | `AGENTA_RUNNER_INPROCESS_FOR_PI must be 'true' or 'false', got '<value>'.` |
| Snapshot and image both set | `AGENTA_RUNNER_DAYTONA_SNAPSHOT and AGENTA_RUNNER_DAYTONA_IMAGE are mutually exclusive; set only one.` |
| Non-integer positive value | `<variable> must be a positive integer, got '<value>'.` |
| Shutdown wait that is negative or not an integer | `AGENTA_RUNNER_SHUTDOWN_WAIT_SECONDS must be a non-negative integer, got '<value>'.` |

The last message covers `AGENTA_RUNNER_PORT`, `AGENTA_RUNNER_CONCURRENCY_LIMIT`,
`AGENTA_RUNNER_DAYTONA_AUTOSTOP_MINUTES`, `AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES`,
`AGENTA_RUNNER_INPROCESS_IDLE_STOP_MS`, `AGENTA_RUNNER_INPROCESS_MAX_RUNNING_SANDBOXES`, and
`AGENTA_RUNNER_INPROCESS_MAX_SESSIONS`. The `inprocess` checks run only when `inprocess` is enabled
(which includes every list with `daytona`).

On a valid start, the runner logs one redacted summary. No credential value or source path is
logged.

```text
runner providers enabled=[local,daytona,inprocess] default=local
runner daytona target=eu artifact=snapshot:agenta-agent-sandbox-v8
runner inprocess sandbox_start=on-first-tool-call artifact=snapshot:agenta-agent-sandbox-v8 max_running_sandboxes=40 max_sessions=200
```

The first line always prints and shows the effective list: `local,daytona` in the variable prints as
`local,daytona,inprocess`. The second line appears only when `daytona` is enabled. The third
line appears only when `inprocess` is enabled. `target`
reads `default` when `AGENTA_RUNNER_DAYTONA_TARGET` is unset, and `artifact` reads
`snapshot:agenta-agent-sandbox-v8` (the pinned default), `snapshot:<name>`, or `image:<name>`
depending on what is set.

### Troubleshooting

#### A run fails with `Sandbox provider '<id>' is not enabled on this deployment`

**Cause:** The run requested a provider that is not in `AGENTA_RUNNER_ENABLED_SANDBOX_PROVIDERS`.

**Solution:** Add the provider and recreate the runner, or change the run to use an enabled
provider. For `inprocess`, add `daytona`: `inprocess` is enabled with it. If the runner log shows
a warning that `inprocess` is off because of credential variables (a deployment that also enables
`local`), remove those variables from the runner environment.

#### A run fails with `could not find runner CLI at /app/runner/src/cli.ts`

**Cause:** `AGENTA_RUNNER_INTERNAL_URL` is unset on the Services API. With no runner URL, the SDK
falls back to spawning the runner as a subprocess from its own image, which does not ship the
runner source.

**Solution:** Set the locator on the `services` container and recreate it. On Compose:

```bash
AGENTA_RUNNER_INTERNAL_URL=http://runner:8765
```

The bundled Compose files already default to this value, and the Helm chart derives it from
`agentRunner.enabled`. A hand-written deployment has to set it. Check that the Services container
reaches the runner at that address:

```bash
docker compose exec services python -c \
  "import urllib.request; print(urllib.request.urlopen('http://runner:8765/health').status)"
```

A `200` confirms the hop.

#### Stop does nothing, and minutes later the run is closed as "stopped responding"

**Cause:** `AGENTA_RUNNER_INTERNAL_URL` is unset on the platform API. The api delivers a Stop to
the runner directly. Without the locator it logs
`cancel: no runner internal_url/token configured; command <id> cannot be delivered`, retries for a
few minutes, and then closes the healthy turn as lost. The chat shows "The agent stopped responding
and the run was closed", and the warm sandbox is gone. Before v0.115.3 the `gh.local` (oss and ee)
and `gh.ssl` Compose files set the locator on `services` only, so the `services` check above passes
while the api has no value.

**Solution:** Set the locator and the token on the `api` container and recreate it:

```bash
docker compose exec api printenv AGENTA_RUNNER_INTERNAL_URL   # empty means this entry
docker compose up -d --remove-orphans --force-recreate api
```

On a Compose file older than v0.115.3, add both lines to the `api` service's `environment` block,
the way the `services` block has them. On the next Stop the api log must not show the
`cannot be delivered` line.

#### The API cannot reach the runner, or the runner rejects its calls

**Cause:** `AGENTA_RUNNER_INTERNAL_URL` does not point at the runner, or `AGENTA_RUNNER_TOKEN` is
set on only one side.

**Solution:** Check the URL, and set the same token value on the api, on services, and on the
runner.

#### A self-managed local run fails because the harness has no login

**Cause:** The subscription mount is missing, or `PI_CODING_AGENT_DIR` / `CLAUDE_CONFIG_DIR` does
not point at it.

**Solution:** See [Use your own subscription](https://agenta.ai/docs/self-host/agents/use-your-own-subscription.md).

#### A run fails with `The <harness> harness did not start within 2 minutes`

**Cause:** The harness did not answer while the run was opening its session. If the runner cannot
copy its pinned Codex adapter at startup, the daemon installs an adapter at first use and can stop
there. The runner logs `[adapter-seed] WARNING` at startup when that is the case.

**Solution:** Read the `[adapter-seed]` line in the runner log and fix what it names. Run the turn
again. To allow a longer startup, raise `AGENTA_RUNNER_ACP_INIT_TIMEOUT_MS`.

#### A self-managed run that requested Daytona fails

**Cause:** Personal subscriptions are local-only.

**Solution:** Run Daytona with a model API key. See
[Sandbox isolation and security](https://agenta.ai/docs/self-host/concepts/sandbox-isolation-and-security.md).

#### The runner fails to start with a Daytona authentication error

**Cause:** `AGENTA_RUNNER_DAYTONA_API_KEY` is wrong, or it has no access to the target.

**Solution:** Check the key and `AGENTA_RUNNER_DAYTONA_TARGET`.

#### Working directories do not persist across turns on Daytona

**Cause:** The sandbox could not reach the store, so it mounted nothing. The runner logs a
mount-degradation warning.

**Solution:** Make the store publicly reachable. See
[Run agents in a cloud sandbox (Daytona)](https://agenta.ai/docs/self-host/agents/daytona.md).

## Store (durable object store)

Backs the durable working directory for sessions and agents. Files written by an agent run
survive sandbox teardown and reappear in the next turn. The store is disabled until `ACCESS_KEY`
and `SECRET_KEY` are set. Point these at any S3-compatible store: the bundled SeaweedFS, AWS S3,
or MinIO. `ENDPOINT_URL` is always explicit (SeaweedFS defaults it to `http://seaweedfs:8333`; a
remote store must set it).

The API holds the master credentials and never passes them to the runner. At run start it mints
short-lived, prefix-scoped credentials and only those reach the sandbox, which mounts the durable
prefix as its working directory. The STS mechanism depends on the backend (see the two-backend
note below): bundled SeaweedFS uses `AssumeRoleWithWebIdentity`; a remote S3 store uses
`GetFederationToken`.

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_STORE_ENDPOINT_URL` | `store.endpoint_url` | `store.endpointUrl` (auto-populated when `store.seaweedfs.enabled=true`) |
| `AGENTA_STORE_STS_ENDPOINT_URL` | `store.sts_endpoint_url` | `store.stsEndpointUrl` |
| `AGENTA_STORE_ACCESS_KEY` | `store.access_key` | `store.accessKey` |
| `AGENTA_STORE_SECRET_KEY` | `store.secret_key` | `store.secretKey` |
| `AGENTA_STORE_REGION` | `store.region` | `store.region` |
| `AGENTA_STORE_BUCKET` | `store.bucket` | `store.bucket` |
| `AGENTA_STORE_NAMESPACE` | `store.namespace` | `store.namespace` |
| `AGENTA_STORE_SIGNING_KEY` | `store.signing_key` | `store.signingKey` |
| `AGENTA_STORE_JWT_ISSUER` | `store.jwt_issuer` | `store.jwtIssuer` |
| `AGENTA_STORE_JWT_PRIVATE_KEY` | `store.jwt_private_key` | `store.jwtPrivateKey` |
| n/a | n/a | `store.seaweedfs.enabled` |

`AGENTA_MOUNTS_MAX_UPLOAD_BYTES` (env.py path `mounts.max_upload_bytes`, read by the `api` service)
caps one file upload or write to the drive. The default is `104857600` (100 MB). The API answers a
larger request with `413`. When the request declares its size in `Content-Length`, the API
answers before it reads the body. Otherwise it stops reading as soon as the body passes the cap. The chart has no dedicated values key for it;
set it through `api.env.AGENTA_MOUNTS_MAX_UPLOAD_BYTES`.

`store.seaweedfs.enabled=true` bundles a SeaweedFS StatefulSet and auto-populates
`store.endpointUrl`. Set it to `false` and supply `store.endpointUrl` to use an external
S3-compatible store. This toggle mirrors `postgresql.enabled`.

:::note `AGENTA_STORE_NAMESPACE`: sharing one bucket across environments
The key layout treats the store as a small database: the **bucket** is the cluster, an optional
**namespace** is the database, and the **row** is the mount's stored prefix:
`mounts/<organization_id>/<mount_id>` for mounts created by version 0.125.0 or later,
`mounts/<project_id>/<mount_id>` for mounts created by earlier versions. Each mount records its
prefix when it is created, so a full key is `<bucket>/[<namespace>/]<stored prefix>/...`.

Leave `NAMESPACE` unset for a dedicated bucket; the key layout is then identical to a single-tenant
store (no empty leading segment). Set it (typically to a deployment or environment id) when
several **ephemeral environments share one bucket**. Each environment's keys are prefixed with its
namespace, and the short-lived credentials the API signs are scoped to that namespace, so one
environment can never read or write another's objects even though they live in the same bucket.
The namespace narrows the credential scope; it never widens it, and it is orthogonal to the store
backend (it works on remote S3 and on bundled SeaweedFS alike).
:::

:::note Two STS backends (selected by `SIGNING_KEY` presence)
The API narrows the master credentials to one mount prefix per run with an inline session policy.
How it signs that scoped credential depends on the backend, and the backend is chosen by whether
`AGENTA_STORE_SIGNING_KEY` is set, not by the endpoint:

- **`SIGNING_KEY` set → bundled SeaweedFS.** SeaweedFS authorizes scoped credentials only through
  its OIDC IAM engine: the API acts as the OIDC issuer, mints a short-lived RS256 *web-identity*
  token, and serves the matching public JWKS at `/.well-known/jwks.json`; SeaweedFS fetches that
  JWKS to verify the token on each `AssumeRoleWithWebIdentity` call.
- **`SIGNING_KEY` unset → remote S3-compatible store (AWS S3, MinIO).** The API already holds S3
  credentials, so it signs a `GetFederationToken` request (SigV4) with them. No OIDC provider, no
  role. Cloudflare R2 is **not** supported: it does not implement AWS STS `GetFederationToken`.

`AGENTA_STORE_STS_ENDPOINT_URL` is the STS endpoint for the remote-S3 path. It defaults to the S3
endpoint (MinIO co-locates STS there); set it only when the store splits STS onto another host.
For AWS: `https://sts.<region>.amazonaws.com`. It is ignored on the SeaweedFS path.

The SeaweedFS-only settings (`SIGNING_KEY`, `JWT_ISSUER`, `JWT_PRIVATE_KEY`):

- `AGENTA_STORE_SIGNING_KEY`: base64 of exactly 32 bytes; the HMAC key SeaweedFS signs its own STS
  session tokens with (`head -c 32 /dev/urandom | base64`). Its presence also selects the SeaweedFS
  backend, so leave it unset for a remote S3 store.
- `AGENTA_STORE_JWT_ISSUER`: the in-network API URL SeaweedFS fetches the JWKS from (e.g.
  `http://api:8000`).
- `AGENTA_STORE_JWT_PRIVATE_KEY`: a stable RSA private key (PKCS#8 PEM) the API signs the
  web-identity token with. **Required in production:** every API replica must share one key, or
  SeaweedFS's cached JWKS desyncs and token validation fails intermittently. Generate with
  `openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048`. Local dev falls back to a
  built-in key when unset.

The bundled store and the API must agree on `ACCESS_KEY` and `SECRET_KEY`; in the Helm chart and
docker-compose this is wired automatically.
:::

:::warning Remote sandboxes (Daytona) need a reachable store endpoint
A local sandbox mounts durable storage on the runner host against the in-network store. A
**remote** sandbox mounts from inside the cloud sandbox, so the store endpoint must be publicly
reachable. Enable the `ngrok` tunnel (the compose `with-tunnel` profile) or point
`AGENTA_STORE_ENDPOINT_URL` at a public S3 URL. Only the scoped, short-lived credentials ever
cross into a remote sandbox.
:::

## Agenta attachments

Bounds the files a user can attach to an agent chat turn. The API enforces the per-file sizes
and the per-session quotas when a file is uploaded, and deletes expired attachments in a
background sweep. The runner enforces how many attachments one turn carries. Attachment bytes
live in the [store](#store-durable-object-store), so uploads fail while the store is
unconfigured.

The chart has no dedicated values keys for these. Set them through the per-deployment env map:
`api.env.<NAME>` for the API variables, `agentRunner.env.<NAME>` for the runner ones.

Read by the `api` service:

| Env var | env.py path | What it bounds | Default |
|---|---|---|---|
| `AGENTA_ATTACHMENTS_MAX_IMAGE_BYTES` | `agenta.sessions.attachments.max_image_bytes` | Size of one image | `10485760` (10 MB) |
| `AGENTA_ATTACHMENTS_MAX_AUDIO_BYTES` | `agenta.sessions.attachments.max_audio_bytes` | Size of one audio file | `15728640` (15 MB) |
| `AGENTA_ATTACHMENTS_MAX_DOCUMENT_BYTES` | `agenta.sessions.attachments.max_document_bytes` | Size of one document | `10485760` (10 MB) |
| `AGENTA_ATTACHMENTS_MAX_OTHER_BYTES` | `agenta.sessions.attachments.max_other_bytes` | Size of one file of any other kind | `10485760` (10 MB) |
| `AGENTA_ATTACHMENTS_MAX_PER_SESSION_COUNT` | `agenta.sessions.attachments.max_per_session_count` | Stored attachments one session may hold | `1000` |
| `AGENTA_ATTACHMENTS_MAX_PER_SESSION_BYTES` | `agenta.sessions.attachments.max_per_session_bytes` | Total stored bytes across one session | `268435456` (256 MB) |
| `AGENTA_ATTACHMENTS_MAX_PENDING_PER_SESSION` | `agenta.sessions.attachments.max_pending_per_session` | Uploads in flight for one session at once | `20` |
| `AGENTA_ATTACHMENTS_PENDING_TTL_SECONDS` | `agenta.sessions.attachments.pending_ttl_seconds` | How long an unfinished upload is held before the sweep reclaims it | `900` (15 minutes) |
| `AGENTA_ATTACHMENTS_UNREFERENCED_TTL_SECONDS` | `agenta.sessions.attachments.unreferenced_ttl_seconds` | How long an uploaded attachment that no message references is kept | `86400` (24 hours) |
| `AGENTA_ATTACHMENTS_SWEEP_INTERVAL_SECONDS` | `agenta.sessions.attachments.sweep_interval_seconds` | Gap between two attachment sweeps | `3600` (1 hour) |

The kind of a file (image, audio, document, other) comes from its media type, and an upload
over its kind's cap is rejected before anything is stored. The count and byte quotas apply to
stored attachments and are checked as each upload is claimed. The sweep runs inside the API
process, and a lock lets one replica sweep at a time.

Read by the `runner` service:

| Env var | env.py path | What it bounds | Default |
|---|---|---|---|
| `AGENTA_ATTACHMENTS_MAX_PER_TURN` | n/a (read by the runner) | Attachments one user turn may carry | `100` |
| `AGENTA_ATTACHMENTS_FETCH_TIMEOUT_MS` | n/a (read by the runner) | Wait for one attachment's bytes to download | `15000` (15 seconds) |

A turn that carries more than `AGENTA_ATTACHMENTS_MAX_PER_TURN` attachments fails before the
run starts. The runner also refuses any single attachment body over 16 MB. That ceiling is
fixed in code, so raising a per-file cap above it stores files the runner cannot fetch.

## Agenta sessions

Bounds what an agent can do with the session tools: starting child sessions, sending messages
to other sessions, and turns that no person sent. An agent can send a message to its child
sessions and to any other session of the project that its person could run. A child session is a session that another session
started with `start_session`. The session that a person started is level 0, its child is
level 1, and the child of that child is level 2.

The chart has no dedicated values keys for these. Set them through `api.env.<NAME>`.

Read by the `api` service:

| Env var | env.py path | What it bounds | Default |
|---|---|---|---|
| `AGENTA_SESSIONS_TURNS_WITHOUT_PERSON_LIMIT` | `agenta.sessions.turns_without_person_limit` | Turns in a row in one session that no person sent. At this count, a new message that no person sent waits in the queue and runs after the next turn that a person sends. | `20` |
| `AGENTA_SESSIONS_CHILD_SESSIONS_LIMIT` | `agenta.sessions.child_sessions_limit` | Running child sessions of one session. At this count, `start_session` is refused, and so is a send that would start a turn in an idle session. | `5` |
| `AGENTA_SESSIONS_CHILD_SESSION_DEPTH_LIMIT` | `agenta.sessions.child_session_depth_limit` | Deepest level of a child session. `start_session` is refused when the new child would be deeper. | `3` |
| `AGENTA_SESSIONS_CHILD_QUEUED_MESSAGES_LIMIT` | `agenta.sessions.child_queued_messages_limit` | Queued messages from one session in another session. A send that would queue one more is refused. | `3` |
| `AGENTA_SESSIONS_STILL_RUNNING_UPDATE_MINUTES` | `agenta.sessions.still_running_update_minutes` | Minutes after a start or a send before the calling session gets a "still running" update, when the agent gives no `update_after_minutes`. Values above `360` are treated as `360`. | `30` |

Each value must be a whole number greater than `0`. The API does not start with `0` or a
negative value.

## Agenta triggers

The chart has no dedicated values key for this. Set it through `api.env.<NAME>`.

Read by the `api` service:

| Env var | env.py path | What it bounds | Default |
|---|---|---|---|
| `AGENTA_TRIGGERS_ONE_TIME_SCHEDULES_MAX_PER_TICK` | `triggers.one_time_schedules_max_per_tick` | One-time schedules that one schedule tick fires, over all projects. The earliest are fired first; the rest fire in the next tick. | `2000` |

The value must be a whole number greater than `0`. The API does not start with `0` or a
negative value.

## Agenta egress

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_INSECURE_EGRESS_ALLOWED` | `agenta.webhooks.allow_insecure` (API); read directly by the SDK for workflow hooks and custom model provider endpoints | `agenta.insecureEgressAllowed` |

:::note SSRF protection
`AGENTA_INSECURE_EGRESS_ALLOWED` defaults to `true`, so outbound requests that Agenta
itself makes to a tenant-configured endpoint (webhooks, workflow hooks, custom model
provider URLs) are allowed even when they resolve to a private, loopback, or otherwise
reserved IP address. The deployment logs a warning while this default is active.

If you're running a shared or multi-tenant deployment, set it to `false`. Agenta then
blocks any such request that resolves to a private, loopback, or reserved IP address,
regardless of who configured the URL. Public URLs are never affected either way.

Every deployment configuration in this repo that produces a reachable, sign-ups-open
instance — the docker-compose `.gh` env files and the Kubernetes `values.*.example.yaml`
overlays — sets this to `false` already. Only the local dev docker-compose files
(`.env.oss.dev`, `.env.ee.dev`, single developer, not exposed) keep the permissive
default.

The old per-surface names (`AGENTA_WEBHOOKS_ALLOW_INSECURE`, `AGENTA_WEBHOOK_ALLOW_INSECURE`,
`AGENTA_SERVICES_HOOK_ALLOW_INSECURE`, `AGENTA_CUSTOM_PROVIDER_ALLOW_INSECURE`) are
deprecated aliases and still work, but new configuration should use the canonical name.
:::

:::note This variable does not gate saving an MCP server URL
Saving a custom MCP server URL is checked under `AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED`
and `AGENTA_MCP_GATEWAY_HOST_ALLOWLIST` below, which are also what the relay enforces when
it calls the server. In 0.119.0 only, that save-time check read
`AGENTA_INSECURE_EGRESS_ALLOWED` instead. See
[Use an MCP server on a private network or over plain HTTP](https://agenta.ai/docs/self-host/agents/tools-and-triggers.md#use-an-mcp-server-on-a-private-network-or-over-plain-http).
:::

## Agenta gateways

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_LLM_GATEWAY_ENABLED` | `llm_gateway.enabled` (api) | `llmGateway.enabled` |
| `AGENTA_MCP_GATEWAY_ENABLED` | `mcp_gateway.enabled` (api; the web container reads the same name) | `mcpGateway.enabled` |
| `AGENTA_MCP_GATEWAY_HOST_ALLOWLIST` | `mcp_gateway.host_allowlist` (api) | `mcpGateway.hostAllowlist` |
| `AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED` | `gateway_egress.insecure_allowed` (api) | `gatewayEgress.insecureAllowed` |
| `AGENTA_GATEWAYS_CREDENTIALS_TTL_SECONDS` | `gateway_credentials.ttl_seconds` (api) | `gatewayCredentials.ttlSeconds` |
| `AGENTA_LLM_GATEWAY_VERTEX_SA_JSON_B64` | `llm_gateway.vertex_sa_json_b64` (api) | not rendered by the chart |
| `AGENTA_LLM_GATEWAY_VERTEX_PROJECT` | `llm_gateway.vertex_project` (api) | not rendered by the chart |

One of these ships a value in the Docker Compose env templates and in the Helm example values
files that differs from the default the code applies when the variable is absent.

| Env var | Code default | `env.oss.dev.example` / `env.ee.dev.example` | `env.oss.gh.example` / `env.ee.gh.example` | Helm `values.yaml` |
|---|---|---|---|---|
| `AGENTA_MCP_GATEWAY_ENABLED` | `true` | `true` | `true` | `true` |
| `AGENTA_LLM_GATEWAY_ENABLED` | `true` | `true` | `true` | `true` |
| `AGENTA_MCP_GATEWAY_HOST_ALLOWLIST` | empty | commented out | commented out | empty |
| `AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED` | `false` | `true` | `true` | unset |
| `AGENTA_GATEWAYS_CREDENTIALS_TTL_SECONDS` | `43200` | unset | unset | unset |

The Compose templates open the egress guard, so a custom model provider or an MCP server on a
private network works. The Helm chart leaves it unset, so the code default applies and the
gateway refuses private addresses and plain HTTP. The example values files in
`hosting/kubernetes/oss` and `hosting/kubernetes/ee` set it to `true`.

To use a custom provider on a private address with Helm, such as Ollama at
`http://10.0.0.7:11434`, add this to your values file:

```yaml
gatewayEgress:
  insecureAllowed: true
```

With the guard open, any user who can create a custom provider or an MCP connection can make
the API call an address inside your network and read the answer. On a deployment where people
you do not trust can create these connections, keep the guard on. Set
`AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED=false` in the env file, or leave
`gatewayEgress.insecureAllowed` unset in your Helm values, and name the servers you want
reachable in `AGENTA_MCP_GATEWAY_HOST_ALLOWLIST` (`mcpGateway.hostAllowlist`).

:::note Kubernetes / Helm
The chart renders every gateway value in this table into the containers that read it. A key you
leave unset renders no environment variable at all, so the application's own default applies.
:::

:::note Which gateways your deployment serves
Agenta has two gateways, and each has its own switch.

The **MCP gateway** lets an agent reach an MCP server through Agenta, so the server's
credential stays on your deployment instead of travelling into the sandbox. It is on by
default. `AGENTA_MCP_GATEWAY_ENABLED=false` turns it off: the API refuses every MCP gateway
route, the MCP settings tab disappears, and an agent dials its declared MCP servers directly,
the way it did before the gateway existed.

The **LLM gateway** does the same for model calls, keeping your provider key out of the
sandbox. It is on by default. `AGENTA_LLM_GATEWAY_ENABLED=false` turns it off: a model call
then resolves the project's stored provider key and injects it into the run. An env file that
already says `false` keeps the gateway off until you change that line to `true` or remove it.

Both are read by the API, which is the authority. The agent SDK carries no switch of its own:
it asks the API and takes the older path when the API says that gateway is not serving. The
web container reads `AGENTA_MCP_GATEWAY_ENABLED` from the same env file to decide whether to
show the MCP settings tab, so set these in the file every container loads and recreate them.
:::

:::note Models your deployment pays for
The LLM gateway can serve models from a Google Cloud Vertex AI account that your deployment
owns, instead of from a key in the project's vault. An agent then picks them from the
**Built-in: agenta** group in the model picker, and the call is made with your account's
credential. Today these are Gemini 3.7 Flash, Gemini 3.8 Flash, Gemini 4 Hydrogen, Gemini 4 Argon,
Gemini 4 Carbon, and Gemini 4 Neon.

To turn this on, set both of these on the API container:

- `AGENTA_LLM_GATEWAY_VERTEX_SA_JSON_B64`: the service account's JSON key, base64-encoded
  (`base64 -w0 key.json`). The service account needs the Vertex AI User role on the project.
- `AGENTA_LLM_GATEWAY_VERTEX_PROJECT`: the Google Cloud project id.

The models are called on the Vertex AI `global` location, where all three are available. If
either variable is not set, the models are not offered. The LLM gateway must also be on
(`AGENTA_LLM_GATEWAY_ENABLED=true`).

Only function tools are available on these models. A request that asks for a provider-side
tool, such as Google Search grounding (`web_search_options`), is refused with
`capability_not_allowed`, because the provider bills it apart from the tokens.

In Agenta Cloud with the wallet on, each call is charged to the organization's credits.
:::

:::note Custom workflow and evaluator URLs
A workflow or evaluator whose URL is under `AGENTA_SERVICES_URL` runs on your deployment's own
services and is called directly. Any other URL, such as a custom workflow you host yourself,
is called through the same outbound guard as the MCP relay. `AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED`
and `AGENTA_MCP_GATEWAY_HOST_ALLOWLIST` decide which of those URLs Agenta may call. The call
does not follow redirects, and the credential sent with it cannot read write-only secret
values.

If a custom workflow is on a private network or answers over plain HTTP, set
`AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED=true`, or put its hostname in
`AGENTA_MCP_GATEWAY_HOST_ALLOWLIST`. Otherwise the call fails with
`Workflow service URL was refused: blocked target: ...`. The Docker Compose templates and the
Helm example values files already set `AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED=true`; a Helm
install that does not start from them must set `gatewayEgress.insecureAllowed` or
`mcpGateway.hostAllowlist` itself.

A revision keeps the URL it was saved with. If you changed `AGENTA_SERVICES_URL` after you
created workflows, their saved URLs still point at the old address, and Agenta treats that
address as a custom URL. Allow the old host as described above, or change the URL on
those revisions to the current services URL. In Docker bridge networking,
the API calls `localhost` as `host.docker.internal`, so put `host.docker.internal` in
`AGENTA_MCP_GATEWAY_HOST_ALLOWLIST` for an old `localhost` URL.

The call does not follow redirects. Set the URL to the address that answers directly.
:::

:::note How long a run may keep reaching a gateway
When a run starts, Agenta issues it a credential that works only on the gateway routes, and
hands that credential to the sandbox the agent runs in. The credential is issued once, at the
start of the run. Nothing replaces it while the run is going, so its lifetime is also the
longest a single turn can keep using an MCP server or a model through a gateway.

`AGENTA_GATEWAYS_CREDENTIALS_TTL_SECONDS` sets that lifetime in seconds. The default is
`43200` (12 hours), chosen to sit above the longest run Agenta will let finish, so a turn
never loses its gateway access partway through. Lower it if you want a shorter-lived
credential, and keep it above the longest turn you expect: a turn still running when the
credential expires starts failing its gateway calls.
:::

:::note Which MCP servers the relay may call
The MCP gateway relays every MCP call an agent makes, so the relay's own outbound guard
decides which MCP servers an agent can reach. That guard requires `https` and refuses an
address that resolves into a private, loopback, link-local, reserved, multicast or RFC 6598
range. `AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED=true` turns both checks off.

The code default is `false`. All four Docker Compose env templates ship `true`, because a
self-hosted MCP server usually sits on the same network as the deployment or answers over
plain HTTP. With the guard on, such a server fails at run time with one of:

```text
blocked target: Upstream URL must use https.
blocked target: Upstream URL resolves to a blocked IP range.
```

`AGENTA_MCP_GATEWAY_HOST_ALLOWLIST` is the narrower alternative. It takes a comma-separated
list of hostnames, with no scheme and no port, and every hostname on it skips the guard while
the guard stays on for everything else:

```bash
AGENTA_MCP_GATEWAY_HOST_ALLOWLIST=mcp.internal,10.0.0.5
```

Leave `AGENTA_GATEWAYS_INSECURE_EGRESS_ALLOWED` at `false` on a deployment where people you
do not trust can create MCP connections. Open egress lets any project aim an MCP connection
at an address inside the network the api container sits on.

This setting and the allowlist also govern what the API accepts when someone saves an MCP
server URL, so a URL that saves is one the relay is willing to call. The save-time check
resolves no hostnames, so it refuses a literal private IP address but defers a hostname to
the call-time check. See
[Use an MCP server on a private network or over plain HTTP](https://agenta.ai/docs/self-host/agents/tools-and-triggers.md#use-an-mcp-server-on-a-private-network-or-over-plain-http).
:::

:::note Reaching the gateway over plain HTTP
An agent that reaches a model through the LLM gateway authenticates to that gateway with a
bearer credential. Agenta sends one over HTTPS, over plain HTTP to a loopback address, or over
plain HTTP to the deployment's own API address, `AGENTA_API_URL`. A deployment reached at an
address such as `http://192.0.2.10:8680/api` or `http://agenta.internal/api` needs no setting.

Plain HTTP to any other host is refused, and the run fails with the error code
`gateway_insecure_endpoint`. Serve the deployment over HTTPS.

A provider's own API key is never sent over plain HTTP to a non-loopback host. A Daytona
sandbox dials your deployment across the internet, so it needs an address it can reach.
:::

## Channels

Channels connect an agent to Slack, Telegram, WhatsApp, or a chat widget embedded in a website. They need no environment variable: users can connect their own Slack app or Telegram bot. The variables below are optional and turn on the hosted integrations, where one app or bot owned by the deployment serves every project. Each hosted integration stays off until all three of its variables are set.

Set them on the `api`, `worker-queues` and `worker-streams` containers. The Helm chart has no keys for them; add them with `api.extraEnv`, `workerQueues.extraEnv` and `workerStreams.extraEnv`.

| Env var                          | env.py path                        | values.yaml path |
| -------------------------------- | ---------------------------------- | ---------------- |
| `SLACK_CLIENT_ID`                | `channels.slack.client_id`         | _(not mapped)_   |
| `SLACK_CLIENT_SECRET`            | `channels.slack.client_secret`     | _(not mapped)_   |
| `SLACK_SIGNING_SECRET`           | `channels.slack.signing_secret`    | _(not mapped)_   |
| `TELEGRAM_HOSTED_BOT_TOKEN`      | `channels.telegram.bot_token`      | _(not mapped)_   |
| `TELEGRAM_HOSTED_BOT_USERNAME`   | `channels.telegram.bot_username`   | _(not mapped)_   |
| `TELEGRAM_HOSTED_WEBHOOK_SECRET` | `channels.telegram.webhook_secret` | _(not mapped)_   |

For the Telegram setup, see [Set up the hosted Telegram bot](https://agenta.ai/docs/self-host/channels/telegram-hosted-bot.md).

WhatsApp has no hosted integration. Each connection brings its own Meta app, so WhatsApp needs no variable. One optional variable changes where the WhatsApp channel sends its Meta Graph API calls:

| Env var                  | env.py path                       | values.yaml path | Default                            |
| ------------------------ | --------------------------------- | ---------------- | ---------------------------------- |
| `WHATSAPP_GRAPH_API_URL` | `channels.whatsapp.graph_api_url` | _(not mapped)_   | `https://graph.facebook.com/v24.0` |

Change it only to route the calls through a proxy or to a test double. For the setup, see [Connect a WhatsApp number to an agent](https://agenta.ai/docs/guides/connect-whatsapp.md).

The embedded chat widget needs no variable to work. The optional variables below change its limits. Its routes need no Agenta login, so they limit their own request rate per embed and per visitor key. Set them on the `api` container. For the rest of the widget setup, see [Embed the chat widget](https://agenta.ai/docs/self-host/channels/embed-widget.md).

| Env var                                                    | env.py path                                               | values.yaml path | Default            |
| ---------------------------------------------------------- | --------------------------------------------------------- | ---------------- | ------------------ |
| `AGENTA_CHANNELS_EMBED_REQUESTS_PER_MINUTE_PER_EMBED`      | `channels.embed.requests_per_minute_per_embed`            | _(not mapped)_   | `600`              |
| `AGENTA_CHANNELS_EMBED_REQUESTS_PER_MINUTE_PER_KEY`        | `channels.embed.requests_per_minute_per_key`              | _(not mapped)_   | `30`               |
| `AGENTA_CHANNELS_EMBED_READ_REQUESTS_PER_MINUTE_PER_EMBED` | `channels.embed.read_requests_per_minute_per_embed`       | _(not mapped)_   | `6000`             |
| `AGENTA_CHANNELS_EMBED_READ_REQUESTS_PER_MINUTE_PER_KEY`   | `channels.embed.read_requests_per_minute_per_key`         | _(not mapped)_   | `240`              |
| `AGENTA_CHANNELS_EMBED_MAX_LIVE_STREAMS_PER_EMBED`         | `channels.embed.max_live_streams_per_embed`               | _(not mapped)_   | `200`              |
| `AGENTA_CHANNELS_EMBED_MAX_MESSAGE_CHARS`                  | `channels.embed.max_message_chars`                        | _(not mapped)_   | `10000`            |
| `AGENTA_CHANNELS_EMBED_MAX_FILE_BYTES`                     | `channels.embed.max_file_bytes`                           | _(not mapped)_   | `5242880` (5 MB)   |

- The `REQUESTS` limits count posts to the embed's events route: messages, approval answers and commands. The `READ_REQUESTS` limits count the routes that list conversations, read one, follow its live stream and download a file.
- `MAX_LIVE_STREAMS_PER_EMBED` caps the live streams that one `api` process keeps open for one embed. Each open conversation in a widget holds one stream. Over the cap the widget gets a 429 and tries again.
- `MAX_MESSAGE_CHARS` applies to the message text and, separately, to the page context serialized as JSON.
- `MAX_FILE_BYTES` applies to all the files of one message together. One message carries at most 10 files.
- `MAX_FILE_BYTES` also applies when the `worker-queues` container stores each uploaded file. Set it to the same value on `api` and `worker-queues`.

:::warning One replica for channel replies
The `sessions` loop of `worker-streams` sends channel replies. Run it in exactly one replica. With two or more, a progress update can overwrite a final reply, and a Telegram reply can arrive twice. With the default `AGENTA_WORKER_STREAMS` (empty, which runs every loop), that means one `worker-streams` replica. On Helm, a rolling update briefly runs two pods; set `workerStreams.strategy.type: Recreate` to avoid the overlap.
:::

## alembic

| Env var | env.py path | values.yaml path |
|---|---|---|
| `ALEMBIC_AUTO_MIGRATIONS` | `alembic.auto_migrations` | `alembic.autoMigrations` |
| `ALEMBIC_CFG_PATH_CORE` | `alembic.cfg_path_core` | n/a |
| `ALEMBIC_CFG_PATH_TRACING` | `alembic.cfg_path_tracing` | n/a |

The migration job picks its migration chains itself and does not read `ALEMBIC_CFG_PATH_CORE` or
`ALEMBIC_CFG_PATH_TRACING`.

## cloudflare

| Env var | env.py path | values.yaml path |
|---|---|---|
| `CLOUDFLARE_TURNSTILE_ALLOWED_HOSTNAMES` | `cloudflare.turnstile.allowed_hostnames` | `cloudflare.turnstile.allowedHostnames` |
| `CLOUDFLARE_TURNSTILE_SECRET_KEY` | `cloudflare.turnstile.secret_key` | `cloudflare.turnstile.secretKey` |
| `CLOUDFLARE_TURNSTILE_SITE_KEY` | `cloudflare.turnstile.site_key` | `cloudflare.turnstile.siteKey` |

## composio

| Env var | env.py path | values.yaml path |
|---|---|---|
| `COMPOSIO_API_KEY` | `composio.api_key` | `composio.apiKey` |
| `COMPOSIO_API_URL` | `composio.api_url` | `composio.apiUrl` |

## crisp

| Env var | env.py path | values.yaml path |
|---|---|---|
| `CRISP_WEBSITE_ID` | `crisp.website_id` | `crisp.websiteId` |

## daytona (code evaluator)

These configure the custom-code evaluator sandbox. The agent runner reads its own
`AGENTA_RUNNER_DAYTONA_*` names instead; see [Agent runner](#agent-runner).

| Env var | env.py path | values.yaml path |
|---|---|---|
| `DAYTONA_API_KEY` | `daytona.api_key` | `daytona.apiKey` |
| `DAYTONA_API_URL` | `daytona.api_url` | `daytona.apiUrl` |
| `DAYTONA_SNAPSHOT` | `daytona.snapshot` | `daytona.snapshot` |
| `DAYTONA_SNAPSHOT_CODE` | `daytona.snapshot` (takes precedence) | n/a |
| `DAYTONA_TARGET` | `daytona.target` | `daytona.target` |

`DAYTONA_SNAPSHOT` sets the snapshot for the custom-code evaluator sandbox. Set
`DAYTONA_SNAPSHOT_CODE` to override it for the evaluator specifically. The agent runner uses its
own `AGENTA_RUNNER_DAYTONA_SNAPSHOT`; see the [runner Daytona section](#daytona).

## docker

| Env var | env.py path | values.yaml path |
|---|---|---|
| `DOCKER_NETWORK_MODE` | `docker.network_mode` | `docker.networkMode` |

## identity (OIDC providers)

| Env var | env.py path | values.yaml path |
|---|---|---|
| `APPLE_OAUTH_CLIENT_ID` | `identity.apple.client_id` | `identity.apple.clientId` |
| `APPLE_OAUTH_CLIENT_SECRET` | `identity.apple.client_secret` | `identity.apple.clientSecret` |
| `APPLE_KEY_ID` | `identity.apple.key_id` | `identity.apple.keyId` |
| `APPLE_PRIVATE_KEY` | `identity.apple.private_key` | `identity.apple.privateKey` |
| `APPLE_TEAM_ID` | `identity.apple.team_id` | `identity.apple.teamId` |
| `AZURE_AD_OAUTH_CLIENT_ID` | `identity.azure_ad.client_id` | `identity.azureAd.clientId` |
| `AZURE_AD_OAUTH_CLIENT_SECRET` | `identity.azure_ad.client_secret` | `identity.azureAd.clientSecret` |
| `AZURE_AD_DIRECTORY_ID` | `identity.azure_ad.directory_id` | `identity.azureAd.directoryId` |
| `BITBUCKET_OAUTH_CLIENT_ID` | `identity.bitbucket.client_id` | `identity.bitbucket.clientId` |
| `BITBUCKET_OAUTH_CLIENT_SECRET` | `identity.bitbucket.client_secret` | `identity.bitbucket.clientSecret` |
| `BOXY_SAML_OAUTH_CLIENT_ID` | `identity.boxy_saml.client_id` | `identity.boxySaml.clientId` |
| `BOXY_SAML_OAUTH_CLIENT_SECRET` | `identity.boxy_saml.client_secret` | `identity.boxySaml.clientSecret` |
| `BOXY_SAML_URL` | `identity.boxy_saml.url` | `identity.boxySaml.url` |
| `DISCORD_OAUTH_CLIENT_ID` | `identity.discord.client_id` | `identity.discord.clientId` |
| `DISCORD_OAUTH_CLIENT_SECRET` | `identity.discord.client_secret` | `identity.discord.clientSecret` |
| `FACEBOOK_OAUTH_CLIENT_ID` | `identity.facebook.client_id` | `identity.facebook.clientId` |
| `FACEBOOK_OAUTH_CLIENT_SECRET` | `identity.facebook.client_secret` | `identity.facebook.clientSecret` |
| `GITHUB_OAUTH_CLIENT_ID` | `identity.github.client_id` | `identity.github.clientId` |
| `GITHUB_OAUTH_CLIENT_SECRET` | `identity.github.client_secret` | `identity.github.clientSecret` |
| `GITLAB_BASE_URL` | `identity.gitlab.base_url` | `identity.gitlab.baseUrl` |
| `GITLAB_OAUTH_CLIENT_ID` | `identity.gitlab.client_id` | `identity.gitlab.clientId` |
| `GITLAB_OAUTH_CLIENT_SECRET` | `identity.gitlab.client_secret` | `identity.gitlab.clientSecret` |
| `GOOGLE_OAUTH_CLIENT_ID` | `identity.google.client_id` | `identity.google.clientId` |
| `GOOGLE_OAUTH_CLIENT_SECRET` | `identity.google.client_secret` | `identity.google.clientSecret` |
| `GOOGLE_WORKSPACES_OAUTH_CLIENT_ID` | `identity.google_workspaces.client_id` | `identity.googleWorkspaces.clientId` |
| `GOOGLE_WORKSPACES_OAUTH_CLIENT_SECRET` | `identity.google_workspaces.client_secret` | `identity.googleWorkspaces.clientSecret` |
| `GOOGLE_WORKSPACES_HD` | `identity.google_workspaces.hd` | `identity.googleWorkspaces.hd` |
| `LINKEDIN_OAUTH_CLIENT_ID` | `identity.linkedin.client_id` | `identity.linkedin.clientId` |
| `LINKEDIN_OAUTH_CLIENT_SECRET` | `identity.linkedin.client_secret` | `identity.linkedin.clientSecret` |
| `OKTA_OAUTH_CLIENT_ID` | `identity.okta.client_id` | `identity.okta.clientId` |
| `OKTA_OAUTH_CLIENT_SECRET` | `identity.okta.client_secret` | `identity.okta.clientSecret` |
| `OKTA_DOMAIN` | `identity.okta.domain` | `identity.okta.domain` |
| `TWITTER_OAUTH_CLIENT_ID` | `identity.twitter.client_id` | `identity.twitter.clientId` |
| `TWITTER_OAUTH_CLIENT_SECRET` | `identity.twitter.client_secret` | `identity.twitter.clientSecret` |

## license

How to add a key, and what an instance gets without one, is on the
[license keys page](https://agenta.ai/docs/self-host/reference/license-keys.md).

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_LICENSE_KEY` | `license.key` | n/a |

A license key turns on the plan it names for every organization on a self-hosted instance. The
key looks like `agenta_license_v1.<payload>.<signature>`. The instance checks it offline, with no
network call. Every Agenta image reads license keys.

An instance admin can also add a key in the app, under **Settings > License**. An instance admin
is a user whose email is in `AGENTA_ACCESS_ALLOWED_OWNER_EMAILS`, or, when that list is unset, the
owner of the oldest organization. A key in `AGENTA_LICENSE_KEY` takes priority over a key added in
the app, and the License page then shows the key but does not let you change it.

On a self-hosted instance, the plan of every organization comes from the key. With no valid key, or after the
key expires, the instance runs on `self_hosted_community`, which has no enterprise features and
allows 1 project per organization and 1 organization per instance. No data is deleted when a key
expires. See [Limits by plan](https://agenta.ai/docs/self-host/reference/license-keys.md#limits-by-plan). `AGENTA_ACCESS_DEFAULT_PLAN`, `AGENTA_ACCESS_PLANS` and
`AGENTA_ACCESS_DEFAULT_PLAN_OVERLAY` cannot turn on enterprise features without a key.

Do not confuse it with [`AGENTA_LICENSE`](#agenta-core), which picks the default database names.

The Helm chart has no value for it. Set it on the `api`, `worker-queues` and `worker-streams`
containers with `api.extraEnv`, `workerQueues.extraEnv` and `workerStreams.extraEnv`.

## llm (provider API keys)

| Env var | env.py path | values.yaml path |
|---|---|---|
| `ALEPHALPHA_API_KEY` | `llm.alephalpha` | `llm.alephalpha` |
| `ANTHROPIC_API_KEY` | `llm.anthropic` | `llm.anthropic` |
| `ANYSCALE_API_KEY` | `llm.anyscale` | `llm.anyscale` |
| `COHERE_API_KEY` | `llm.cohere` | `llm.cohere` |
| `DEEPINFRA_API_KEY` | `llm.deepinfra` | `llm.deepinfra` |
| `GEMINI_API_KEY` | `llm.gemini` | `llm.gemini` |
| `GROQ_API_KEY` | `llm.groq` | `llm.groq` |
| `MINIMAX_API_KEY` | `llm.minimax` | `llm.minimax` |
| `MISTRAL_API_KEY` | `llm.mistral` | `llm.mistral` |
| `OPENAI_API_KEY` | `llm.openai` | `llm.openai` |
| `OPENROUTER_API_KEY` | `llm.openrouter` | `llm.openrouter` |
| `PERPLEXITYAI_API_KEY` | `llm.perplexityai` | `llm.perplexityai` |
| `TOGETHERAI_API_KEY` | `llm.togetherai` | `llm.togetherai` |
| `XAI_API_KEY` | `llm.xai` | `llm.xai` |

A prompt or an evaluator runs on the provider keys saved in its project. The keys above, set on
the services container, are used only when a project has no key of its own for that provider,
and only when `AGENTA_SERVICES_ENV_PROVIDER_KEYS_ENABLED` allows it. It defaults to `true` when
`AGENTA_LICENSE` is `oss` or unset, and to `false` when it is `ee`. With it off, a project without a saved key gets the
error "No API key found for model". A custom provider always uses its own key and never one of
these.

The same setting covers AWS. A Bedrock or SageMaker connection can omit its access keys and run on
the AWS credentials of the host (the environment, an attached role, or instance metadata) only when
`AGENTA_SERVICES_ENV_PROVIDER_KEYS_ENABLED` allows it. With it off, such a call stops with the same
error, and the services container removes the AWS credential variables (such as
`AWS_ACCESS_KEY_ID`, `AWS_SESSION_TOKEN` and `AWS_PROFILE`) from its environment at start. The
region variables stay. The Bedrock bearer tokens `AWS_BEARER_TOKEN_BEDROCK` and `BEDROCK_MANTLE_API_KEY` are never
read from the services environment.

## loops

| Env var | env.py path | values.yaml path |
|---|---|---|
| `LOOPS_API_KEY` | `loops.api_key` | `loops.apiKey` |

## postgres

| Env var | env.py path | values.yaml path |
|---|---|---|
| `POSTGRES_USER` | `postgres.user` | `postgres.user` |
| `POSTGRES_PASSWORD` | `postgres.password` | `postgres.password` |
| `POSTGRES_PORT` | `postgres.port` | `postgres.port` |
| `POSTGRES_URI_CORE` | `postgres.uri_core` | `postgres.uriCore` |
| `POSTGRES_URI_SUPERTOKENS` | `postgres.uri_supertokens` | `postgres.uriSupertokens` |
| `POSTGRES_URI_TRACING` | `postgres.uri_tracing` | `postgres.uriTracing` |
| `POSTGRES_DB_PREFIX` | `postgres.db_prefix` | n/a |

The API finds its three databases in this order:

1. `POSTGRES_URI_CORE`, `POSTGRES_URI_TRACING` and `POSTGRES_URI_SUPERTOKENS`, when set.
2. Else `<prefix>_core`, `<prefix>_tracing` and `<prefix>_supertokens`, where the prefix is
   `POSTGRES_DB_PREFIX`.
3. Else the prefix is `agenta_` followed by `AGENTA_LICENSE`: `agenta_oss` when it is unset or
   `oss`, `agenta_ee` when it is `ee`.

The env file examples for new installs set `POSTGRES_DB_PREFIX`. Do not change it on an install
that has data: the install then opens other, empty databases. The Helm chart has no value for the
prefix. It names the bundled databases from `agenta.license`, and `postgresql.databases.*` overrides
them.

### Connection pool

Every process builds two engines, one for the core database and one for the tracing
database. A process can therefore open up to `2 x (pool_size + max_overflow)` server
connections at peak. Pools open connections on demand, so an idle process holds fewer. The defaults fit the smallest supported server, 400 connections shared by
about ten processes, and leave headroom for migrations, the cron and a `psql` session.

Raise them against the server's real limit, which `SHOW max_connections` reports. A pool
wider than the server grants does not fail at start. It fails during the next traffic
burst, as `TooManyConnectionsError` in every process at once.

| Env var | env.py path | Default | Purpose |
|---|---|---|---|
| `POSTGRES_POOL_SIZE` | `postgres.pool_size` | `5` | Connections each engine keeps open in an API process |
| `POSTGRES_MAX_OVERFLOW` | `postgres.max_overflow` | `10` | Extra connections an API engine may open during a burst, closed on check-in |
| `POSTGRES_WORKER_POOL_SIZE` | `postgres.worker_pool_size` | `2` | Same, for the queue and stream consumers |
| `POSTGRES_WORKER_MAX_OVERFLOW` | `postgres.worker_max_overflow` | `8` | Same, for the queue and stream consumers |
| `POSTGRES_POOL_RECYCLE_SECONDS` | `postgres.pool_recycle_seconds` | `1800` | Age at which a pooled connection is discarded |
| `POSTGRES_POOL_TIMEOUT_SECONDS` | `postgres.pool_timeout_seconds` | `30` | How long a caller waits for a connection once the pool and its overflow are exhausted |
| `POSTGRES_MAX_CONNECTIONS` | `postgres.max_connections` | `400` | The server's own `max_connections`, used only for a start-up warning |
| `POSTGRES_POOL_CONSUMERS` | `postgres.pool_consumers` | `10` | How many of your processes share that limit, used only for the same warning |

The queue and stream consumers get the narrower pool. A consumer opens many connections
during an evaluation run and then idles, and an idle connection inside `pool_size` is
never closed. The narrow pool keeps the steady state small and sends the burst through
overflow, which does close.

`POSTGRES_MAX_CONNECTIONS` and `POSTGRES_POOL_CONSUMERS` change no behavior. When
`pool_size + max_overflow` multiplied by two engines and by `POSTGRES_POOL_CONSUMERS`
exceeds `POSTGRES_MAX_CONNECTIONS`, each process logs one warning as it builds its
engines. Set both to your real numbers so the warning means something.

To size them, count every process that builds these engines at the largest rollout
overlap: each gunicorn worker in each API pod, and each queue and stream worker. Keep
`30 x API processes + 20 x worker processes` (the default peaks) well under
`max_connections`, and leave room for migrations and other clients.

The Helm chart has no values for these. Set them through each component's `extraEnv`.

## posthog

| Env var | env.py path | values.yaml path |
|---|---|---|
| `POSTHOG_API_KEY` | `posthog.api_key` | `posthog.apiKey` |
| `POSTHOG_API_URL` | `posthog.api_url` | `posthog.apiUrl` |

## redis

| Env var | env.py path | values.yaml path |
|---|---|---|
| `REDIS_URI` | `redis.uri` | `redis.uri` |
| `REDIS_URI_DURABLE` | `redis.uri_durable` | `redis.uriDurable` |
| `REDIS_URI_VOLATILE` | `redis.uri_volatile` | `redis.uriVolatile` |

## releases

What users see, and who sees it, is on the [update notices page](https://agenta.ai/docs/self-host/upgrade-and-migrate/update-notices.md).

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_UPDATE_CHECK_ENABLED` | `releases.update_check_enabled` | `releases.updateCheckEnabled` |
| `AGENTA_RELEASE_FEED_URL` | `releases.feed_url` | Not mapped; set it in the API's environment |

The update check is on by default. The API downloads the public release feed at
`https://agenta.ai/releases.json` when someone uses Agenta, and keeps it for 12 hours (each API
process keeps its own copy). The request sends the version the API runs and the kind of
instance (`?version=v0.131.0&kind=production`) and no other data about your instance. The kind
is `production` unless `AGENTA_TELEMETRY_INSTANCE_KIND` sets `development`, `ci` or `test`. Agenta uses the feed to
show newer releases in "What's new", an "Update available" mark in the help menu, and a
warning to organization owners and admins when a newer release fixes a security issue.

Set `AGENTA_UPDATE_CHECK_ENABLED=false` to stop the download. Agenta then shows only the
releases that shipped with the version you run. This setting does not follow
`AGENTA_TELEMETRY_ENABLED`.

`AGENTA_RELEASE_FEED_URL` is the address of the release feed. The default is
`https://agenta.ai/releases.json`. An empty value uses the default. Change it only to test a
different feed.

## smtp

SMTP is preferred for email delivery. It is enabled only when host, port, and
sender are configured. SendGrid remains supported as a fallback when SMTP is not
fully configured.

For local Mailpit from an API container, use `SMTP_HOST=host.docker.internal`
when Mailpit runs on the host, or `SMTP_HOST=mailpit` only when Mailpit is on
the same Docker network.

For setup steps, see [Set Up Email for Invitations](https://agenta.ai/docs/self-host/access-control/set-up-email.md).

| Env var | env.py path | values.yaml path |
|---|---|---|
| `SMTP_HOST` | `smtp.host` | `smtp.host` |
| `SMTP_PORT` | `smtp.port` | `smtp.port` |
| `SMTP_USERNAME` | `smtp.username` | `smtp.username` |
| `SMTP_PASSWORD` | `smtp.password` | `smtp.password` |
| `SMTP_FROM_EMAIL` | `smtp.from_email` | `smtp.fromEmail` |
| `SMTP_USE_TLS` | `smtp.use_tls` | `smtp.useTls` |
| `SMTP_USE_SSL` | `smtp.use_ssl` | `smtp.useSsl` |
| `SMTP_TIMEOUT` | `smtp.timeout` | `smtp.timeout` |

## sendgrid

SendGrid is used only when SMTP is not fully configured.

| Env var | env.py path | values.yaml path |
|---|---|---|
| `SENDGRID_API_KEY` | `sendgrid.api_key` | `sendgrid.apiKey` |
| `SENDGRID_FROM_EMAIL` | `sendgrid.from_email` | `sendgrid.fromEmail` |

## stripe

| Env var | env.py path | values.yaml path |
|---|---|---|
| `STRIPE_API_KEY` | `stripe.api_key` | `stripe.apiKey` |
| `STRIPE_WEBHOOK_SECRET` | `stripe.webhook_secret` | `stripe.webhookSecret` |
| `STRIPE_WEBHOOK_TARGET` | `stripe.webhook_target` | `stripe.webhookTarget` |

Stripe is for Agenta cloud billing. Do not set `STRIPE_API_KEY` on a self-hosted instance: the API
and the workers refuse to start when `STRIPE_API_KEY` is set and `AGENTA_LICENSE_KEY` is not a
cloud license key.

## supertokens

| Env var | env.py path | values.yaml path |
|---|---|---|
| `SUPERTOKENS_API_KEY` | `supertokens.api_key` | `supertokens.apiKey` |
| `SUPERTOKENS_APPLICATION` | `supertokens.application` | `supertokens.application` |
| `SUPERTOKENS_PASSWORD_MAX_LENGTH` | `supertokens.password_max_length` | `supertokens.passwordMaxLength` |
| `SUPERTOKENS_PASSWORD_MIN_LENGTH` | `supertokens.password_min_length` | `supertokens.passwordMinLength` |
| `SUPERTOKENS_PASSWORD_POLICY` | `supertokens.password_policy` | `supertokens.passwordPolicy` |
| `SUPERTOKENS_PASSWORD_REGEX` | `supertokens.password_regex` | `supertokens.passwordRegex` |
| `SUPERTOKENS_TENANT` | `supertokens.tenant` | `supertokens.tenant` |
| `SUPERTOKENS_URI_CORE` | `supertokens.uri_core` | `supertokens.uriCore` |

## telemetry

What a self-hosted instance sends to Agenta, and what each setting stops, is on the
[telemetry page](https://agenta.ai/docs/self-host/reference/telemetry.md).

| Env var | env.py path | values.yaml path |
|---|---|---|
| `AGENTA_TELEMETRY_ENABLED` | `telemetry.enabled` | `telemetry.enabled` |
| `AGENTA_DEPLOYMENT_METHOD` | `telemetry.deployment_method` | _(set to `helm` by the chart)_ |
| `AGENTA_TELEMETRY_INSTANCE_KIND` | `telemetry.instance_kind` | `telemetry.instanceKind` |

`AGENTA_TELEMETRY_ENABLED` defaults to `true`. Set it to `false` to stop every event
except the one-time install ping. `AGENTA_DEPLOYMENT_METHOD` is `compose`, `helm`,
`railway`, `kubernetes` or `docker`. The Helm chart, the compose files and the Railway
template set it for you. When it is unset, the API reports `kubernetes` if
`KUBERNETES_SERVICE_HOST` is set, `docker` if `/.dockerenv` exists, and nothing otherwise.
`AGENTA_TELEMETRY_INSTANCE_KIND` is `production`, `development`, `ci` or `test`. When it
is unset, the API reports `ci` if `CI` is set, `development` if the web URL is
`localhost` or a private address, and `production` otherwise. The install ping, the
startup event, the heartbeat and every product event carry it as `instance_kind`.

## Deprecated environment variables

The following legacy names still work via fallback (the Pydantic env loader
reads the new name first, then the legacy one). They will be removed in a
future major release.

| Legacy env var | Canonical replacement |
|---|---|
| `AGENTA_ALLOWED_DOMAINS` | `AGENTA_ACCESS_ALLOWED_DOMAINS` |
| `AGENTA_ORG_CREATION_ALLOWLIST` | `AGENTA_ACCESS_ALLOWED_OWNER_EMAILS` |
| `AGENTA_ACCESS_ORG_CREATION_ALLOWLIST` | `AGENTA_ACCESS_ALLOWED_OWNER_EMAILS` |
| `AGENTA_ACCESS_ALLOWED_ORGANIZATION_OWNERS` | `AGENTA_ACCESS_ALLOWED_OWNER_EMAILS` |
| `AGENTA_BLOCKED_DOMAINS` | `AGENTA_ACCESS_BLOCKED_DOMAINS` |
| `AGENTA_BLOCKED_EMAILS` | `AGENTA_ACCESS_BLOCKED_EMAILS` |
| `AGENTA_DEFAULT_PLAN` | `AGENTA_ACCESS_DEFAULT_PLAN` |
| `SUPERTOKENS_EMAIL_DISABLED` | `AGENTA_ACCESS_EMAIL_DISABLED` |
| `AGENTA_PRICING` | `AGENTA_BILLING_PRICING` |
| `STRIPE_PRICING` | `AGENTA_BILLING_PRICING` |
| `AGENTA_CACHE_ENABLED` | `AGENTA_API_CACHING_ENABLED` |
| `AGENTA_CACHING_ENABLED` | `AGENTA_API_CACHING_ENABLED` |
| `AGENTA_LOG_CONSOLE_ENABLED` | `AGENTA_LOGGING_CONSOLE_ENABLED` |
| `AGENTA_LOG_CONSOLE_LEVEL` | `AGENTA_LOGGING_CONSOLE_LEVEL` |
| `AGENTA_LOG_FILE_ENABLED` | `AGENTA_LOGGING_FILE_ENABLED` |
| `AGENTA_LOG_FILE_LEVEL` | `AGENTA_LOGGING_FILE_LEVEL` |
| `AGENTA_LOG_FILE_PATH` | `AGENTA_LOGGING_FILE_PATH` |
| `AGENTA_LOG_OTLP_ENABLED` | `AGENTA_LOGGING_OTLP_ENABLED` |
| `AGENTA_LOG_OTLP_LEVEL` | `AGENTA_LOGGING_OTLP_LEVEL` |
| `AGENTA_SERVICES_SANDBOX_RUNNER` | `AGENTA_SERVICES_CODE_SANDBOX_RUNNER` |
| `AGENTA_SERVICE_MIDDLEWARE_AUTH_ENABLED` (singular SERVICE) | `AGENTA_SERVICES_MIDDLEWARE_AUTH_ENABLED` |
| `AGENTA_SERVICE_MIDDLEWARE_CACHE_ENABLED` (singular SERVICE) | `AGENTA_SERVICES_MIDDLEWARE_CACHING_ENABLED` |
| `AGENTA_WEBHOOK_ALLOW_INSECURE` | `AGENTA_INSECURE_EGRESS_ALLOWED` |
| `AGENTA_WEBHOOKS_ALLOW_INSECURE` | `AGENTA_INSECURE_EGRESS_ALLOWED` |
| `AGENTA_SERVICES_HOOK_ALLOW_INSECURE` | `AGENTA_INSECURE_EGRESS_ALLOWED` |
| `AGENTA_CUSTOM_PROVIDER_ALLOW_INSECURE` | `AGENTA_INSECURE_EGRESS_ALLOWED` |
| `AGENTA_AUTO_MIGRATIONS` | `ALEMBIC_AUTO_MIGRATIONS` |
| `AGENTA_RUNTIME_PREFIX` | _(removed; no consumer in API)_ |
| `ACTIVE_DIRECTORY_OAUTH_CLIENT_ID` | `AZURE_AD_OAUTH_CLIENT_ID` |
| `ACTIVE_DIRECTORY_OAUTH_CLIENT_SECRET` | `AZURE_AD_OAUTH_CLIENT_SECRET` |
| `ACTIVE_DIRECTORY_DIRECTORY_ID` | `AZURE_AD_DIRECTORY_ID` |
| `POSTHOG_HOST` | `POSTHOG_API_URL` |
| `AGENTA_AUTHN_EMAIL_FROM` | `SMTP_FROM_EMAIL` (preferred) or `SENDGRID_FROM_EMAIL` fallback |
| `AGENTA_SEND_EMAIL_FROM_ADDRESS` | `SMTP_FROM_EMAIL` (preferred) or `SENDGRID_FROM_EMAIL` fallback |
| `STRIPE_TARGET` | `STRIPE_WEBHOOK_TARGET` |
| `SUPERTOKENS_CONNECTION_URI` | `SUPERTOKENS_URI_CORE` |

## Removed environment variables

Some variables were removed without a replacement. Agenta ignores them, and the behavior they used to switch is always on. For the list removed in 0.121.0 and what each one did, see [Upgrading to 0.121.0](https://agenta.ai/docs/self-host/upgrade-and-migrate/upgrading.md#upgrading-to-01210).

From 0.122.6 the images no longer include the New Relic agent. Agenta ignores `NEWRELIC_LICENSE_KEY`, `NEW_RELIC_LICENSE_KEY` and `NRIA_LICENSE_KEY`, and the Helm chart ignores `newrelic.licenseKey` and `observability.newRelic.licenseKey`. You can delete them.

The `newrelic-admin` command is gone from the images too. If your own Compose file or Kubernetes manifest starts the api, services or worker containers with `newrelic-admin run-program`, remove that prefix before you upgrade, or those containers fail to start. Keep the rest of the command as it is. The Compose files and the Helm chart in this repository already start the processes without it.
