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

# Compatibility with sandboxd

> Every place axed intentionally behaves differently from sandboxd.

Every place where axed's Agent Sandbox adapter intentionally behaves differently from sandboxd. Anything not listed here is a bug.

The adapter ([`crates/axed/src/adapters/agent_sandbox`](https://github.com/vincent0426/axe/tree/main/crates/axed/src/adapters/agent_sandbox), on by default, off with `--agent-sandbox=false`) implements the Kubernetes Agent Sandbox runtime API as defined by `packages/sandboxd` in [kubernetes-sigs/agent-sandbox](https://github.com/kubernetes-sigs/agent-sandbox). [Agent Sandbox API](https://axe-engine.mintlify.site/reference/agent-sandbox-api.md) documents it in full.

The protos in [`proto/process`](https://github.com/vincent0426/axe/tree/main/proto/process) and [`proto/watcher`](https://github.com/vincent0426/axe/tree/main/proto/watcher) are copied unchanged from upstream.

## Processes

| Behavior | sandboxd | axed | Why |
| - | - | - | - |
| `Execute` output with no configured limit | Buffered without bound | Capped at 256 MiB per stream; exceeding it returns `RESOURCE_EXHAUSTED`, the same code sandboxd uses for policy truncation | One command must not exhaust daemon memory |
| Output held open by background jobs after the command exits | `Execute` and `ExecuteWithLimits` wait up to 10 seconds (5 with a time limit), then kill the command's process group and fail with `INTERNAL` `command output pipes did not finish draining`. `Start` waits up to 5 seconds, then reports the exit | All wait up to 5 seconds, then report the exit with the output read so far and leave the jobs running | A background job that inherits stdout is common (`server &`) and does not make the command fail |
| `--stream-chunk-size` | Default `0`, which selects 4096 bytes | Default `0`, which selects 64 KiB. The value is a ceiling on one read from the process; chunks are whatever one read returns, up to it | Fewer messages for bulk output. Clients never depend on chunk boundaries |
| `TERM` for PTY processes | Inherited only | Set to `xterm-256color` when neither the request nor the daemon environment sets it | Interactive programs misbehave without `TERM` |
| `oom_score_adj` of processes | Inherited from the daemon | Each process raises its own to `--child-oom-score-adj` (default `500`) before it execs, and axed lowers its own to `-900` when it has `CAP_SYS_RESOURCE` | The kernel's OOM killer must pick a runaway command, not the daemon that is often PID 1 |
| Request messages over 4 MiB, such as a huge environment | `RESOURCE_EXHAUSTED` from grpc-go | `OUT_OF_RANGE` from tonic | Both gRPC libraries refuse the message before the service sees it, each with its own code |
| Concurrent processes | Unbounded | Starts fail with `RESOURCE_EXHAUSTED` once running processes hold the whole `--output-budget` (256 MiB, so 256 processes at the default 1 MiB `--retain`) or number `--max-processes` (1024) | Every process reserves its retained output up front, so memory stays bounded |
| Output buffered by concurrent `Execute` calls | Unbounded | All running unary executions share `--capture-budget` (256 MiB). Output past it is truncated, so `Execute` fails with `RESOURCE_EXHAUSTED` | Responses are buffered whole, so their total must be bounded |
| Malformed commands | A NUL byte in an argument or variable fails with `INTERNAL` or `NOT_FOUND`; an empty program name with `INTERNAL` `exec: no command` | A NUL byte fails with `INVALID_ARGUMENT` before anything starts; an empty program name with `PERMISSION_DENIED`, as `execvp` reports it | axed checks the command before it starts the process and reports what the kernel said |
| `WriteStdin` after `eof` on a pipe | Input fails with `INTERNAL` `file already closed`, and so does a second `eof` | Input fails with `FAILED_PRECONDITION`; a second `eof` succeeds | Writing to closed stdin is a caller error, not a server fault, and SDKs retry `INTERNAL` |
| Errors on the adapter's gRPC services and REST API | A code and message | The same code, and on REST the same HTTP status. The message can be worded differently, for example `cwd: path traversal outside sandbox root is forbidden` where sandboxd says `cwd: access denied: path "../../etc": path escapes sandbox root`, or `path does not exist under the root` where sandboxd says `path does not exist within the sandbox`. The errors listed in [Reasons](https://axe-engine.mintlify.site/reference/errors.md#reasons) also carry a `google.rpc.ErrorInfo` detail | One mapping for every API. Clients branch on the code, not the text |

## Filesystem REST API

| Behavior | sandboxd | axed | Why |
| - | - | - | - |
| `EACCES` while resolving a path | 500 `INTERNAL` | 403 `PERMISSION_DENIED` | A permission error is not a server fault, and SDKs retry 500s |
| A symlink loop while resolving a path | 500 `INTERNAL` | 400 `INVALID_ARGUMENT` `too many levels of symbolic links` | The path is at fault, not the server, and SDKs retry 500s |
| Paths that are not valid UTF-8 once percent-decoded | Used as raw bytes | 400 `INVALID_ARGUMENT` `path is not valid UTF-8` | Listings and watch events report such names with U+FFFD in both daemons, so no client can name them anyway; a recursive `DELETE` of the parent removes them |
| Paths longer than `PATH_MAX` (4096 bytes) | 400 `INVALID_ARGUMENT`, also when extracting an archive | Accepted when each component fits in 255 bytes and a request path is at most 256 directories deep; archive entries may be deeper | Resolution opens one component at a time, so the kernel limits only components |
| Literal `.` or `..` segments in the URL, and `/v1/files` without the trailing slash | 307 redirect from Go's router | Cleaned lexically, then the normal rules apply (`../` above the root is 403); `/v1/files` is the root | No redirect for clients that refuse redirects |
| Temporary files during upload | `.sandboxd-tmp-*` visible in the target directory, and seen by watchers | Unnamed `O_TMPFILE`, invisible until commit. Falls back to `.axe-tmp-*` on filesystems without `O_TMPFILE`; and `extract=tar` always writes entries through `.axe-tmp-*` files, which listings show until commit; watchers do not report either | Partial uploads stay invisible and crashes leave no temporary files |
| `DELETE` with an invalid `recursive` value on a missing path | 404 | 400 | axed validates parameters before it touches the filesystem |
| Malformed request details | A `Content-Type` of `multipart/form-data` with a parameter missing its `=`, or with a space before `;`, stores the body as the file. A bad percent-escape such as `%zz` gets a plain-text 400. `max_depth` above the largest signed 64-bit integer gets 400 | The first is refused with 400, the second gets a JSON 400, and `max_depth` is accepted up to 2^64−1 | Each HTTP stack parses malformed input its own way; the status is the same or the request was invalid anyway |
| Path resolution | Resolves symlinks, checks the prefix, then opens the path by name | Resolves one component at a time through held directory descriptors | A symlink swapped in during a request cannot redirect it |
| `--http-idle-timeout` | Closes idle HTTP/1 keep-alive connections. Request headers must arrive within a fixed 10 seconds | Same, and also closes connections stalled mid-transfer and HTTP/2 connections with no request open that receive only keepalive pings. It is also the time allowed for request headers | A stalled or idle client would otherwise hold a connection slot and a file descriptor indefinitely |
| Listing size | Limited by entry count for recursive listings | Also fails with 400 once the returned names add up to more than 32 MiB, and a listing of direct children fails with 400 past 1,048,576 entries in the directory | Names are full relative paths, so a deep tree's listing grows with depth squared |
| Archive metadata on extract | Go's `archive/tar` reads PAX and long-name records up to 1 MiB each | At most 32 KiB of header and metadata records per entry, else 413 | The tar reader holds each record in memory whole |

## Watcher

| Behavior | sandboxd | axed | Why |
| - | - | - | - |
| Detecting removal of the watched directory | Watches the parent directory | Uses the directory's own `IN_DELETE_SELF` and `IN_MOVE_SELF` | No events from siblings, no parent watch to maintain |
| Events per batch | Everything read in the window | About 4,096 at most; a flood backs up in the kernel's queue, which reports an overflow error if it fills | Bounds the daemon's memory per watch |

## Command line

axed takes sandboxd's command line as Go parses it. That covers every sandboxd flag, with the same defaults (though `--stream-chunk-size`'s default of `0` selects a larger size; see [Processes](#processes)), single-dash flags (`-root-dir`), Go durations (`1.5s`, `0`), hostnames and the empty string for `--listen-host`, `--version`, and controller-runtime's `--zap-devel`, `--zap-encoder` and `--zap-log-level`. axed accepts `--zap-stacktrace-level` and `--zap-time-encoding` and ignores them. `--http-idle-timeout=0` disables the idle limit, as in sandboxd. A negative duration such as `-1s` is refused, where Go accepts it. `AXE_LOG` (a tracing filter) overrides the zap level. [axed command line](https://axe-engine.mintlify.site/reference/axed.md) lists every flag.

## Additions

* axed also serves AXE's native API, [`axe.v1`](https://axe-engine.mintlify.site/reference/native-api), on every gRPC listener. It is a separate API with its own string process ids. The adapter numbers only the processes started through its own `Start`, counting up from 1, and `WriteStdin`, `SendSignal` and `ResizeTTY` find only those. Processes started through `axe.v1` or Agent Substrate's API have no integer id.
* With `--agent-substrate`, axed also serves Agent Substrate's guest API. See [Agent Substrate API](https://axe-engine.mintlify.site/reference/agent-substrate-api.md).
* With `--mcp-listen`, axed also serves the Model Context Protocol at `/mcp` on separate endpoints. See [Agents over MCP](https://axe-engine.mintlify.site/deploy/mcp.md).
* New flags: `--listen`, `--mcp-listen`, `--agent-sandbox`, `--agent-substrate`, `--on-sigterm`, `--cgroups`, `--retain`, `--max-retain`, `--max-finished`, `--output-budget`, `--capture-budget`, `--max-processes`, `--grpc-idle-timeout`, `--log-format`, `--child-oom-score-adj`, `--default-user`, and the policies `--default-timeout`, `--default-memory`, `--default-max-tasks`, `--max-timeout` and `--max-memory`. The policies and `--default-user` are off by default, so the adapter behaves as sandboxd does unless you set them. `--rest-port 0` lets the kernel pick a port.
* `--auth-token-file` is reloaded when the file changes and on `SIGHUP`, with the previous token accepted for 60 seconds. sandboxd reads it once at startup.
* The REST port also serves HTTP/2 without TLS (h2c). sandboxd's serves HTTP/1.1 only.
* `GET /readyz` answers like `GET /v1/health`, and `grpc.health.v1` is served on every gRPC listener. Neither needs the token.

[Deploy on Agent Sandbox](https://axe-engine.mintlify.site/deploy/agent-sandbox.md) shows how to swap the image.


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