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

# Configuration reference: environment variables

> Every environment variable RootSign reads, with its default and allowed values, plus where settings come from, when they are read, and how a .env file applies.

RootSign is configured with environment variables. Every setting has a default, so a plain `pip install rootsign` records to local JSONL files with nothing set. This page lists each variable, grouped by what it controls.

## How settings are read

**Sources.** Each variable is read from the environment, then from a `.env` file in the **current working directory**, then from its default. An environment variable wins over the same name in `.env`. The `.env` file is found from the directory you run the program from, not the directory the script is in. Names are not case-sensitive.

> [!WARNING]
>
> A `.env` file in your working directory applies to RootSign even if it was written for something else. If a project's `.env` sets `ROOTSIGN_BACKEND` or `DATABASE_URL`, every RootSign script and command run from that directory uses it.

**When they are read.** The `ROOTSIGN_` settings are read when `rootsign.init()` runs, and stay fixed for the rest of the process: changing a variable after `init()` has no effect. Setting one in code before `init()` works:

```python theme={null}
import os

import rootsign

os.environ["ROOTSIGN_CAPTURE_DECISIONS"] = "true"
rootsign.init(agent="invoice-agent")
```

Without `init()`, for example when you build a `SessionContext` and client yourself, each setting is read when it is used. The database settings are read the first time RootSign connects to PostgreSQL. The CLIs read everything when they start.

> [!NOTE]
>
> Before the release after RootSign 0.3.1, `ROOTSIGN_CAPTURE_DECISIONS` and `ROOTSIGN_REASONING_DEPTH` were read when `rootsign` was imported, so setting them in code after the import was ignored.

**Invalid values.** A `ROOTSIGN_` variable with a value outside its allowed list stops `import rootsign` with a pydantic `ValidationError` that names the setting:

```text theme={null}
pydantic_core._pydantic_core.ValidationError: 1 validation error for SDKSettings
BACKEND
  Input should be 'jsonl', 'postgres', 'cloud' or 'local' [type=literal_error, input_value='sqlite', input_type=str]
```

## Storage backend

**ROOTSIGN\_BACKEND** `jsonl | postgres | cloud` (default: jsonl)

Where records are written.

| Value | Records go to | Needs |
| - | - | - |
| `jsonl` | One file per session under `ROOTSIGN_DATA_DIR` | Nothing |
| `postgres` | PostgreSQL with TimescaleDB, at `DATABASE_URL` | `pip install 'rootsign[postgres]'` |
| `cloud` | The hosted ingest endpoint, **preview** | `pip install 'rootsign[cloud]'` |

`local` is a deprecated name for `postgres`, and prints a `FutureWarning`. With `cloud`, RootSign cannot register the agent, because the hosted backend issues agent IDs: pass the ID with `rootsign.session(agent_id=...)`. A session opened without one raises `ValueError`.

**ROOTSIGN\_DATA\_DIR** `path` (default: \~/.rootsign)

The folder for the JSONL backend. Sessions are written to `sessions/<session_id>.jsonl` inside it, and registered agents to `agents.jsonl`. It also moves the spool, unless `ROOTSIGN_SPOOL_DIR` is set.

**ROOTSIGN\_JSONL\_FSYNC** `chain | always | never` (default: chain)

When the JSONL backend forces a write to disk with `fsync`.

| Value | `fsync` after |
| - | - |
| `chain` | Each action and approval record, the records the hash chain depends on |
| `always` | Every record, including session open and close |
| `never` | No record. The operating system writes them when it chooses, so a power loss can lose the last records. |

## PostgreSQL

These have no `ROOTSIGN_` prefix. They apply with `ROOTSIGN_BACKEND=postgres`, to the `rootsign` commands that take a session or action ID, and to `rootsign-admin`.

**DATABASE\_URL** `URL` (default: postgresql+asyncpg://rootsign:rootsign\@localhost:5432/rootsign\_dev)

The database the SDK and the `rootsign` CLI connect to. Use the `postgresql+asyncpg://` form: `rootsign[postgres]` installs the asyncpg driver. With a plain `postgresql://` URL, SQLAlchemy chooses another driver, and the connection fails unless that driver is installed and supports asyncio. The default is the database [`rootsign-admin start-db`](https://docs.getprovidex.com/reference/cli-rootsign-admin#rootsign-admin-start-db) creates.

**DATABASE\_URL\_SYNC** `URL` (default: postgresql+psycopg2://rootsign:rootsign\@localhost:5432/rootsign\_dev)

The same database, with the `psycopg2` driver. `rootsign-admin init` and `status` connect with it. Point it at the same database as `DATABASE_URL`.

**DB\_POOL\_SIZE** `integer` (default: 10)

Connections the SDK keeps open to the database.

**DB\_MAX\_OVERFLOW** `integer` (default: 20)

Extra connections allowed above `DB_POOL_SIZE` under load.

**DB\_POOL\_TIMEOUT** `integer` (default: 30)

Seconds to wait for a free connection before failing.

**ENVIRONMENT** `text` (default: development)

Set it to `production` in a real deployment. RootSign then refuses to use the default database URLs, which point at a local database with the password `rootsign`, so a deployment that forgot to set `DATABASE_URL` fails instead of writing to the wrong place. The refusal is a `ValidationError` raised the first time RootSign reads the database settings: when `rootsign-admin` starts, or when the SDK first connects.

```text theme={null}
Value error, ENVIRONMENT=production but DATABASE_URL still points at the dev-credentialed local database. Set DATABASE_URL (and DATABASE_URL_SYNC) explicitly for production deployments.
```

This is not the agent's environment, which you pass to `rootsign.init(environment=...)`.

## Cloud transport and spool

> [!WARNING]
>
> **Preview.** The hosted ingest endpoint is not live yet. The spool and `rootsign-admin sync --dry-run` work today.

**ROOTSIGN\_CLOUD\_URL** `URL` (default: [https://ingest.getprovidex.com/v1](https://ingest.getprovidex.com/v1))

The ingest endpoint. Records are posted to `<ROOTSIGN_CLOUD_URL>/ingest`, so the value ends in `/v1`, not `/v1/ingest`.

**ROOTSIGN\_API\_KEY** `text`

The key sent with each request. Required for `rootsign-admin sync` to upload anything.

**ROOTSIGN\_SPOOL\_DIR** `path` (default: \$ROOTSIGN\_DATA\_DIR/spool)

Where records are kept when the endpoint is unreachable. Spooled sessions are ordinary session files, so `rootsign verify --local` and `rootsign export --local` read them.

**ROOTSIGN\_HTTP\_TIMEOUT\_SECONDS** `number` (default: 10.0)

Timeout for each request.

**ROOTSIGN\_HTTP\_MAX\_RETRIES** `integer` (default: 3)

Attempts per request, including the first. `3` means one send and at most two retries.

**ROOTSIGN\_ON\_RECORD\_LOSS** `warn | fail` (default: warn)

What the cloud transport does when a record can be neither sent nor spooled, for example because the endpoint is down and the disk is full.

| Value | Behaviour |
| - | - |
| `warn` | Log at CRITICAL, keep the agent running, and leave a gap in the chain that verifies as INCOMPLETE. |
| `fail` | Raise `RecordPersistenceError` into the tool call, for deployments that prefer a stopped agent to a missing record. |

Approval records never follow this setting: if one cannot be stored, the held tool does not run and `HiTLPersistenceError` is raised. See [Errors](https://docs.getprovidex.com/reference/errors.md).

## Decision capture

**ROOTSIGN\_CAPTURE\_DECISIONS** `boolean` (default: false)

Record what the agent decided, and why, before each action. When off, `ctx.record_decision()` does nothing and returns `None`, so the same code can run with capture on or off. Off by default because reasoning text is where personal data tends to collect.

**ROOTSIGN\_REASONING\_DEPTH** `minimal | summary | full` (default: summary)

How much of each decision is kept. Ignored when capture is off.

| Value | `reasoning_summary` | `alternatives_considered` |
| - | - | - |
| `minimal` | Not kept | Not kept |
| `summary` | First 500 characters | Not kept |
| `full` | First 10,000 characters | Kept |

## Batching

**ROOTSIGN\_BUFFERED** `boolean` (default: false)

Queue records in memory and write them in batches, so tool calls do not wait for each write. Records are still written in order and the chain verifies the same way. The batch is written when the session closes.

**ROOTSIGN\_BUFFER\_INTERVAL** `number` (default: 0.5)

Seconds between background writes of the batch.

**ROOTSIGN\_BUFFER\_MAX\_SIZE** `integer` (default: 100)

Records queued before a write is forced.

## Accepted but unused

`ROOTSIGN_WAL_PATH`, `ROOTSIGN_MAX_RETRIES`, `ROOTSIGN_RETRY_BASE_DELAY` and `ROOTSIGN_RETRY_MAX_DELAY` are still accepted, so an existing `.env` that sets them keeps loading, but nothing reads them. For retries, use `ROOTSIGN_HTTP_MAX_RETRIES`.

## Related

> [card] [rootsign-admin](https://docs.getprovidex.com/reference/cli-rootsign-admin.md)
>
> Start the local database, create its tables, and upload the spool.

> [card] [Errors](https://docs.getprovidex.com/reference/errors.md)
>
> Every exception RootSign raises into your code.


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