



























@@ -7,7 +7,7 @@ read_when:
77 - Troubleshooting ACP backend and plugin wiring
88 - Debugging ACP completion delivery or agent-to-agent loops
99 - Operating /acp commands from chat
10-title: "ACP Agents"
10+title: "ACP agents"
1111---
12121313# ACP agents
@@ -32,61 +32,33 @@ There are three nearby surfaces that are easy to confuse:
32323333## Does this work out of the box?
343435-Usually, yes.
35+Usually, yes. Fresh installs ship the bundled `acpx` runtime plugin enabled by default, with a plugin-local pinned `acpx` binary that OpenClaw probes and self-repairs on startup. Run `/acp doctor` for a readiness check.
363637-- Fresh installs now ship the bundled `acpx` runtime plugin enabled by default.
38-- The bundled `acpx` plugin prefers its plugin-local pinned `acpx` binary.
39-- On startup, OpenClaw probes that binary and self-repairs it if needed.
40-- Start with `/acp doctor` if you want a fast readiness check.
37+First-run gotchas:
413842-What can still happen on first use:
43-44-- A target harness adapter may be fetched on demand with `npx` the first time you use that harness.
39+- Target harness adapters (Codex, Claude, etc.) may be fetched on demand with `npx` the first time you use them.
4540- Vendor auth still has to exist on the host for that harness.
46-- If the host has no npm/network access, first-run adapter fetches can fail until caches are pre-warmed or the adapter is installed another way.
47-48-Examples:
49-50-- `/acp spawn codex`: OpenClaw should be ready to bootstrap `acpx`, but the Codex ACP adapter may still need a first-run fetch.
51-- `/acp spawn claude`: same story for the Claude ACP adapter, plus Claude-side auth on that host.
41+- If the host has no npm or network access, first-run adapter fetches fail until caches are pre-warmed or the adapter is installed another way.
524253-## Fast operator flow
43+## Operator runbook
544455-Use this when you want a practical `/acp` runbook:
45+Quick `/acp` flow from chat:
564657-1. Spawn a session:
58-- `/acp spawn codex --bind here`
59-- `/acp spawn codex --mode persistent --thread auto`
60-2. Work in the bound conversation or thread (or target that session key explicitly).
61-3. Check runtime state:
62-- `/acp status`
63-4. Tune runtime options as needed:
64-- `/acp model <provider/model>`
65-- `/acp permissions <profile>`
66-- `/acp timeout <seconds>`
67-5. Nudge an active session without replacing context:
68-- `/acp steer tighten logging and continue`
69-6. Stop work:
70-- `/acp cancel` (stop current turn), or
71-- `/acp close` (close session + remove bindings)
47+1. **Spawn** — `/acp spawn codex --bind here` or `/acp spawn codex --mode persistent --thread auto`
48+2. **Work** in the bound conversation or thread (or target the session key explicitly).
49+3. **Check state** — `/acp status`
50+4. **Tune** — `/acp model <provider/model>`, `/acp permissions <profile>`, `/acp timeout <seconds>`
51+5. **Steer** without replacing context — `/acp steer tighten logging and continue`
52+6. **Stop** — `/acp cancel` (current turn) or `/acp close` (session + bindings)
725373-## Quick start for humans
74-75-Examples of natural requests:
54+Natural-language triggers that should route to the ACP runtime:
76557756- "Bind this Discord channel to Codex."
78-- "Start a persistent Codex session in a thread here and keep it focused."
57+- "Start a persistent Codex session in a thread here."
7958- "Run this as a one-shot Claude Code ACP session and summarize the result."
80-- "Bind this iMessage chat to Codex and keep follow-ups in the same workspace."
8159- "Use Gemini CLI for this task in a thread, then keep follow-ups in that same thread."
826083-What OpenClaw should do:
84-85-1. Pick `runtime: "acp"`.
86-2. Resolve the requested harness target (`agentId`, for example `codex`).
87-3. If current-conversation binding is requested and the active channel supports it, bind the ACP session to that conversation.
88-4. Otherwise, if thread binding is requested and the current channel supports it, bind the ACP session to the thread.
89-5. Route follow-up bound messages to that same ACP session until unfocused/closed/expired.
61+OpenClaw picks `runtime: "acp"`, resolves the harness `agentId`, binds to the current conversation or thread when supported, and routes follow-ups to that session until close/expiry.
90629163## ACP versus sub-agents
9264@@ -124,52 +96,27 @@ For operators, the practical rule is:
1249612597### Current-conversation binds
12698127-Use `/acp spawn <harness> --bind here` when you want the current conversation to become a durable ACP workspace without creating a child thread.
128-129-Behavior:
130-131-- OpenClaw keeps owning the channel transport, auth, safety, and delivery.
132-- The current conversation is pinned to the spawned ACP session key.
133-- Follow-up messages in that conversation route to the same ACP session.
134-- `/new` and `/reset` reset the same bound ACP session in place.
135-- `/acp close` closes the session and removes the current-conversation binding.
136-137-What this means in practice:
138-139-- `--bind here` keeps the same chat surface. On Discord, the current channel stays the current channel.
140-- `--bind here` can still create a new ACP session if you are spawning fresh work. The bind attaches that session to the current conversation.
141-- `--bind here` does not create a child Discord thread or Telegram topic by itself.
142-- The ACP runtime can still have its own working directory (`cwd`) or backend-managed workspace on disk. That runtime workspace is separate from the chat surface and does not imply a new messaging thread.
143-- If you spawn to a different ACP agent and do not pass `--cwd`, OpenClaw inherits the **target agent's** workspace by default, not the requester's.
144-- If that inherited workspace path is missing (`ENOENT`/`ENOTDIR`), OpenClaw falls back to the backend default cwd instead of silently reusing the wrong tree.
145-- If the inherited workspace exists but cannot be accessed (for example `EACCES`), spawn returns the real access error instead of dropping `cwd`.
99+`/acp spawn <harness> --bind here` pins the current conversation to the spawned ACP session — no child thread, same chat surface. OpenClaw keeps owning transport, auth, safety, and delivery; follow-up messages in that conversation route to the same session; `/new` and `/reset` reset the session in place; `/acp close` removes the binding.
146100147101Mental model:
148102149-- chat surface: where people keep talking (`Discord channel`, `Telegram topic`, `iMessage chat`)
150-- ACP session: the durable Codex/Claude/Gemini runtime state OpenClaw routes to
151-- child thread/topic: an optional extra messaging surface created only by `--thread ...`
152-- runtime workspace: the filesystem location where the harness runs (`cwd`, repo checkout, backend workspace)
103+- **chat surface** — where people keep talking (Discord channel, Telegram topic, iMessage chat).
104+- **ACP session** — the durable Codex/Claude/Gemini runtime state OpenClaw routes to.
105+- **child thread/topic** — an optional extra messaging surface created only by `--thread ...`.
106+- **runtime workspace** — the filesystem location (`cwd`, repo checkout, backend workspace) where the harness runs. Independent of the chat surface.
153107154108Examples:
155109156-- `/acp spawn codex --bind here`: keep this chat, spawn or attach a Codex ACP session, and route future messages here to it
157-- `/acp spawn codex --thread auto`: OpenClaw may create a child thread/topic and bind the ACP session there
158-- `/acp spawn codex --bind here --cwd /workspace/repo`: same chat binding as above, but Codex runs in `/workspace/repo`
159-160-Current-conversation binding support:
161-162-- Chat/message channels that advertise current-conversation binding support can use `--bind here` through the shared conversation-binding path.
163-- Channels with custom thread/topic semantics can still provide channel-specific canonicalization behind the same shared interface.
164-- `--bind here` always means "bind the current conversation in place".
165-- Generic current-conversation binds use the shared OpenClaw binding store and survive normal gateway restarts.
110+- `/acp spawn codex --bind here` — keep this chat, spawn or attach Codex, route future messages here.
111+- `/acp spawn codex --thread auto` — OpenClaw may create a child thread/topic and bind there.
112+- `/acp spawn codex --bind here --cwd /workspace/repo` — same chat binding, Codex runs in `/workspace/repo`.
166113167114Notes:
168115169-- `--bind here` and `--thread ...` are mutually exclusive on `/acp spawn`.
170-- On Discord, `--bind here` binds the current channel or thread in place. `spawnAcpSessions` is only required when OpenClaw needs to create a child thread for `--thread auto|here`.
171-- If the active channel does not expose current-conversation ACP bindings, OpenClaw returns a clear unsupported message.
172-- `resume` and "new session" questions are ACP-session questions, not channel questions. You can reuse or replace runtime state without changing the current chat surface.
116+- `--bind here` and `--thread ...` are mutually exclusive.
117+- `--bind here` only works on channels that advertise current-conversation binding; OpenClaw returns a clear unsupported message otherwise. Bindings persist across gateway restarts.
118+- On Discord, `spawnAcpSessions` is only required when OpenClaw needs to create a child thread for `--thread auto|here` — not for `--bind here`.
119+- If you spawn to a different ACP agent without `--cwd`, OpenClaw inherits the **target agent's** workspace by default. Missing inherited paths (`ENOENT`/`ENOTDIR`) fall back to the backend default; other access errors (e.g. `EACCES`) surface as spawn errors.
173120174121### Thread-bound sessions
175122@@ -427,45 +374,19 @@ Notes:
427374- The target agent must support `session/load` (Codex and Claude Code do).
428375- If the session ID isn't found, the spawn fails with a clear error — no silent fallback to a new session.
429376430-### Operator smoke test
377+<Accordion title="Post-deploy smoke test">
431378432-Use this after a gateway deploy when you want a quick live check that ACP spawn
433-is actually working end-to-end, not just passing unit tests.
379+After a gateway deploy, run a live end-to-end check rather than trusting unit tests:
434380435-Recommended gate:
381+1. Verify the deployed gateway version and commit on the target host.
382+2. Open a temporary ACPX bridge session to a live agent.
383+3. Ask that agent to call `sessions_spawn` with `runtime: "acp"`, `agentId: "codex"`, `mode: "run"`, and task `Reply with exactly LIVE-ACP-SPAWN-OK`.
384+4. Verify `accepted=yes`, a real `childSessionKey`, and no validator error.
385+5. Clean up the temporary bridge session.
436386437-1. Verify the deployed gateway version/commit on the target host.
438-2. Confirm the deployed source includes the ACP lineage acceptance in
439-`src/gateway/sessions-patch.ts` (`subagent:* or acp:* sessions`).
440-3. Open a temporary ACPX bridge session to a live agent (for example
441-`razor(main)` on `jpclawhq`).
442-4. Ask that agent to call `sessions_spawn` with:
443-- `runtime: "acp"`
444-- `agentId: "codex"`
445-- `mode: "run"`
446-- task: `Reply with exactly LIVE-ACP-SPAWN-OK`
447-5. Verify the agent reports:
448-- `accepted=yes`
449-- a real `childSessionKey`
450-- no validator error
451-6. Clean up the temporary ACPX bridge session.
387+Keep the gate on `mode: "run"` and skip `streamTo: "parent"` — thread-bound `mode: "session"` and stream-relay paths are separate richer integration passes.
452388453-Example prompt to the live agent:
454-455-```text
456-Use the sessions_spawn tool now with runtime: "acp", agentId: "codex", and mode: "run".
457-Set the task to: "Reply with exactly LIVE-ACP-SPAWN-OK".
458-Then report only: accepted=<yes/no>; childSessionKey=<value or none>; error=<exact text or none>.
459-```
460-461-Notes:
462-463-- Keep this smoke test on `mode: "run"` unless you are intentionally testing
464- thread-bound persistent ACP sessions.
465-- Do not require `streamTo: "parent"` for the basic gate. That path depends on
466- requester/session capabilities and is a separate integration check.
467-- Treat thread-bound `mode: "session"` testing as a second, richer integration
468- pass from a real Discord thread or Telegram topic.
389+</Accordion>
469390470391## Sandbox compatibility
471392@@ -554,30 +475,6 @@ Notes:
554475555476## ACP controls
556477557-Available command family:
558-559-- `/acp spawn`
560-- `/acp cancel`
561-- `/acp steer`
562-- `/acp close`
563-- `/acp status`
564-- `/acp set-mode`
565-- `/acp set`
566-- `/acp cwd`
567-- `/acp permissions`
568-- `/acp timeout`
569-- `/acp model`
570-- `/acp reset-options`
571-- `/acp sessions`
572-- `/acp doctor`
573-- `/acp install`
574-575-`/acp status` shows the effective runtime options and, when available, both runtime-level and backend-level session identifiers.
576-577-Some controls depend on backend capabilities. If a backend does not support a control, OpenClaw returns a clear unsupported-control error.
578-579-## ACP command cookbook
580-581478| Command | What it does | Example |
582479| -------------------- | --------------------------------------------------------- | ------------------------------------------------------------- |
583480| `/acp spawn` | Create ACP session; optional current bind or thread bind. | `/acp spawn codex --bind here --cwd /repo` |
@@ -596,7 +493,7 @@ Some controls depend on backend capabilities. If a backend does not support a co
596493| `/acp doctor` | Backend health, capabilities, actionable fixes. | `/acp doctor` |
597494| `/acp install` | Print deterministic install and enable steps. | `/acp install` |
598495599-`/acp sessions` reads the store for the current bound or requester session. Commands that accept `session-key`, `session-id`, or `session-label` tokens resolve targets through gateway session discovery, including custom per-agent `session.store` roots.
496+`/acp status` shows the effective runtime options plus runtime-level and backend-level session identifiers. Unsupported-control errors surface clearly when a backend lacks a capability. `/acp sessions` reads the store for the current bound or requester session; target tokens (`session-key`, `session-id`, or `session-label`) resolve through gateway session discovery, including custom per-agent `session.store` roots.
600497601498## Runtime options mapping
602499@@ -739,16 +636,9 @@ Then verify backend health:
739636740637### acpx command and version configuration
741638742-By default, the bundled acpx backend plugin (`acpx`) uses the plugin-local pinned binary:
639+By default, the bundled `acpx` plugin uses its plugin-local pinned binary (`node_modules/.bin/acpx` inside the plugin package). Startup registers the backend as not-ready and a background job verifies `acpx --version`; if the binary is missing or mismatched, it runs `npm install --omit=dev --no-save acpx@<pinned>` and re-verifies. The gateway stays non-blocking throughout.
743640744-1. Command defaults to the plugin-local `node_modules/.bin/acpx` inside the ACPX plugin package.
745-2. Expected version defaults to the extension pin.
746-3. Startup registers ACP backend immediately as not-ready.
747-4. A background ensure job verifies `acpx --version`.
748-5. If the plugin-local binary is missing or mismatched, it runs:
749-`npm install --omit=dev --no-save acpx@<pinned>` and re-verifies.
750-751-You can override command/version in plugin config:
641+Override the command or version in plugin config:
752642753643```json
754644{
@@ -766,13 +656,9 @@ You can override command/version in plugin config:
766656}
767657```
768658769-Notes:
770-771-- `command` accepts an absolute path, relative path, or command name (`acpx`).
772-- Relative paths resolve from OpenClaw workspace directory.
659+- `command` accepts an absolute path, relative path (resolved from the OpenClaw workspace), or command name.
773660- `expectedVersion: "any"` disables strict version matching.
774-- When `command` points to a custom binary/path, plugin-local auto-install is disabled.
775-- OpenClaw startup remains non-blocking while the backend health check runs.
661+- Custom `command` paths disable plugin-local auto-install.
776662777663See [Plugins](/tools/plugin).
778664此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。