How ACP Works
ACP uses a subprocess model. A client (your application, or an editor like Zed) launches an agent as a child process and communicates over stdin/stdout using JSON-RPC messages. The protocol has three phases:- Initialize — client and agent exchange protocol versions and capabilities
- Session — client creates a session with a working directory context
- Prompt — client sends messages, agent streams back responses
Overview
The ACP Java SDK provides:- Client SDK — connect to and interact with any ACP-compliant agent
- Agent SDK — build ACP-compliant agents that work in Zed, JetBrains, and VS Code
- Test utilities — in-memory transports for fast, deterministic testing
Quick Start
Try it now
The fastest way to see ACP in action is to clone the tutorial and run a module. The client example talks to Gemini CLI (requiresGEMINI_API_KEY). The agent example runs locally with no API key.
Client — Connect to an Agent
This example launches Gemini CLI as an ACP agent subprocess and sends it a prompt. Any CLI tool that speaks ACP over stdin/stdout works here — Gemini CLI is one such tool.AgentParameters builds the command line (gemini --experimental-acp). StdioAcpClientTransport spawns the process and handles the JSON-RPC framing. The sessionUpdateConsumer receives the agent’s response text as it streams in — without it, you’d get the stop reason but no visible output.
Agent — Build Your Own
This is the other side of the conversation. When you build an agent, editors and clients launch your code as a subprocess and send it JSON-RPC messages over stdin. Your agent handles three request types: initialize, new session, and prompt. The stdio transport reads from stdin and writes to stdout.run() blocks until the client disconnects. The module includes a demo client that launches this agent as a subprocess and exercises it — you’ll see Echo: Hello! printed when you run it.
Adding the SDK to your project
acp-agent-support instead — it includes acp-core transitively:
Three Agent API Styles
| Style | Entry Point | Best For |
|---|---|---|
| Annotation-based | @AcpAgent, @Prompt | Least boilerplate, declarative style |
| Sync | AcpAgent.sync() | Blocking handlers, plain return values |
| Async | AcpAgent.async() | Reactive applications, Project Reactor Mono |
Documentation
API Reference
Client API, Agent API (all three styles), protocol types, transports, errors
Tutorial
30-module progressive tutorial from client basics to IDE integration
Resources
- GitHub Repository — Source code
- ACP Java Tutorial — 30 hands-on modules
ACP Ecosystem
- Agent Client Protocol — Official specification
- ACP Specification — Protocol details (initialization, sessions, prompt turns)
- Agents Directory — ACP-compliant agents
- Clients Directory — Editors and clients that support ACP