> ## Documentation Index
> Fetch the complete documentation index at: https://axe-engine.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Substrate

> Run axed as the guest daemon in Agent Substrate actors in place of ate-env-guest.

## What Agent Substrate expects

Agent Substrate snapshots whole sandboxes without calling into the guest. It cancels client streams before a snapshot, may cold-boot from the persisted disk instead of restoring memory, and expects the main process to survive SIGTERM so the actor can be suspended. axed handles each of these:

* **Memory restores are transparent.** Processes keep running. Clients reconnect and continue from an output offset.
* **Cold boots are visible.** A cold boot starts a new axed with a new `instance_id`, so no client mistakes a new process for an old one.
* **Timeouts count running time.** Time spent suspended does not count against a process's timeout. axed detects a suspend when the clocks show the gap; where they do not, the platform can report the restore with `System.Configure` (`axectl resumed`). See [Snapshots](https://axe-engine.mintlify.site/snapshots.md).

## Configure axed

Start axed with two flags:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
axed --agent-substrate --on-sigterm=stay
```

**--agent-substrate** `switch` (default: off)

Takes no value. Serve Agent Substrate's guest API, `ateenv.v1alpha` (its `ProcessService` and `FileSystemService`), on every listener, next to AXE's native API.

**--on-sigterm** `shutdown | stay` (default: shutdown)

With `stay`, SIGTERM does not stop axed. It logs `eviction pending`, keeps running, and reports `eviction_pending: true` through `System.Health`, so the platform can suspend the sandbox instead of losing it. SIGINT always shuts down.

By default axed also serves the Kubernetes Agent Sandbox API, including a REST listener on port 8080. Leave it on if you use its health endpoint for the wakeup probe, as below.

## Point the wakeup probe at /readyz

`ate-env-guest` serves the guest API and `GET /readyz` together on one port (`:80` by default). axed splits them: the guest API is on `--grpc-port` (9090 by default) and any `--listen` endpoint, and `GET /readyz` is on `--rest-port` (8080 by default). Point clients of the guest API at the gRPC port; the template's wakeup probe needs only its port changed. It answers without a token, the same as `GET /v1/health`, and returns 503 while axed shuts down. A gRPC probe can use `grpc.health.v1` on any listener instead.

## Check eviction state

After a SIGTERM, `axectl info` shows the state:

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
ready          true
eviction       pending
```

## What was tested

Agent Substrate's own guest API tests, from `agent-substrate/env`, pass against axed with their test bodies unchanged. Tests that configure a server-side policy run against an axed started with the matching flag: a default timeout with `--default-timeout`, and a process concurrency cap with `--max-processes`. One is skipped because axed has no equivalent policy: a log size cap that writes a truncation notice into the output.

To match `ate-env-guest`'s defaults, start axed with `--default-timeout 1h --max-processes 10`. Both are off (or larger) by default.

Snapshot behavior was tested under [gVisor](https://axe-engine.mintlify.site/deploy/gvisor.md) and [Firecracker](https://axe-engine.mintlify.site/deploy/firecracker.md), not inside Agent Substrate itself.

## Reference

> [card] [Agent Substrate API](https://axe-engine.mintlify.site/reference/agent-substrate-api.md)
>
> The `ateenv.v1alpha` services as axed serves them.

> [card] [Snapshots](https://axe-engine.mintlify.site/snapshots.md)
>
> How axed detects suspend and restore.


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