ACP Harness Router
When user intent is "run this in Pi/Claude Code/Codex/OpenCode/Gemini/Kimi (ACP harness)", do not use subagent runtime or PTY scraping. Route through ACP-aware flows.
Intent detection
Trigger this skill when the user asks OpenClaw to:
- - run something in Pi / Claude Code / Codex / OpenCode / Gemini
- continue existing harness work
- relay instructions to an external coding harness
- keep an external harness conversation in a thread-like conversation
Mandatory preflight for coding-agent thread requests:
- - Before creating any thread for Pi/Claude/Codex/OpenCode/Gemini work, read this skill first in the same turn.
- After reading, follow
OpenClaw ACP runtime path below; do not use message(action="thread-create") for ACP harness thread spawn.
Mode selection
Choose one of these paths:
- 1. OpenClaw ACP runtime path (default): use
sessions_spawn / ACP runtime tools. - Direct
acpx path (telephone game): use acpx CLI through exec to drive the harness session directly.
Use direct acpx when one of these is true:
- - user explicitly asks for direct
acpx driving - ACP runtime/plugin path is unavailable or unhealthy
- the task is "just relay prompts to harness" and no OpenClaw ACP lifecycle features are needed
Do not use:
- -
subagents runtime for harness control - INLINECODE9 command delegation as a requirement for the user
- PTY scraping of pi/claude/codex/opencode/gemini/kimi CLIs when
acpx is available
AgentId mapping
Use these defaults when user names a harness directly:
- - "pi" -> INLINECODE11
- "claude" or "claude code" -> INLINECODE12
- "codex" -> INLINECODE13
- "opencode" -> INLINECODE14
- "gemini" or "gemini cli" -> INLINECODE15
- "kimi" or "kimi cli" -> INLINECODE16
These defaults match current acpx built-in aliases.
If policy rejects the chosen id, report the policy error clearly and ask for the allowed ACP agent id.
OpenClaw ACP runtime path
Required behavior:
- 1. For ACP harness thread spawn requests, read this skill first in the same turn before calling tools.
- Use
sessions_spawn with:
-
runtime: "acp"
-
thread: true
-
mode: "session" (unless user explicitly wants one-shot)
- 3. For ACP harness thread creation, do not use
message with action=thread-create; sessions_spawn is the only thread-create path. - Put requested work in
task so the ACP session gets it immediately. - Set
agentId explicitly unless ACP default agent is known. - Do not ask user to run slash commands or CLI when this path works directly.
Example:
User: "spawn a test codex session in thread and tell it to say hi"
Call:
CODEBLOCK0
Thread spawn recovery policy
When the user asks to start a coding harness in a thread (for example "start a codex/claude/pi/kimi thread"), treat that as an ACP runtime request and try to satisfy it end-to-end.
Required behavior when ACP backend is unavailable:
- 1. Do not immediately ask the user to pick an alternate path.
- First attempt automatic local repair:
- ensure plugin-local pinned acpx is installed in
extensions/acpx
- verify
${ACPX_CMD} --version
- 3. After reinstall/repair, restart the gateway and explicitly offer to run that restart for the user.
- Retry ACP thread spawn once after repair.
- Only if repair+retry fails, report the concrete error and then offer fallback options.
When offering fallback, keep ACP first:
- - Option 1: retry ACP spawn after showing exact failing step
- Option 2: direct acpx telephone-game flow
Do not default to subagent runtime for these requests.
ACPX install and version policy (direct acpx path)
For this repo, direct acpx calls must follow the same pinned policy as the @openclaw/acpx extension.
- 1. Prefer plugin-local binary, not global PATH:
-
./extensions/acpx/node_modules/.bin/acpx
- 2. Resolve pinned version from extension dependency:
-
node -e "console.log(require('./extensions/acpx/package.json').dependencies.acpx)"
- 3. If binary is missing or version mismatched, install plugin-local pinned version:
-
cd extensions/acpx && npm install --omit=dev --no-save acpx@<pinnedVersion>
- 4. Verify before use:
-
./extensions/acpx/node_modules/.bin/acpx --version
- 5. If install/repair changed ACPX artifacts, restart the gateway and offer to run the restart.
- Do not run
npm install -g acpx unless the user explicitly asks for global install.
Set and reuse:
CODEBLOCK1
Direct acpx path ("telephone game")
Use this path to drive harness sessions without /acp or subagent runtime.
Rules
- 1. Use
exec commands that call ${ACPX_CMD}. - Reuse a stable session name per conversation so follow-up prompts stay in the same harness context.
- Prefer
--format quiet for clean assistant text to relay back to user. - Use
exec (one-shot) only when the user wants one-shot behavior. - Keep working directory explicit (
--cwd) when task scope depends on repo context.
Session naming
Use a deterministic name, for example:
Where conversationId is thread id when available, otherwise channel/conversation id.
Command templates
Persistent session (create if missing, then prompt):
CODEBLOCK2
One-shot:
CODEBLOCK3
Cancel in-flight turn:
CODEBLOCK4
Close session:
CODEBLOCK5
Harness aliases in acpx
- - INLINECODE43
- INLINECODE44
- INLINECODE45
- INLINECODE46
- INLINECODE47
- INLINECODE48
Built-in adapter commands in acpx
Defaults are:
- - INLINECODE49
- INLINECODE50
- INLINECODE51
- INLINECODE52
- INLINECODE53
- INLINECODE54
If ~/.acpx/config.json overrides agents, those overrides replace defaults.
Failure handling
- -
acpx: command not found:
- for thread-spawn ACP requests, install plugin-local pinned acpx in
extensions/acpx immediately
- restart gateway after install and offer to run the restart automatically
- then retry once
- do not ask for install permission first unless policy explicitly requires it
- do not install global
acpx unless explicitly requested
- - adapter command missing (for example
claude-agent-acp not found):
- for thread-spawn ACP requests, first restore built-in defaults by removing broken
~/.acpx/config.json agent overrides
- then retry once before offering fallback
- if user wants binary-based overrides, install exactly the configured adapter binary
- -
NO_SESSION: run ${ACPX_CMD} <agent> sessions new --name <sessionName> then retry prompt. - queue busy: either wait for completion (default) or use
--no-wait when async behavior is explicitly desired.
Output relay
When relaying to user, return the final assistant text output from acpx command result. Avoid relaying raw local tool noise unless user asked for verbose logs.
ACP Harness Router
当用户意图为在Pi/Claude Code/Codex/OpenCode/Gemini/Kimi(ACP harness)中运行此操作时,不要使用子代理运行时或PTY抓取。通过ACP感知流程进行路由。
意图检测
当用户要求OpenClaw执行以下操作时触发此技能:
- - 在Pi / Claude Code / Codex / OpenCode / Gemini中运行某些内容
- 继续现有的harness工作
- 将指令转发给外部编码harness
- 以类似线程对话的方式保持外部harness对话
编码代理线程请求的强制预检:
- - 在创建任何用于Pi/Claude/Codex/OpenCode/Gemini工作的线程之前,在同一轮次中先阅读此技能。
- 阅读后,遵循下面的OpenClaw ACP运行时路径;不要使用message(action=thread-create)来生成ACP harness线程。
模式选择
选择以下路径之一:
- 1. OpenClaw ACP运行时路径(默认):使用sessions_spawn / ACP运行时工具。
- 直接acpx路径(传话游戏):通过exec使用acpx CLI直接驱动harness会话。
当以下任一条件成立时,使用直接acpx路径:
- - 用户明确要求直接使用acpx驱动
- ACP运行时/插件路径不可用或不健康
- 任务只是将提示转发给harness,且不需要OpenClaw ACP生命周期功能
不要使用:
- - subagents运行时来控制harness
- /acp命令委托作为用户的要求
- 当acpx可用时,对pi/claude/codex/opencode/gemini/kimi CLI进行PTY抓取
AgentId映射
当用户直接命名harness时,使用以下默认值:
- - pi -> agentId: pi
- claude或claude code -> agentId: claude
- codex -> agentId: codex
- opencode -> agentId: opencode
- gemini或gemini cli -> agentId: gemini
- kimi或kimi cli -> agentId: kimi
这些默认值与当前acpx内置别名匹配。
如果策略拒绝了所选ID,请清晰报告策略错误,并询问允许的ACP代理ID。
OpenClaw ACP运行时路径
必需行为:
- 1. 对于ACP harness线程生成请求,在调用工具之前,先在同一轮次中阅读此技能。
- 使用sessions_spawn,参数为:
- runtime: acp
- thread: true
- mode: session(除非用户明确想要一次性模式)
- 3. 对于ACP harness线程创建,不要使用带有action=thread-create的message;sessions_spawn是唯一的线程创建路径。
- 将请求的工作放入task中,以便ACP会话立即获取。
- 除非已知ACP默认代理,否则显式设置agentId。
- 当此路径直接工作时,不要要求用户运行斜杠命令或CLI。
示例:
用户:在线程中生成一个测试codex会话,并让它说你好
调用:
json
{
task: 说你好。,
runtime: acp,
agentId: codex,
thread: true,
mode: session
}
线程生成恢复策略
当用户要求在线程中启动编码harness时(例如启动一个codex/claude/pi/kimi线程),将其视为ACP运行时请求,并尝试端到端地满足它。
当ACP后端不可用时的必需行为:
- 1. 不要立即要求用户选择替代路径。
- 首先尝试自动本地修复:
- 确保插件本地固定的acpx已安装在extensions/acpx中
- 验证${ACPX_CMD} --version
- 3. 重新安装/修复后,重启网关并主动为用户运行该重启。
- 修复后重试ACP线程生成一次。
- 仅当修复+重试失败时,报告具体错误,然后提供回退选项。
提供回退时,保持ACP优先:
- - 选项1:显示确切失败步骤后重试ACP生成
- 选项2:直接acpx传话游戏流程
不要默认对这些请求使用子代理运行时。
ACPX安装和版本策略(直接acpx路径)
对于此仓库,直接acpx调用必须遵循与@openclaw/acpx扩展相同的固定策略。
- 1. 优先使用插件本地二进制文件,而非全局PATH:
- ./extensions/acpx/node_modules/.bin/acpx
- 2. 从扩展依赖中解析固定版本:
- node -e console.log(require(./extensions/acpx/package.json).dependencies.acpx)
- 3. 如果二进制文件缺失或版本不匹配,安装插件本地固定版本:
- cd extensions/acpx && npm install --omit=dev --no-save acpx@
- 4. 使用前验证:
- ./extensions/acpx/node_modules/.bin/acpx --version
- 5. 如果安装/修复更改了ACPX工件,重启网关并提供运行重启。
- 除非用户明确要求全局安装,否则不要运行npm install -g acpx。
设置并复用:
bash
ACPXCMD=./extensions/acpx/nodemodules/.bin/acpx
直接acpx路径(传话游戏)
使用此路径驱动harness会话,无需/acp或子代理运行时。
规则
- 1. 使用调用${ACPX_CMD}的exec命令。
- 每次对话复用稳定的会话名称,以便后续提示保持在同一个harness上下文中。
- 优先使用--format quiet以获得干净的助手文本,以便转发回用户。
- 仅当用户想要一次性行为时,才使用exec(一次性)。
- 当任务范围依赖于仓库上下文时,保持工作目录显式(--cwd)。
会话命名
使用确定性名称,例如:
其中conversationId在可用时为线程ID,否则为频道/对话ID。
命令模板
持久会话(如果缺失则创建,然后提示):
bash
${ACPX_CMD} codex sessions show oc-codex- \
|| ${ACPX_CMD} codex sessions new --name oc-codex-
${ACPX_CMD} codex -s oc-codex- --cwd --format quiet
一次性:
bash
${ACPX_CMD} codex exec --cwd --format quiet
取消进行中的轮次:
bash
${ACPX_CMD} codex cancel -s oc-codex-
关闭会话:
bash
${ACPX_CMD} codex sessions close oc-codex-
acpx中的Harness别名
- - pi
- claude
- codex
- opencode
- gemini
- kimi
acpx中的内置适配器命令
默认值为:
- - pi -> npx pi-acp
- claude -> npx -y @zed-industries/claude-agent-acp
- codex -> npx @zed-industries/codex-acp
- opencode -> npx -y opencode-ai acp
- gemini -> gemini
- kimi -> kimi acp
如果~/.acpx/config.json覆盖了agents,这些覆盖将替换默认值。
失败处理
- - acpx: command not found:
- 对于线程生成的ACP请求,立即在extensions/acpx中安装插件本地固定的acpx
- 安装后重启网关,并主动提供自动运行重启
- 然后重试一次
- 除非策略明确要求,否则不要先请求安装权限
- 除非明确要求,否则不要安装全局acpx
- - 适配器命令缺失(例如未找到claude-agent-acp):
- 对于线程生成的ACP请求,首先通过移除损坏的~/.acpx/config.json代理覆盖来恢复内置默认值
- 然后在提供回退前重试一次
- 如果用户想要基于二进制文件的覆盖,则安装配置的适配器二进制文件
- - NOSESSION:运行${ACPXCMD} sessions new --name ,然后重试提示。
- 队列繁忙:要么等待完成(默认),要么在明确需要异步行为时使用--no-wait。
输出转发
转发给用户时,返回来自acpx命令结果的最终助手文本