--- title: Custom agents description: Run any ACP-capable server through acpx — unknown positional names, --agent escape hatch, and config-defined custom agents. --- `acpx` does not require an agent to be in the built-in registry. Any ACP-capable command can be the agent. There are three ways to use a custom agent. ## 1. Unknown positional name On Unix-like systems, a positional agent name that is neither built in nor configured is treated as a raw command: ```bash acpx my-agent 'review this patch' acpx my-agent prompt 'do the thing' acpx my-agent exec 'one-shot ask' acpx my-agent sessions ``` For custom launches on Windows, define a named agent with `argv` as shown below. See [Config](config.md#the-agents-map) for structured argv and interpreter requirements. The literal string `my-agent` becomes the spawn command. This is useful when you have an ACP server already on `PATH` under a name that is not a built-in. ## 2. `--agent ` escape hatch On Unix-like systems, use `--agent` for ad-hoc raw commands or paths with arguments and quoting: ```bash acpx --agent ./bin/my-custom-acp-server 'do something' acpx --agent 'node ./scripts/acp-dev-server.mjs --mode ci' exec 'summarize changes' ``` Rules: - Do not combine `--agent` with a positional agent token in the same command. That is a usage error. - The resolved command string becomes the session scope key (`agentCommand`). Two different command strings are two different sessions, even if the underlying binary is the same. - Empty commands and unterminated quoting are rejected as usage errors. ## 3. Config-defined agents For commands you use repeatedly, define them in [`~/.acpx/config.json`](config.md#the-agents-map): ```json { "agents": { "ci-bot": { "argv": ["node", "./scripts/ci-acp-bridge.mjs", "--profile", "internal"] } } } ``` Then call by friendly name: ```bash acpx ci-bot sessions new acpx ci-bot 'run validation checks' ``` Custom names defined in config win over the built-in registry, so you can also override `codex`, `claude`, etc. with a vendored adapter. ## Session scope and the agent command The agent command — whether built-in, unknown positional, `--agent`, or config-defined — is part of the session scope key: ```text (agentCommand, absoluteCwd, optional name) ``` Switching from `acpx --agent ./bin/v1` to `acpx --agent ./bin/v2` changes the session scope. A friendly config name is a shortcut, not the stored session identity: changing its configured executable or arguments can select a different scope. Keep the resolved command unchanged during an upgrade—for example, update the binary behind a stable executable path—to retain the same local scope. Resuming its conversation still depends on the adapter supporting the saved session. ## ACP requirements for custom agents A custom agent must: - Speak ACP over stdio. - Implement `initialize`, `session/new`, `session/prompt`, and `session/cancel`. - Advertise optional capabilities honestly. Session reopening requires `session/resume` or `session/load`. Closing a remote session requires `session/close`. Fresh-session-only agents can omit these capabilities. - Advertise `agentCapabilities` and model controls honestly. Prefer a categorized model config option for ACP 0.25; existing adapters may continue to return legacy `models` metadata and implement `session/set_model`. `fs/*` and `terminal/*` client methods are routed through acpx's permission policy. File operations apply cwd containment checks; terminal commands are not an OS sandbox. See [Permissions](permissions.md#working-directory-and-filesystem-guardrails) for the filesystem guarantees and limitations. ### Troubleshooting `session/new` Some ACP servers require their own project or workspace mapping before they can create a session. If `sessions new` or `sessions ensure` fails at `session/new` for a custom server, verify the server-side project initialization first, then retry with the same cwd and explicit environment you expect the server to see. ## Practical examples Local dev server with arguments: ```bash acpx --agent 'node --inspect ./scripts/dev-acp.mjs --port 5555' sessions new acpx --agent 'node --inspect ./scripts/dev-acp.mjs --port 5555' 'run a sanity check' ``` Per-repo override with config: `/.acpxrc.json`: ```json { "agents": { "internal": { "command": "/opt/internal/acp-bridge", "args": ["--profile", "stable"] } } } ``` Then everywhere in that repo: ```bash acpx internal sessions new acpx internal 'review the latest commit' acpx internal exec 'list TODO comments' ``` ### OpenClaw checkout On Unix, override the built-in profile to run a source checkout directly. Replace both absolute paths below with your checkout and token file. The bridge starts in the selected project directory, so a relative script path would resolve there. ```json { "agents": { "openclaw": { "command": "env OPENCLAW_HIDE_BANNER=1 OPENCLAW_SUPPRESS_NOTES=1 node /path/to/openclaw/scripts/run-node.mjs acp --url ws://127.0.0.1:18789 --token-file /path/to/gateway.token --session agent:main:main" } } } ``` ## See also - [Agents](agents.md) — built-in registry. - [Config](config.md) — the `agents` map and precedence rules. - [Sessions](sessions.md) — how the agent command participates in scope keys. ## Incoming message limits Each incoming ACP transport line is limited to **64 MiB (67,108,864 bytes)** by default. `ACPX_MAX_ACP_MESSAGE_BYTES` overrides that limit with a non-negative safe integer number of bytes: - Unset, empty, or whitespace-only: use the 64 MiB default. - Positive value: use that limit; for example, `134217728` allows 128 MiB. - `0`: explicitly disable the limit and allow unlimited input. The limit counts raw UTF-8 bytes before decoding, excluding the terminating LF but including a preceding CR and other whitespace. It applies to complete messages and unfinished lines alike, regardless of how stdout chunks are split. Multiple individually valid messages can arrive in a combined read larger than the limit. Choose a limit large enough for image and other structured responses. Overflow fails the connection with `ACP_MESSAGE_TOO_LARGE` and explains how to raise or disable the limit; invalid settings fail before an agent process is spawned. A warm owner keeps the setting with which its ACP connection was started, so restart it to pick up a new value or default. This is a per-message limit, not a process-memory or model-token budget; decoding and JSON parsing may use more memory than the serialized message size. It does not limit outgoing ACP prompts, queue requests, or shell output capture.