···11+# ACP
22+33+This page describes the user-facing ACP support now available in Mistermorph.
44+55+## What It Is
66+77+Mistermorph can delegate one isolated subtask to an external ACP agent.
88+99+Today that means:
1010+1111+- Mistermorph acts as an ACP client.
1212+- The external agent runs as a local child process over `stdio`.
1313+- The parent agent uses the explicit `acp_spawn` tool to start that subtask.
1414+1515+This is separate from `spawn`.
1616+1717+- `spawn` starts another local Mistermorph agent loop.
1818+- `acp_spawn` starts an external ACP-compatible agent or adapter.
1919+2020+## Current Scope
2121+2222+The current implementation is intentionally narrow:
2323+2424+- client-only; Mistermorph is not an ACP server
2525+- `stdio` transport only
2626+- one synchronous session per call
2727+- one prompt turn per call
2828+- text prompts only
2929+- `authenticate` when the agent advertises auth methods
3030+- `session/set_config_option` when `session/new` advertises config option ids
3131+- client callbacks for:
3232+ - `session/request_permission`
3333+ - `fs/read_text_file`
3434+ - `fs/write_text_file`
3535+ - `terminal/create`
3636+ - `terminal/output`
3737+ - `terminal/wait_for_exit`
3838+ - `terminal/kill`
3939+ - `terminal/release`
4040+4141+Not supported yet:
4242+4343+- MCP passthrough
4444+- session reuse
4545+- HTTP / SSE transport
4646+- interactive approval UI
4747+4848+## Config
4949+5050+ACP support has two config surfaces:
5151+5252+1. Enable the explicit tool entry.
5353+2. Define one or more ACP agent profiles.
5454+5555+Example:
5656+5757+```yaml
5858+tools:
5959+ acp_spawn:
6060+ enabled: true
6161+6262+acp:
6363+ agents:
6464+ - name: "codex"
6565+ enable: true
6666+ type: "stdio"
6767+ command: "codex-acp"
6868+ args: []
6969+ env: {}
7070+ cwd: "."
7171+ read_roots: ["."]
7272+ write_roots: ["."]
7373+ session_options:
7474+ mode: "auto"
7575+ reasoning_effort: "low"
7676+```
7777+7878+Field notes:
7979+8080+- `tools.acp_spawn.enabled` controls only the explicit `acp_spawn` tool entry.
8181+- `acp.agents[].name` is the profile name the parent agent uses.
8282+- `cwd`, `read_roots`, and `write_roots` constrain ACP file and terminal callbacks.
8383+- `session_options` is passed into `session/new._meta`.
8484+- If the ACP agent advertises config option ids in `session/new`, matching keys from `session_options` are also sent through `session/set_config_option`.
8585+8686+## How to Use It
8787+8888+At runtime, the parent agent must explicitly choose `acp_spawn`.
8989+9090+Typical prompt:
9191+9292+```text
9393+Only call acp_spawn. Use the codex agent. Read ./README.md and summarize it in exactly 5 Chinese sentences. Do not call spawn. Do not read the file yourself.
9494+```
9595+9696+The `acp_spawn` parameters are:
9797+9898+- `agent`: ACP profile name
9999+- `task`: task text for the external agent
100100+- `cwd`: optional working-directory override
101101+- `output_schema`: optional structured-output label
102102+- `observe_profile`: optional local observation hint
103103+104104+The result comes back in the same `SubtaskResult` envelope used by other isolated task paths.
105105+106106+## Execution Model
107107+108108+One `acp_spawn` call does this:
109109+110110+1. load the ACP profile
111111+2. start the wrapper process
112112+3. `initialize`
113113+4. `authenticate` if needed
114114+5. `session/new`
115115+6. `session/set_config_option` for advertised option ids
116116+7. `session/prompt`
117117+8. serve ACP callbacks during the turn
118118+9. collect final text and stop reason
119119+10. close the session/process
120120+121121+This means the parent agent does not need to know whether the child path was local `spawn` or ACP `acp_spawn`. Both return the same top-level envelope.
122122+123123+## Security and Limits
124124+125125+Two limits matter here.
126126+127127+First, ACP permission requests are not the real security boundary. The real boundary is what Mistermorph actually implements in its client callbacks:
128128+129129+- allowed file roots
130130+- allowed terminal working directories
131131+- local write and process rules
132132+133133+Second, the wrapper process itself is still a local child process.
134134+135135+That means:
136136+137137+- ACP callback limits apply to ACP method calls
138138+- they do not automatically sandbox arbitrary direct behavior inside the wrapper itself
139139+140140+So ACP support should be treated as controlled delegation, not a hard sandbox.
141141+142142+## Codex Adapter Notes
143143+144144+Current Codex integration is based on an external ACP adapter such as `codex-acp`.
145145+146146+Practical checks:
147147+148148+1. `codex` itself must already work on the machine.
149149+2. `mistermorph tools` should show `acp_spawn`.
150150+3. the ACP profile should point to `codex-acp`.
151151+152152+The repository also includes an opt-in live integration test:
153153+154154+```bash
155155+MISTERMORPH_ACP_CODEX_INTEGRATION=1 go test ./internal/acpclient -run TestRunPrompt_CodexACPIntegration -v
156156+```
157157+158158+## See Also
159159+160160+- [Tools](./tools.md)
161161+- [Configuration](./configuration.md)
162162+- [Feature Design](./feat/feat_20260410_acp_agent_support.md)
163163+- [Implementation Progress](./feat/feat_20260410_acp_agent_support_impl.md)
···11+---
22+title: ACP
33+description: Use external ACP agents through acp_spawn.
44+---
55+66+# ACP
77+88+Mister Morph can delegate one isolated task to an external ACP agent.
99+1010+Today, ACP support is intentionally narrow:
1111+1212+- Mister Morph is an ACP client, not an ACP server.
1313+- Transport is `stdio` only.
1414+- Each `acp_spawn` call creates one synchronous session and one prompt turn.
1515+- The external agent is started from `acp.agents`.
1616+1717+## When to Use ACP
1818+1919+Use ACP when the child task should run inside an external agent stack instead of another local Mister Morph loop.
2020+2121+Typical examples:
2222+2323+- run Codex through an ACP adapter
2424+- run another ACP-compatible coding agent
2525+- keep the parent loop simple while delegating file edits or command execution to a specialized external agent
2626+2727+If you only need another local Mister Morph loop, use [Subagents](/guide/subagents) and `spawn` instead.
2828+2929+## What Is Supported
3030+3131+Current support includes:
3232+3333+- `authenticate` when advertised by the ACP agent
3434+- `session/new`
3535+- `session/set_config_option` for option ids advertised by `session/new`
3636+- `session/prompt`
3737+- `session/request_permission`
3838+- `fs/read_text_file`
3939+- `fs/write_text_file`
4040+- minimal `terminal/*`
4141+4242+Not supported yet:
4343+4444+- MCP passthrough
4545+- session reuse
4646+- HTTP / SSE transport
4747+4848+## Config
4949+5050+You need two pieces of config:
5151+5252+1. enable the explicit tool entry
5353+2. define at least one ACP profile
5454+5555+```yaml
5656+tools:
5757+ acp_spawn:
5858+ enabled: true
5959+6060+acp:
6161+ agents:
6262+ - name: "codex"
6363+ enable: true
6464+ type: "stdio"
6565+ command: "codex-acp"
6666+ args: []
6767+ env: {}
6868+ cwd: "."
6969+ read_roots: ["."]
7070+ write_roots: ["."]
7171+ session_options:
7272+ mode: "auto"
7373+ reasoning_effort: "low"
7474+```
7575+7676+Notes:
7777+7878+- `tools.acp_spawn.enabled` controls only the `acp_spawn` entry.
7979+- `session_options` is first passed through `session/new._meta`.
8080+- If the ACP agent advertises config option ids, matching keys are also sent through `session/set_config_option`.
8181+8282+## Prompt Pattern
8383+8484+Tell the parent agent to use `acp_spawn` explicitly.
8585+8686+Example:
8787+8888+```text
8989+Only call acp_spawn. Use the codex agent. Read ./README.md and summarize it in exactly 5 Chinese sentences. Do not call spawn. Do not read the file yourself.
9090+```
9191+9292+`acp_spawn` accepts:
9393+9494+- `agent`
9595+- `task`
9696+- `cwd`
9797+- `output_schema`
9898+- `observe_profile`
9999+100100+The result comes back in the same `SubtaskResult` envelope used by other isolated task paths.
101101+102102+## Runtime Behavior
103103+104104+One `acp_spawn` call does this:
105105+106106+1. start the configured wrapper process
107107+2. `initialize`
108108+3. `authenticate` if needed
109109+4. `session/new`
110110+5. `session/set_config_option` for advertised options
111111+6. `session/prompt`
112112+7. serve ACP file, permission, and terminal callbacks
113113+8. collect the final assistant text
114114+115115+## Security Notes
116116+117117+ACP callback permissions are not the whole boundary.
118118+119119+The real enforcement happens in the implemented client methods:
120120+121121+- allowed file roots
122122+- allowed terminal working directories
123123+- local write and process rules
124124+125125+Also, the wrapper itself is still a local child process. ACP callback limits do not automatically sandbox arbitrary direct behavior inside that wrapper.
126126+127127+## Codex via Adapter
128128+129129+Current Codex support is meant to work through an ACP adapter such as `codex-acp`.
130130+131131+Practical checks:
132132+133133+1. `codex` itself should already work.
134134+2. `mistermorph tools` should list `acp_spawn`.
135135+3. the ACP profile should point to `codex-acp`.
136136+137137+See also:
138138+139139+- [Subagents](/guide/subagents)
140140+- [Built-in Tools](/guide/built-in-tools)
141141+- [Config Fields](/guide/config-reference)
+12-2
web/vitepress/docs/guide/built-in-tools.md
···1717| Group | When available | Tools |
1818|---|---|---|
1919| Static tools | Available from config alone | `read_file`, `write_file`, `bash`, `url_fetch`, `web_search`, `contacts_send` |
2020-| Engine tools | Available when an agent engine is assembled for a run | `spawn` |
2020+| Engine tools | Available when an agent engine is assembled for a run | `spawn`, `acp_spawn` |
2121| Runtime tools | Available when the LLM or required context is available | `plan_create`, `todo_update` |
2222| Channel-specific tools | Available when the current channel is Telegram / Slack or another concrete channel runtime | `telegram_send_voice`, `telegram_send_photo`, `telegram_send_file`, `message_react` |
2323···73737474For parameter details, result envelope fields, test prompts, and the difference from `bash.run_in_subtask=true`, see [Subagents](/guide/subagents).
75757676+### `acp_spawn`
7777+7878+Starts an external ACP-compatible agent through a configured profile. The parent agent still waits synchronously, but the inner work runs through ACP instead of another local Mister Morph loop.
7979+8080+- Key limits: can be disabled via `tools.acp_spawn.enabled`; requires a matching profile under `acp.agents`; current transport is `stdio` only.
8181+- Current behavior: one `acp_spawn` call creates one ACP session, serves file and terminal callbacks, and returns the same `SubtaskResult` envelope shape as other isolated task paths.
8282+8383+For profile config, runtime behavior, and practical Codex adapter notes, see [ACP](/guide/acp).
8484+7685## Runtime Tools
77867887These tools are injected dynamically while the agent is running.
···136145 read_file: ...
137146 write_file: ...
138147 spawn: ...
148148+ acp_spawn: ...
139149 bash: ...
140150 url_fetch: ...
141151 web_search: ...
···144154 plan_create: ...
145155```
146156147147-Console Setup / Settings and the `/api/settings/agent` payload use the same nested shape, for example `tools.spawn.enabled`.
157157+Console Setup / Settings and the `/api/settings/agent` payload use the same nested shape, for example `tools.spawn.enabled` and `tools.acp_spawn.enabled`.
148158149159For the full configuration, see [Config Reference](/guide/config-reference.md).
···1212- A shell command is slow or noisy, and you want its output isolated from the parent loop.
1313- The work is still multi-step, but you want the inner execution to operate with a narrower tool set.
1414- You want one compact final result instead of leaking raw intermediate output back to the parent.
1515+- The child work should run inside an external ACP-compatible agent instead of another local Mister Morph loop.
15161617Choose the entry like this:
1718···21222223## Overview
23242424-Mistermorph currently exposes two explicit subagent entries:
2525+Mistermorph currently exposes three isolated-task entries:
25262627| Entry | Starts another LLM loop | Best for | Returns |
2728|---|---|---|---|
2829| `spawn` | Yes | an inner agent that still needs tools and reasoning | `SubtaskResult` JSON envelope |
3030+| `acp_spawn` | No local inner Mister Morph loop; starts an external ACP session instead | an external ACP-compatible agent or adapter | `SubtaskResult` JSON envelope |
2931| `bash.run_in_subtask=true` | No | one shell command with isolated execution/output | `SubtaskResult` JSON envelope |
30323133Shared behavior:
32343333-- Both are synchronous. The parent waits until the inner run finishes.
3434-- Both share the same depth limit.
3535-- Both return the same top-level envelope shape.
3535+- All three are synchronous. The parent waits until the inner run finishes.
3636+- All three share the same depth limit.
3737+- All three return the same top-level envelope shape.
3638- Neither path sends the raw inner transcript back into the parent loop by default.
37394040+ACP-specific note:
4141+4242+- `acp_spawn` still creates an inner agent boundary, but that boundary is handled by an external ACP agent process rather than another local Mister Morph engine.
4343+3844This feature is about isolation and result collection. It is not a background job system yet.
39454046## Current Implementation
···5864- If no usable tool remains, the call fails.
5965- `spawn` is never re-exposed inside the inner agent, even if listed in `tools`.
60666767+### `acp_spawn`
6868+6969+`acp_spawn` is also an engine-scoped tool.
7070+7171+Parameters:
7272+7373+- `agent`: required ACP profile name from `acp.agents`
7474+- `task`: required prompt for the external ACP agent
7575+- `cwd`: optional working-directory override
7676+- `output_schema`: optional structured-output label
7777+- `observe_profile`: optional observer hint
7878+7979+Current behavior:
8080+8181+- one call creates one ACP session
8282+- the current implementation uses `stdio` transport only
8383+- the child path can serve ACP permission, file, and terminal callbacks
8484+- the final result is normalized into the same `SubtaskResult` envelope used by `spawn`
8585+8686+For profile config and transport details, see [ACP](/guide/acp).
8787+6188### `bash.run_in_subtask=true`
62896390This is the lighter isolated-execution path.
···9011791118### Result Envelope
921199393-Both entries return JSON in this shape:
120120+All three entries return JSON in this shape:
9412195122```json
96123{
···158185### Config and Embedding
159186160187- `tools.spawn.enabled` controls only the explicit `spawn` tool entry.
188188+- `tools.acp_spawn.enabled` controls only the explicit `acp_spawn` tool entry.
189189+- ACP profiles live under `acp.agents`.
161190- Direct isolated runs such as `bash.run_in_subtask=true` still work even if `tools.spawn.enabled=false`.
162162-- `integration.Config.BuiltinToolNames` can include or omit `spawn`.
163163-- If you build an engine directly with `agent.New(...)`, `spawn` is enabled by default. Disable it with `agent.WithSpawnToolEnabled(false)`.
191191+- `integration.Config.BuiltinToolNames` can include or omit `spawn` and `acp_spawn`.
192192+- If you build an engine directly with `agent.New(...)`, `spawn` is enabled by default and `acp_spawn` is disabled by default. Override them with `agent.WithSpawnToolEnabled(...)`, `agent.WithACPSpawnToolEnabled(...)`, and `agent.WithACPAgents(...)`.
164193165194Example:
166195167196```go
168197cfg := integration.DefaultConfig()
169169-cfg.BuiltinToolNames = []string{"read_file", "url_fetch", "spawn"}
198198+cfg.BuiltinToolNames = []string{"read_file", "url_fetch", "spawn", "acp_spawn"}
170199cfg.Set("tools.spawn.enabled", true)
200200+cfg.Set("tools.acp_spawn.enabled", true)
171201```
172202173203See also:
174204175205- [Built-in Tools](/guide/built-in-tools)
206206+- [ACP](/guide/acp)
176207- [Create Your Own AI Agent: Advanced](/guide/build-your-own-agent-advanced)
177208- [Config Fields](/guide/config-reference)