> ## 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.

# Errors reference: exceptions RootSign raises

> Every exception RootSign can raise into your code, when each one happens, its attributes and message, and the failures RootSign logs instead of raising.

RootSign is built so that recording never breaks the agent it records. When a record cannot be written, RootSign logs a `WARNING` on the `rootsign` logger and your tool returns its real result. Exceptions reach your code in four cases only:

* **An approval decides against a tool call.** A person rejects it, nobody answers in time, or the approval itself cannot be stored. The tool does not run.
* **A session cannot be opened.** `rootsign.session()` raises before its body runs, so the agent does no work that would leave no record at all.
* **You asked for failures to stop the agent**, with `ROOTSIGN_ON_RECORD_LOSS=fail`.
* **RootSign is set up wrongly**: no session is open, or an extra is missing.

## Catch everything from RootSign

Every exception on this page, apart from those under [Other exceptions](#other-exceptions), derives from `RootSignError`:

```python theme={null}
from rootsign import RootSignError

try:
    await wire_transfer(account="GB29NWBK60161331926819", amount=250000.0)
except RootSignError as error:
    print(f"not run: {error}")
```

```text theme={null}
RootSignError
├── HiTLRejectedError
├── HiTLTimeoutError
├── HiTLUnsupportedBackendError
├── RecordPersistenceError
│   └── HiTLPersistenceError
├── RootSignNotInitializedError
├── RootSignPostgresExtraRequired
├── RootSignCloudExtraRequired
├── EscalationDepthExceededError
└── IngestError
```

Import any of them from `rootsign.errors`. `RootSignError`, `RootSignNotInitializedError`, `HiTLRejectedError`, `HiTLTimeoutError` and `EscalationDepthExceededError` can also be imported from `rootsign`.

## Approval

These come from tools marked `@rootsign.trace(require_approval=True)`. [Require human approval](https://docs.getprovidex.com/guides/human-approval.md) shows each one in context.

### HiTLRejectedError

A person rejected the call, with `rootsign approve <action_id> --reject` or by answering anything but yes at the inline prompt. The tool did not run, and the rejection is recorded.

```text theme={null}
Action 7d8d56ec-805c-430d-ae2f-ff1141a17f30 rejected by approver. Reason: Above the unattended mandate
```

**action\_id** `UUID`

The held action.

**reason** `str | None`

The note given with the rejection, if any.

### HiTLTimeoutError

Nobody decided within `timeout_seconds`, on the PostgreSQL backend. The tool did not run. The action is recorded as `timed_out`, which is kept apart from a person rejecting it. The inline prompt on the JSONL backend has no timeout.

```text theme={null}
HiTL approval timed out after 300s for action b5e0e3d3-fa5e-4cb4-9462-b1048fd54c83. Status set to timed_out.
```

**action\_id** `UUID`

The held action.

**timeout\_seconds** `int | float`

The timeout that expired.

### HiTLUnsupportedBackendError

`require_approval=True` was used where nobody can be asked: on the JSONL backend with no terminal to prompt in, such as a background job or CI; on the cloud transport, whose approvals will come from the hosted backend once it is live; or with a `LocalIngestClient` bound to your own database transaction, whose pending record nobody can see until you commit. Raised on the tool's first call, before it runs and before anything is recorded. Run it in a terminal, or use the PostgreSQL backend and `rootsign approve`.

```text theme={null}
HiTL not available for tool 'wire_transfer' on this backend. Human-in-the-loop with require_approval=True needs either an interactive terminal (JSONL backend prompts inline) or the shared store: set ROOTSIGN_BACKEND=postgres for the async poll-loop / `rootsign approve` flow.
```

On the cloud transport:

```text theme={null}
HiTL not available for tool 'wire_transfer' on the cloud transport. Approvals on the cloud transport will come from the hosted backend, which is not live yet. Set ROOTSIGN_BACKEND=postgres to approve with `rootsign approve`, or use the JSONL backend in an interactive terminal.
```

With a client bound to your own transaction:

```text theme={null}
HiTL not available for tool 'wire_transfer' with a client bound to your own transaction. A held call's pending record must be committed when it is written, so that `rootsign approve` can see it. Use ManagedLocalIngestClient, which commits each record (rootsign.init() uses it), instead of LocalIngestClient(db=...).
```

> [!NOTE]
>
> The cloud and own-transaction cases were added after RootSign 0.3.1. In 0.3.1 and earlier, a held call with your own transaction waited for an approval nobody could see, then failed with `ActionNotFoundError`. A held call on the cloud transport tried to reach a local PostgreSQL database and failed with `OSError`, or with `ActionNotFoundError` if one was running. In neither case did the tool run.

**tool\_name** `str | None`

The tool that was called.

### HiTLPersistenceError

The record of a held call, or of the decision on it, could not be stored: the session file could not be written, or the database refused it. Raised before the tool runs, whatever `ROOTSIGN_ON_RECORD_LOSS` says: a decision that cannot be recorded is not acted on. For example, on the JSONL backend with a session file that cannot be written:

```text theme={null}
HiTL record for tool 'pay' could not be persisted: the pending action record was not stored (the cause is logged above at WARNING). The gated action was not executed.
```

**tool\_name** `str | None`

The held tool.

It is a subclass of `RecordPersistenceError`, so `except RecordPersistenceError` catches both.

> [!NOTE]
>
> Before the release after RootSign 0.3.1, the JSONL backend ran an approved tool even when the approval record could not be written, and the JSONL and PostgreSQL backends raised `RuntimeError` when the pending record could not be written.

## Recording

### RecordPersistenceError

A record could not be stored anywhere, and you set `ROOTSIGN_ON_RECORD_LOSS=fail`. Raised by the cloud transport when the endpoint is unreachable and the spool cannot be written. It can come from the call that writes the record: opening the session, a tool call, or closing the session.

```text theme={null}
record for session <session_id> could not be persisted (PermissionError: [Errno 13] Permission denied: '<spool_dir>/sessions') and ROOTSIGN_ON_RECORD_LOSS=fail
```

With the default, `warn`, nothing is raised. RootSign logs the loss at `CRITICAL`, the agent keeps running, and the gap in the chain makes the session verify as INCOMPLETE. See [`ROOTSIGN_ON_RECORD_LOSS`](https://docs.getprovidex.com/reference/configuration#cloud-transport-and-spool).

`rootsign.session()` also raises it, on every backend and whatever `ROOTSIGN_ON_RECORD_LOSS` says, when it cannot open the session: the agent cannot be registered, or the session's first record cannot be written, for example because the data folder is not writable or the database is down. Nothing in the `async with` block runs. A record lost later leaves a gap that verify reports, but a session that never opened leaves no file to show that anything was missed.

```text theme={null}
session could not be opened (PermissionError: [Errno 13] Permission denied: '<data_dir>/agents.jsonl'). Nothing was recorded, and the session body did not run.
```

The original error is its `__cause__`.

It is raised the same way when the store refuses the session's first record, for example on PostgreSQL for an agent ID that was never registered. A first record the cloud transport could not deliver at all is not a refusal; `ROOTSIGN_ON_RECORD_LOSS` decides what happens to it, as above. For an unknown agent ID:

```text theme={null}
session could not be opened (the store refused SESSION_OPEN: UNKNOWN_AGENT: agent_id=<agent_id> not registered). Nothing was recorded, and the session body did not run.
```

> [!NOTE]
>
> Failing on a refused session open was added after RootSign 0.3.1. Until then the session body ran, and the store refused every record in it.

> [!NOTE]
>
> Before the release after RootSign 0.3.1, a session that could not be opened raised the underlying `PermissionError` or `OSError` instead.

## Setup

### RootSignNotInitializedError

A traced tool, `wrap_tools()`, the MCP proxy or `record_decision()` was used with no session to record into: outside `async with rootsign.session(...)`, and without an explicit `ctx=` and `client=`.

```text theme={null}
@rootsign.trace requires a session context. No rootsign session is active. Either open one:
    rootsign.init(agent="my-agent")
    async with rootsign.session(objective="..."):  # then wrap/trace inside
or pass the context explicitly: ctx=<SessionContext>, client=<IngestClient>.
```

**surface** `str | None`

What needed the session, such as `@rootsign.trace`.

### RootSignPostgresExtraRequired

`ROOTSIGN_BACKEND=postgres` was set, but the database packages are not installed. Raised when the first session opens. Install them with `pip install 'rootsign[postgres]'`.

```text theme={null}
ROOTSIGN_BACKEND=postgres requires the database extra. Install with:  pip install 'rootsign[postgres]'  (missing module: sqlalchemy)
```

### RootSignCloudExtraRequired

An `HttpIngestClient` was created without the HTTP package. Install it with `pip install 'rootsign[cloud]'`.

```text theme={null}
ROOTSIGN_BACKEND=cloud requires the cloud extra. Install with:  pip install 'rootsign[cloud]'  (missing module: httpx)
```

### EscalationDepthExceededError

Reserved for chained approval escalations. This version never raises it.

## Ingest errors

`IngestError` and its subclasses are raised inside the store when it refuses a record, and are turned into an error code in the store's response. They do not reach your code. You see the codes in `rootsign-admin sync` output and in sync receipts.

| Exception | Error code |
| - | - |
| `UnknownAgentError` | `UNKNOWN_AGENT` |
| `SessionNotFoundError` | `SESSION_NOT_FOUND` |
| `SessionClosedError` | `SESSION_CLOSED` |
| `SessionAlreadyExistsError` | `SESSION_ALREADY_EXISTS` |
| `ActionNotFoundError` | `ACTION_NOT_FOUND` |
| `ActionAlreadyResolvedError` | `ACTION_ALREADY_RESOLVED` |
| `ApprovalParentNotFoundError` | `APPROVAL_PARENT_NOT_FOUND` |
| `IngestValidationError` | `VALIDATION_ERROR` |
| `HashChainBrokenError` | `HASH_CHAIN_BROKEN` |

Each carries `error_code` and `retryable` attributes. The full list of codes, with which ones to retry, is in the [ingest specification](https://docs.getprovidex.com/reference/ingest-spec-v1.md#5-error-code-registry).

## Other exceptions

Some mistakes raise standard Python exceptions rather than `RootSignError`:

| Exception | When |
| - | - |
| `ValueError` | `rootsign.init()` gets an invalid value, such as `risk_tier="extreme"` or a one-character `agent`, or is called a second time with different arguments. A session opened with `ROOTSIGN_BACKEND=cloud` and no `agent_id`. |
| `pydantic.ValidationError` | A `ROOTSIGN_` environment variable has a value outside its allowed list, which stops `import rootsign`. `ENVIRONMENT=production` with the default database URLs. See [Configuration](https://docs.getprovidex.com/reference/configuration.md#how-settings-are-read). |
| `NotImplementedError` | `require_approval=True` on a LangChain `BaseTool` or a CrewAI tool. Put it on the plain function the tool calls. |
| `FileNotFoundError` | `verify_session_local()` is given a path that does not exist. |

For example:

```text theme={null}
ValueError: rootsign.init() was already called with different arguments (agent='invoice-agent'/'development', backend='jsonl' → agent='billing-agent'/'development', backend='jsonl'). init() configures one agent identity per process; for multiple identities use the explicit API (SessionContext + get_ingest_client).
```

## What is logged instead of raised

Failures that do not affect whether a tool should run are logged on the `rootsign` logger and never raised:

* A record that could not be written, on any backend, logged at `WARNING`. On the cloud transport it goes to the spool first. For example, on the JSONL backend:

  ```text theme={null}
  WARNING rootsign.sdk: rootsign ingest failed for tool lookup: [Errno 13] Permission denied: '<data_dir>/sessions/<session_id>.jsonl'
  ```
* Records lost entirely with `ROOTSIGN_ON_RECORD_LOSS=warn`, logged at `CRITICAL`, with a chain gap that verify reports.
* A decision that could not be recorded. The action is still recorded, without a `decision_id`.

To see them, configure logging in your application, for example `logging.basicConfig(level=logging.WARNING)`.

## Related

> [card] [Require human approval](https://docs.getprovidex.com/guides/human-approval.md)
>
> Hold a tool call until a person decides, and handle the outcome.

> [card] [Configuration](https://docs.getprovidex.com/reference/configuration.md)
>
> Every environment variable, including `ROOTSIGN_ON_RECORD_LOSS`.


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