Understanding the Agent-Client Protocol (ACP): Communication Between AI Agents and Code Editors

    This article breaks down the Agent-Client Protocol (ACP), a standardized communication contract between AI coding agents and code editors. It explains the motivation behind a unified protocol, the responsibility boundaries between the Client and the Agent, the on-demand connection model with multiple sessions over a single connection, and the message mechanism based on notifications and bidirectional requests. It also covers permission boundaries, user visibility, practical implementation advice, common pitfalls, and the ecosystem benefits of standardization.

    Understanding the Agent-Client Protocol (ACP): Communication Between AI Agents and Code Editors

    1. Background: Why a Unified Agent-Client Protocol Is Needed

    As intelligent coding tools spread quickly, one engineering problem keeps recurring: every time a new AI coding capability appears, development teams often have to build a separate integration for each editor. Editor A needs one plugin, Editor B needs another adapter layer, and the command-line environment requires yet another implementation. Integration logic becomes tightly coupled to specific products, so maintenance costs grow linearly with the number of supported clients.

    The root cause is the lack of a stable communication contract. This is similar to how the Universal Serial Bus (USB) interface fueled a thriving peripheral ecosystem: as long as both devices and hosts follow the same electrical and protocol specifications, any combination works. Applying this idea between agents and editors leads to the design motivation behind standardized protocols like the Agent-Client Protocol (hereafter ACP): define once, reuse across many clients.

    It is worth emphasizing that the protocol itself does not dictate model capabilities or specific tool implementations. It only constrains how the two sides establish a connection, exchange messages, and express permissions and streaming states. This “thin protocol, broad ecosystem” positioning is the prerequisite for adoption by different implementations.

    2. Role Division: The Responsibility Boundary Between Client and Agent

    ACP uses a Client-Agent model. The Client is the code editor or integrated development environment, and the Agent is the AI coding assistant. The two communicate through a standard protocol, and the Agent may optionally connect to external tools.

    1. ┌─────────────┐ ACP ┌──────────────┐
    2. │ Client │ ◄───────────► │ Agent │
    3. │ (Editor) │ │ (AI Assistant│
    4. └─────────────┘ └──────────────┘
    5. │ │
    6. │ Files/Terminal/Permissions │ Optional
    7. ▼ ▼
    8. User Interface ┌──────────┐
    9. │ Tools │
    10. └──────────┘

    The Client’s core responsibilities include: launching the Agent process on demand, organizing user input into requests, rendering the Agent’s streaming output, handling tool-call and file-operation requests from the Agent, and maintaining the permission confirmation interface.

    The Agent’s core responsibilities include: understanding user intent, planning execution steps, calling external tools as needed (for example, version control, language services, retrieval capabilities), generating code or suggestions, and returning intermediate states and final results.

    The key value of this division is decoupling responsibilities: the editor does not need to understand the model’s internal logic, and the Agent does not need to assume which kind of interface it is running in. Both sides depend only on protocol semantics, so they can evolve independently.

    3. Connection Model: On-Demand Launch and Multiple Sessions Over a Single Connection

    3.1 On-Demand Launch

    When a user first tries to connect to an Agent, the Client is responsible for launching the Agent subprocess on demand, with communication carried out over standard input/output pipes; in remote or containerized deployment scenarios, a single network connection can carry the same message stream. Once the connection is established, both sides first perform capability negotiation, exchanging the message types and feature flags they support to avoid later runtime errors where “the peer does not support a certain capability.”

    3.2 Multiple Sessions Over a Single Connection

    A single connection can carry multiple concurrent sessions. This point is often underestimated, but it directly determines the ceiling of the product experience. Developers can have the Agent analyze an error in one window while having it refactor a module in another context, with neither blocking the other. A schematic session lifecycle is as follows:

    1. // 1. Create a session
    2. { "method": "session/new", "params": { "cwd": "/workspace/demo" } }
    3. // 2. Send a user prompt
    4. { "method": "session/prompt", "params": { "sessionId": "s-1", "text": "Explain this logic" } }
    5. // 3. Cancel a session without affecting others
    6. { "method": "session/cancel", "params": { "sessionId": "s-1" } }

    Decoupling sessions from the connection allows the connection to be reused, keeps resource usage under control, and makes operations like “cancel” precise to a single-session granularity.

    4. Message Mechanism: Notifications and Bidirectional Requests

    The protocol makes extensive use of JSON-RPC notification semantics. A notification is a one-way message that requires no response, making it suitable for high-frequency, disposable, or mergeable state updates. As the Agent generates output, it continuously pushes partial results, the current step, and tool execution progress, so the interface can present the “thinking process” in real time rather than waiting for the complete response and refreshing all at once. For the streaming experience, this is the most critical piece.

    Bidirectional requests solve another problem: the Agent can proactively initiate calls to the Client that require a response, with typical scenarios including requesting authorization for a tool call, requesting permission to read or write a certain path, and requesting to create a terminal to execute a command. The request-response semantics ensure the Agent can obtain a clear conclusion before deciding whether to continue, rather than “acting first and asking later.”

    The combination of the two can be understood this way: notifications handle “continuous informing,” while requests handle “key confirmation.” The former optimizes perceived latency, and the latter guarantees controllability.

    5. Trustworthy Design: Permission Boundaries and User Visibility

    The higher the degree of automation, the stronger the user’s need for certainty about “what it can do right now.” The protocol’s response is to make permissions explicit: sensitive operations are not decided by the Agent on its own but are turned into a request directed at the user; the user approves, rejects, or sets a long-term rule, and the conclusion is returned along the original request.

    In engineering practice, it is recommended to follow a few general principles:

    • Least privilege: by default, grant only the path and command scope required for the current task.
    • Tiered confirmation: read-only operations can be allowed automatically, while write and execution operations require confirmation.
    • Revocable: authorization should support reclamation at the session or task level, rather than taking effect permanently.
    • Auditable: log authorizations and tool calls to a logging service for easier troubleshooting.

    These practices naturally align with the protocol’s notification/request mechanism and are also key to turning “trustworthy” from a slogan into an implementation.

    6. Implementation Advice and Common Pitfalls

    When building in-house or selecting a solution, you can focus on the following points:

    1. Do capability negotiation first, then feature development, to avoid compatibility rework.
    2. Abstract tool calls into a unified description (name, input parameters, permission requirements) for easy cross-client reuse.
    3. Streaming rendering must handle out-of-order and merged messages, and cannot assume messages arrive at strictly equal intervals.
    4. Long-running tasks need both a progress channel and a cancellation channel; neither can be missing.
    5. Manage session state and connection state separately to make scaling and failure recovery easier.

    Common pitfalls include: treating the protocol as a model capability standard, stuffing logic that requires a response into notifications, and making permission confirmation a one-time global authorization.

    7. Further Thoughts

    The biggest benefit of a standardized protocol is not “writing a few fewer lines of code,” but ecosystem division of labor: editors focus on interaction and presentation, Agents focus on reasoning and planning, and tools focus on execution. The three parties iterate independently and collaborate through a stable contract. When this layering holds, intelligent coding capabilities can become plug-and-play like general-purpose peripherals. Combined with general-purpose cloud capabilities (such as container platforms hosting the Agent runtime, and logging services with monitoring and alerting to ensure observability), elasticity and operations can be further incorporated into the same system.