Skip to content

[Feature]: Implement ACP Server Mode in ZeroClaw #2456

@tucan-tv

Description

@tucan-tv

Summary

Implement a native Agent Control Protocol (ACP) server mode in ZeroClaw to enable seamless integration with ACP-compatible clients, such as the Zed editor and other modern IDEs. This will allow ZeroClaw to act as a high-performance "coding agent" backend.

Problem statement

Currently, ZeroClaw primarily operates as a standalone CLI tool, a gateway for webhooks/websockets, or as an ACP client (via src/channels/acp.rs) to talk to other servers. However, it cannot yet act as an ACP server.

This is insufficient because:

  1. IDE Integration: Users want to use ZeroClaw directly within their code editors (like Zed) as a resident agent.
  2. Protocol Standardization: ACP is emerging as a standard for agent-client interaction (similar to LSP for languages or MCP for tools). Without server-side support, ZeroClaw remains isolated from this ecosystem.
  3. UX Parity: Other agent runtimes (like OpenClaw or Claude Code) support this mode, making ZeroClaw less accessible for developers who prefer IDE-integrated workflows.

Proposed solution

We propose adding a dedicated ACP server mode that communicates via JSON-RPC 2.0 over stdio (and optionally TCP/Unix sockets).

Interfaces & Commands

  • New Command: zeroclaw agent --acp or a dedicated zeroclaw acp subcommand.
  • Transport: Default to stdio for local IDE integration.

Core Protocol Implementation

  1. initialize: Handle the handshake by reporting ZeroClaw's capabilities, version, and supported toolsets.
  2. session/new: Create an isolated agent session with a specific working directory.
  3. session/prompt: Bridge incoming prompts to the existing agent::process_message_with_session logic.
  4. session/stop: Gracefully terminate active sessions.

Real-time Streaming

The server should stream progress back to the client using JSON-RPC notifications or partial results:

  • Reasoning: Stream the agent's "thoughts" (hidden reasoning) as they are generated.
  • Tool Execution: Notify the client when a tool is being called and when it completes.
  • Content: Stream the final response incrementally.

Example Integration (Zed settings.json)

"coding_agents": {
  "zeroclaw": {
    "command": "zeroclaw",
    "args": ["agent", "--acp"]
  }
}

Non-goals / out of scope

  • Implementation of a full MCP server (ZeroClaw should remain an MCP host that uses MCP tools).
  • GUI components within ZeroClaw itself; the UI remains the responsibility of the ACP client (e.g., Zed).
  • Complex multi-agent coordination within a single ACP session (initially).

Alternatives considered

  • Gateway Bridge: Using the existing WebSocket gateway and a wrapper script to convert ACP-to-WS. Rejected: Adds unnecessary latency and complexity compared to a native stdio server.
  • LSP Extension: Implementing a Language Server Protocol (LSP) extension. Rejected: LSP is designed for static analysis and basic refactoring, whereas ACP is specifically designed for autonomous agent control and streaming.

Acceptance criteria

  1. Handshake Success: ZeroClaw responds correctly to initialize and session/new.
  2. Agent Loop Execution: Prompts received via session/prompt trigger the full agent loop, including tool discovery, memory recall, and execution.
  3. Streaming Verification: Clients receive real-time updates for both reasoning and tool calls.
  4. Security Compliance: Respects existing autonomy_level and allowed_commands settings even when in ACP mode.
  5. Stability: The server handles process termination and session cleanup gracefully.

Architecture impact

  • src/channels/: A new acp_server.rs module will be needed (sharing some logic with the existing acp.rs client).
  • src/main.rs: Update command parsing to include the ACP mode.
  • src/agent/: Minor updates to ensure the agent loop can stream events to a provided callback/channel during ACP sessions.
  • src/gateway/: Potential refactoring of shared server utilities (JSON-RPC handling).

Risk and rollback

  • Risk: Potential for resource exhaustion if too many sessions are opened.
  • Mitigation: Implement session limits and timeouts.
  • Rollback: The feature is additive and can be disabled by not using the --acp flag. It does not affect existing CLI or Gateway modes.

Breaking change?

No

Data hygiene checks

  • I removed personal/sensitive data from examples, payloads, and logs.
  • I used neutral, project-focused wording and placeholders.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions