Skip to content

feat(provider): add acpx provider for any ACP-compatible coding agent#16

Merged
steipete merged 5 commits into
openclaw:mainfrom
mvanhorn:feat/acpx-provider
May 17, 2026
Merged

feat(provider): add acpx provider for any ACP-compatible coding agent#16
steipete merged 5 commits into
openclaw:mainfrom
mvanhorn:feat/acpx-provider

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

  • Adds an acpx provider that routes clawpatch review / fix / revalidate through openclaw/acpx, so any ACP-compatible coding agent (Codex, Claude, Pi, Gemini, OpenClaw ACP) can back a clawpatch run behind one provider name. Defaults to codex as the underlying agent so existing users keep the same behavior; pick a different agent via --model claude, --model pi, or --model claude:sonnet-4-5.
  • One new branch in providerByName plus a small helper trio (runAcpxJson, buildAcpxPrompt, extractAcpxJson) in src/provider.ts. No new runtime dependencies; acpx is a peer CLI like codex.
  • New runCommandRaw in src/exec.ts preserves full stdout for stream-protocol consumers. The existing runCommand keeps its 8 KB trimOutput for short-output CLIs, so codex/mocks are unaffected. acpx's --format json --json-strict emits 200+ NDJSON envelopes per prompt, which would be corrupted by truncation.
  • Permission model is documented honestly. acpx --approve-all is a permission-prompt auto-approver, not an enforced sandbox like codex --sandbox workspace-write. For review / revalidate (--deny-all), the provider also embeds an explicit READ-ONLY directive in the prompt body, and docs/safety.md is updated to reflect that the read-only guarantee for the acpx path depends on the underlying agent's cooperation.
  • NDJSON parser reads agent_message_chunk, agent_thought_chunk, and tool_call_result envelope kinds so the provider works for agents that route final structured output differently (Claude can land it in thought chunks; some configs use tool-call returns). On extraction failure, the diagnostic names the envelope kinds it observed, so an acpx version-shape change surfaces as a clear "envelope shape may have changed" error rather than a silent malformed-output.

Why this matters

The README at line 79 and docs/providers.md line 42 both call out that "Direct OpenAI, Claude, Gemini, and provider panels are not implemented yet." The cheapest path to closing that gap is not to write a Claude provider, a Gemini provider, and a Pi provider one at a time, but to route through openclaw/acpx (the org's existing headless ACP client). This is the same pattern openclaw/mcporter uses for MCP servers: one CLI surface for a whole protocol family.

Selection syntax uses last-colon split on model, so model identifiers that contain colons work cleanly:

model value Agent Model
(null / unset) codex agent default
claude claude agent default
claude:sonnet-4-5 claude sonnet-4-5
pi pi agent default
ollama:llama3:70b ollama:llama3 70b

Migration: --provider codex --model X is NOT equivalent to --provider acpx --model X (the latter selects an agent named X). The correct migration is --provider acpx --model codex:X. docs/providers.md has a dedicated migration note.

Demo

Simulated demo:

acpx provider demo

Empirical validation from the dogfood run: acpx --cwd <root> --deny-all --format json --json-strict codex exec --file <prompt> against a clawpatch review-shaped prompt embedding reviewJsonSchema returned schema-conforming JSON on first try. 256 NDJSON lines, ~19s, concatenated agent_message_chunk.content.text parsed cleanly into {findings, inspected}.

Testing

  • corepack pnpm typecheck
  • corepack pnpm lint
  • corepack pnpm test — 126 tests pass; new src/provider.test.ts covers extractAcpxJson for codex / claude (thought-chunk) / tool-call shapes, json fence stripping, prose-preamble tolerance, the malformed-output diagnostic paths, and a 256-line NDJSON fixture >8KB as a regression guard for the runCommandRaw path.
  • Manual dogfood (recorded in the simulated demo above): the acpx provider returned schema-conforming JSON on a fixture repo without contacting Codex.

mvanhorn and others added 5 commits May 16, 2026 08:29
Routes review/fix/revalidate through openclaw/acpx so clawpatch can use
Codex, Claude, Pi, Gemini, or any other ACP-compatible coding agent
behind one provider name. Defaults to codex as the underlying agent so
existing users keep working unchanged; select a different agent via
`--model claude`, `--model pi`, or `--model claude:sonnet-4-5`.

The new `runCommandRaw` exec helper preserves full stdout for
stream-protocol consumers; the existing `runCommand` still truncates
output > 8KB, so existing callers are unaffected.

The NDJSON parser reads agent_message_chunk, agent_thought_chunk, and
tool_call_result envelopes so non-codex agents that route final output
differently still work. The malformed-output diagnostic names the
observed envelope kinds so acpx-version-shape drift is diagnosable
rather than silent.
…mode caveat

acpx --deny-all denies ACP permission prompts but does not force the
underlying agent into a read-only sandbox. Agents in their own
full-access mode that bypass ACP permissions could still write to the
workspace during review/revalidate.

Add an explicit READ-ONLY directive to the prompt body when permission
is deny, and document the limitation in safety.md and providers.md so
the existing read-only contract is preserved where the agent honors
prompt directives, and the residual risk is named for agents that
don't.
# Conflicts:
#	CHANGELOG.md
#	docs/providers.md
#	src/exec.ts
#	src/provider.test.ts
#	src/provider.ts
@steipete steipete merged commit bbd4427 into openclaw:main May 17, 2026
5 checks passed
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Thanks for landing the acpx provider, @steipete. ACP-compatible coverage in clawpatch is a real unlock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants