Skip to content

Agent Client Protocol (ACP) Support

CodeCompanion implements the Agent Client Protocol (ACP) to enable you to work with coding agents from within Neovim. ACP is an open standard that enables structured interaction between clients (like CodeCompanion) and AI agents, providing capabilities such as session management, file system operations, tool execution, and permission handling.

This page provides a technical reference for what's supported in CodeCompanion and how it's been implemented.

Implementation

CodeCompanion provides comprehensive support for the ACP specification:

Feature CategorySupportedDetails
Core ProtocolJSON-RPC 2.0, streaming responses, message buffering
AuthenticationMultiple auth methods, adapter-level hooks
Content TypesText, images, embedded resources
File SystemRead/write text files with line ranges
MCP IntegrationStdio, HTTP, and SSE transports
PermissionsInteractive UI with diff preview for tool approval
Session ManagementCreate, load, and persist sessions with state tracking
Session ModesMode switching
Session ModelsSelect specific models
Tool CallsContent blocks, file diffs, status updates
Agent PlansVisual display of an agent's execution plan
Terminal OperationsTerminal capabilities not implemented

Supported Adapters

Please see the Configuring ACP Adapters page.

Client Capabilities

CodeCompanion advertises the following capabilities to ACP agents:

lua
{
  fs = {
    readTextFile = true,   -- Read files with optional line ranges
    writeTextFile = true   -- Write/create files
  },
  terminal = false         -- Terminal operations not supported
}

Content Types

Content TypeSend to AgentReceive from Agent
Text
File DiffsN/A
Images
Audio
Embedded Resources

State Management

Unlike HTTP adapters which are stateless (sending the full conversation history with each request), ACP adapters are stateful. The agent maintains the conversation context, so CodeCompanion only sends new messages with each prompt. Session IDs are tracked throughout the conversation lifecycle.

File Context Handling

When sending files as embedded resources to agents, CodeCompanion re-reads the file content rather than using the chat buffer representation. This avoids HTTP-style <attachment> tags that are used for LLM adapters but don't make sense for ACP agents.

Slash Commands

ACP agents can advertise their own slash commands dynamically. You can access them with \command in the chat buffer. CodeCompanion transforms this to /command before sending your prompt to the agent.

Model Selection

CodeCompanion implements a session/set_model method that allows you to select a model for the current session. This feature is not part of the official ACP specification and is subject to change in future versions.

Cleanup and Lifecycle

CodeCompanion ensures clean disconnection from ACP agents by hooking into Neovim's VimLeavePre autocmd. This guarantees that agent processes are properly terminated even if Neovim exits unexpectedly.

Protocol Version

CodeCompanion currently implements ACP Protocol Version 1.

The protocol version is negotiated during initialization. If an agent selects a different version, CodeCompanion will log a warning but continue to operate, following the agent's selected version.

Current Limitations

  • Terminal Operations: The terminal/* family of methods (terminal/create, terminal/output, terminal/release, etc.) are not implemented. CodeCompanion doesn't advertise terminal capabilities to agents.

  • Agent Plan Rendering: Plan updates from agents are received and logged, but they're not currently rendered in the chat buffer UI.

  • Audio Content: Audio can't be sent or received

See Also

Released under the MIT License.