Skip to main content
The examples use the axectl wrapper from the quickstart. The gRPC examples use grpcurl against axe.v1 on port 9090; add -H "authorization: Bearer $TOKEN" when axed requires a token. The native API reference covers every field.

Choose a lifetime

A process either outlives the call that started it or dies with it. Pick the RPC that matches.
axectl exec always keeps stdin open and forwards yours, so you can pipe input into it. If axectl exec is killed, axed kills the whole process tree, and ps later shows the process with exit code 137.
In the Agent Sandbox API, process.v1.ProcessService/Start behaves like Run without detach, so the process dies when the stream ends. Execute and ExecuteWithLimits behave like Exec. The Agent Sandbox API has no detached start. See the Agent Sandbox API reference.

Refer to a process

Every process gets an id of 32 hex digits that is never reused. Ids belong to one daemon instance; see Snapshots for what happens after a cold boot. You can also give a process a name:
  • A name is unique among running processes. Starting a second process with a name that is in use fails with ALREADY_EXISTS.
  • The name frees when the process exits, so you can reuse it right away.
  • A name resolves to the running process with that name, or, if none is running, to the most recently finished one that axed still keeps.
In the API, every call that takes a process uses ProcessRef, a oneof of id and name. axectl treats any argument of exactly 32 hex digits as an id and anything else as a name, so avoid names that look like ids.

Label and filter

Labels are key-value pairs you attach at start. List returns only processes that carry all the labels you pass.
List includes finished processes that axed still keeps, so you can read their exit status.

Retry a start safely

A connection can drop after axed started a process but before you got the reply, for example across a snapshot. Set request_id on StartRequest (or on the start inside RunRequest, or on ExecRequest) so that a retry does not start a second copy. Repeating a start with the same request_id returns the process the first start created, with no new process and no name conflict.
The retry must be the same request: a different spec, name, labels or retain_bytes under the same id fails with ALREADY_EXISTS (REQUEST_ID_CONFLICT), so a reused key never silently returns an unrelated process. Once axed evicts the record (see finished records), a retry fails with FAILED_PRECONDITION (REQUEST_EXPIRED) instead of starting the command again. axed remembers the last 4096 evicted ids. After you remove a process with Remove, its id is free for a new start. axectl run --request-id KEY sets one.

Retry an Exec

Exec with a request_id keeps its process like Start does: it shows in List, and it runs to the end even if the call is cancelled, as it is when a snapshot drops the connection. Repeating the same Exec returns the first run’s exit and output, read back from its retained output (retain_bytes, default --retain), without running the command again. If the first run wrote more than it retained, or its record was evicted, the repeat fails with FAILED_PRECONDITION (REQUEST_EXPIRED). Size retain_bytes to the output you expect.

Set the environment, directory and user

These fields live in Spec, which every start RPC takes.
axed resolves a relative working directory inside the root, so -w src runs in /workspace/src. An absolute path under the root, such as -w /workspace/src, is used as it is. An absolute path outside the root, such as / or /etc, fails with PERMISSION_DENIED, and so does .. above the root. A directory that does not exist fails with NOT_FOUND. See Path confinement. A uid with no /etc/passwd entry runs with a gid equal to the uid. An unknown user name fails with NOT_FOUND. Switching users needs privilege. axed sets the process’s uid and gid, so when axed itself runs unprivileged (as in the default image, user 1000), a user that changes either fails with PERMISSION_DENIED. To run processes as another user, run axed as root or give it CAP_SETUID and CAP_SETGID.
The Agent Sandbox ProcessConfig carries command, env_vars and cwd. It has no user, name, labels or request id. axed takes an absolute cwd outside the root as relative to it, so /src there means /workspace/src.

Set retention per process

Each process keeps its newest output bytes for replay. retain_bytes (axectl run --retain N) sets how many. Retention describes the defaults, the limits and how axed raises small values.
Retention counts against a global output budget. The output log explains replay, the budget, and what happens when it fills.