Skip to main content
Complete API reference for the ACP Java SDK, covering client, agent (all three styles), protocol types, transports, errors, and test utilities.

Installation

Maven (0.14.0 — stable)

Core SDK (client + sync/async agent APIs):
Annotation-based agent support (includes acp-core transitively):
Test utilities:
WebSocket server transport for agents:

Gradle

Snapshot (0.15.0-SNAPSHOT)

For unreleased features, add the snapshot repository and use the snapshot version:
Then use 0.15.0-SNAPSHOT in place of 0.14.0 in your dependencies.

Three Agent API Styles

Quick Comparison

All three produce identical protocol behavior and support the same capabilities.

When to Use Each

  • Annotation-based — default choice. Least boilerplate, auto-converts return types, supports interceptors and custom argument resolvers.
  • Sync — when you want explicit control over every handler without annotations. Blocking void methods for sending updates.
  • Async — when your agent needs non-blocking I/O. Uses Project Reactor Mono for composable async chains.

Client API

AcpClient — Factory

AcpSyncClient — Blocking Client

Builder Configuration

Example — Complete client lifecycle

This launches Gemini CLI as an ACP agent subprocess and sends it a prompt. AgentParameters builds the command line; StdioAcpClientTransport spawns the process and handles JSON-RPC framing over stdin/stdout.

Agent API — Annotation-Based

The acp-agent-support module provides a declarative programming model using annotations.

Annotations

Class-Level

Handler Methods

Deprecated: the session-model API (0.14.0). session/set_model and the related types (@SetSessionModel, SetSessionModelRequest/Response, SessionModelState, ModelInfo, and the models field on session responses) were removed from the ACP spec in June 2026 and are marked @Deprecated(forRemoval = true). They still work for now but will be removed in a future release. Expose model selection through session/set_config_option instead: advertise a select config option whose category is "model", and switch models with setSessionConfigOption(...). This is the same mechanism used for session modes (category: "mode") and reasoning level (category: "thought_level").

Parameter Annotations

Flexible Method Signatures

Handler methods support flexible parameter resolution:

Return Value Handling

SyncPromptContext

Available in @Prompt handlers. Provides blocking methods for agent-client interaction:

AcpAgentSupport — Bootstrap

Interceptors

Cross-cutting concerns like logging, metrics, or error handling:

Example — Complete annotation-based agent


Agent API — Sync (Builder)

Blocking handlers with plain return values. No annotations.

Builder Methods

Example

Prompt Handler Context

The context parameter in promptHandler provides:

Agent API — Async (Builder)

Reactive handlers returning Mono. Uses Project Reactor.

Example

The async context’s sendMessage(), sendUpdate(), etc. return Mono<Void>, composable with .then() and .flatMap().

Convenience Methods vs Full API

The SDK provides convenience methods that cover the most common operations. Use these by default — they produce cleaner code and handle the protocol details for you.

When convenience methods are enough (~80% of cases)

When to use the full API (~20% of cases)

Drop to the full API when you need control that convenience methods don’t expose:
The convenience methods are wrappers around the full API — they call the same underlying protocol methods. You can mix and match freely within a single handler.

Protocol Types

All protocol types are defined in AcpSchema as Java records.

Request/Response Types

Session Types (0.12.0)

Config Option Types (0.12.0)

session/set_config_option is stable. The select variant is the stable shape; boolean is an SDK extension.

Provider Types (0.14.0, unstable)

Model/backend routing configuration. The agent advertises support with a providers capability; the client manages providers via listProviders / setProvider / disableProvider. apiType / supported use well-known LlmProtocol ids (anthropic, openai, azure, vertex, bedrock) or a custom string, modeled as String in the SDK.

Elicitation Types (0.12.0, unstable)

Content Types

Session Update Types

Content chunks (UserMessageChunk, AgentMessageChunk, AgentThoughtChunk) carry an optional messageId: chunks sharing the same id belong to one logical message, and a change in id starts a new message (0.14.0).

Stop Reasons

Convenience Methods


Capabilities

Client Capabilities

Advertised during initialize:

NegotiatedCapabilities

Check capabilities before using them:
Or use require methods that throw AcpCapabilityException if unsupported:

Session Capabilities (0.12.0)

Agents advertise session management support via SessionCapabilities. The NegotiatedCapabilities accessors are: supportsListSessions(), supportsCloseSession(), supportsResumeSession(), supportsDeleteSession() (0.14.0), supportsAdditionalDirectories() (0.14.0), and supportsForkSession() (unstable) — each with a matching require*() that throws AcpCapabilityException.

Elicitation Capabilities (0.12.0, unstable)

Clients advertise elicitation support during initialization:

@UnstableAcpApi

APIs marked @UnstableAcpApi correspond to protocol elements in schema.unstable.json. They are public and functional but may change in any minor release. When the protocol element stabilizes, the annotation is removed (compatible change). See Versioning for the full policy. IntelliJ users can configure the Unstable API Usage inspection (Settings > Inspections > JVM languages) to flag usages.

Transports

Stdio Transport

The default transport. The client launches the agent as a subprocess and communicates via JSON-RPC over stdin/stdout. This is the same mechanism Zed, JetBrains, and VS Code use to talk to agents. Client sideAgentParameters specifies the command to launch. Any executable that speaks ACP over stdin/stdout works (Gemini CLI, your own agent JAR, etc.):
Agent side — reads JSON-RPC from stdin, writes responses to stdout. The agent doesn’t need to know what launched it:

WebSocket Transport

For network-based communication. Client (JDK-native, no extra dependencies):
Agent (requires acp-websocket-jetty):

In-Memory Transport

For testing. No subprocess or network I/O.

Errors

Exception Hierarchy

Error Codes

Agent-Side Error Handling

Throw AcpProtocolException from handlers to send structured errors to clients:

Test Utilities

The acp-test module provides utilities for testing without subprocesses.

InMemoryTransportPair


Packages

Maven Artifacts


See Also