Skip to content

ACP Agents ​

The Agent Client Protocol (ACP) is an open protocol between clients and coding agents. Instead of starting a CLI, a harness.run step can act as an ACP client: it opens a session, sends the prompt, answers the agent's permission requests, and captures the agent's reply as step stdout.

Select ACP with protocol: acp in a named custom harness definition. The agent runs in one of three places:

transportAgent runsEndpoint
stdio (default)On the Dagu host, as a local adapter processbinary
websocketOn another hostws:// or wss:// URL
httpOn another host, behind ACP Streamable HTTPhttp:// or https:// URL

Local Adapter ​

Install and authenticate an ACP adapter on the host that runs the step, such as codex-acp from npm install -g @agentclientprotocol/codex-acp:

yaml
working_dir: /srv/repos/app

harnesses:
  coding-agent:
    protocol: acp
    binary: codex-acp

steps:
  - id: review
    action: harness.run
    with:
      provider: coding-agent
      prompt: Summarize the modules in this repository without modifying files.
    output: REVIEW
  • The adapter process inherits the step's environment, working directory, and resource limits. The session's working directory is the step's.
  • binary, prefix_args, flag_style, and option_flags control how the adapter starts. Other with keys become adapter CLI flags, as described in Passing Options.
  • The prompt travels over the protocol, so ACP definitions reject prompt_mode, prompt_flag, and prompt_position. with.stdin is appended to the prompt after a blank line.

Remote Agent ​

A remote definition connects to an agent that another host runs. It needs a url and cwd, the absolute working directory on the agent host:

yaml
working_dir: /srv/repos/app

harnesses:
  remote-agent:
    protocol: acp
    transport: websocket          # http for an ACP Streamable HTTP endpoint
    url: wss://acp.example.com/acp
    cwd: /srv/project
    headers:
      Authorization: Bearer ${ACP_TOKEN}

steps:
  - id: review
    action: harness.run
    timeout_sec: 600
    with:
      provider: remote-agent
      prompt: Review the project without modifying files.
    output: REVIEW
  • A remote step accepts only provider, fallback, and acp_permission under with. Any other key fails the step, because a remote agent takes no CLI flags.
  • binary, prefix_args, flag_style, and option_flags are rejected in a remote definition.
  • url, cwd, headers, and ca_file accept workflow variables. A url or cwd with a variable is validated after it resolves.
  • Dagu passes cwd to the agent as written. It never creates or translates the remote directory.
  • Certificate and hostname verification always stay on. ca_file adds PEM roots for this connection, alongside the system roots; a relative path resolves from the step's working directory.
  • Redirects are refused, and network errors omit credentials and response bodies.
  • Headers sent over ws:// or http:// to a non-loopback host produce a warning in the step log.

Keep tokens in secrets rather than in the DAG file.

WebSocket ​

The WebSocket transport offers the acp.v1 subprotocol, sends headers with the upgrade request, and uses ping frames to keep idle connections open through proxies.

Bearer tokens stay in the Authorization header. Set bearer_subprotocol: true only for a bridge that requires the token as a bearer.<token> subprotocol; the token must then be a valid HTTP token, so tokens containing / or = cannot use it.

Streamable HTTP ​

transport: http follows the experimental Streamable HTTP profile of the ACP TypeScript SDK. The endpoint must implement that profile: initialize returns JSON with an Acp-Connection-Id header, later POSTs return 202 Accepted, and replies and agent requests arrive on server-sent event streams. Dagu keeps cookies for affinity and deletes the connection when the step ends. This is not the MCP Streamable HTTP transport.

Definition Fields ​

FieldApplies toDescription
protocolallacp selects ACP; cli or omitted keeps CLI invocation
transportACPstdio (default), websocket, or http
binarystdioAdapter binary name or path; required
prefix_argsstdioArguments placed before generated flags
flag_stylestdiognu_long or single_dash for generated flags
option_flagsstdioExact flag per with key
urlremoteEndpoint: ws:///wss:// for WebSocket, http:///https:// for HTTP; required
cwdremoteAbsolute working directory on the agent host; required
headersremoteRequest headers, such as Authorization
ca_fileremoteExtra PEM certificate roots for this connection
bearer_subprotocolWebSocketAlso send the bearer token as a bearer.<token> subprotocol; default false

Permissions ​

ACP agents ask the client before running tools that need approval. with.acp_permission sets the answer:

ValueBehavior
deny (default)Selects the agent's reject option and fails the attempt, even if the agent then ends its turn normally
allowSelects an offered allow_once option; never grants persistent approval

With allow, a request that offers no allow_once option is still rejected and fails the attempt.

yaml
working_dir: /srv/repos/app

harnesses:
  coding-agent:
    protocol: acp
    binary: codex-acp

steps:
  - id: fix
    action: harness.run
    with:
      provider: coding-agent
      acp_permission: allow
      prompt: Fix the failing unit test.

This policy answers the protocol's permission requests only. It is not a sandbox around the agent's own tools; use a remote host or the agent's own sandbox settings for isolation.

Output ​

The agent's message text becomes step stdout, so it works with output:, outputs:, and output_schema. Protocol messages, thoughts, and tool events are left out. The step succeeds only when the agent ends its turn with end_turn; any other stop reason, such as a refusal, fails the attempt.

Each execution opens a new session.

DAG-Level Defaults ​

DAG-level harness: defaults apply to ACP steps, with two differences:

  • A remote ACP step inherits only provider and acp_permission, also when a variable such as ${PROVIDER} selects the provider.
  • acp_permission affects only ACP steps. CLI providers never receive it as a flag, so one DAG can set it alongside CLI steps.
yaml
working_dir: /srv/repos/app

harnesses:
  remote-agent:
    protocol: acp
    transport: http
    url: https://acp.example.com/acp
    cwd: /srv/project

harness:
  provider: claude
  model: sonnet
  acp_permission: allow

steps:
  - id: local_review
    action: harness.run
    with:
      prompt: Review the staged changes.

  - id: remote_review
    action: harness.run
    with:
      provider: remote-agent
      prompt: Review the deployment manifests.

local_review runs Claude Code with --model sonnet. remote_review gets acp_permission: allow but not model.

Stopping and Timeouts ​

EventBehaviorExit code
StopSends session/cancel and waits for the agent to end its turn143, or 128 + the signal number
Forced stop, including when max_clean_up_time_sec elapsesSends session/cancel, then ends the local process tree or closes the remote connection137
timeout_sec reachedSends session/cancel, then interrupts the transport124

A stop skips the remaining fallback providers, even when it arrives while the agent is still starting. A remote agent must honor session/cancel; Dagu closes the connection but does not own the remote process.

When a local adapter crashes or exits after a failed turn, the step keeps the adapter's exit code, so retry_policy and continue_on rules can match it. Recent adapter stderr is included in the error.

Fallbacks ​

ACP and CLI providers can share one fallback list. Text from a failed attempt never reaches the output of a later successful attempt.

yaml
working_dir: /srv/repos/app

harnesses:
  coding-agent:
    protocol: acp
    binary: codex-acp

steps:
  - id: review
    action: harness.run
    with:
      provider: coding-agent
      prompt: Review this repository.
      fallback:
        - provider: claude

Limits ​

  • Adapters must be installed and authenticated beforehand; interactive authentication is not available.
  • ACP steps cannot run in a container. A step-level container: fails the step; a DAG-level container: fails local adapters and is ignored by remote agents.
  • The client does not offer filesystem or terminal callbacks to the agent.
  • Sessions are not resumed, and a dropped connection is not reconnected or replayed.
  • ACP agents do not report model usage; the step records the provider under notReported.

Need one of these? Request it.

Dagu is open source under the GNU General Public License v3.0.