Skip to main content

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.

Configure axed

Start axed with two flags:
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.
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:

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 and Firecracker, not inside Agent Substrate itself.

Reference

Agent Substrate API

The ateenv.v1alpha services as axed serves them.

Snapshots

How axed detects suspend and restore.