Skip to content

Commit 0cd8df3

Browse files
author
Mark Pollack
committed
acp-core: a supported in-process transport, InMemoryTransportPair
An application that connects its own ACP client to its own agent in one JVM (a web endpoint driving an @AcpAgent, for instance) had to take InMemoryTransportPair from acp-test, a test artifact, at runtime. The pair now lives in acp-core as com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair, reusing the acp-test implementation, with what a supported transport needs: - One JSON mapper per pair: create() takes the classpath default once, create(AcpJsonMapper) takes one the application configures (the test copy created a mapper for every conversion). - Either side's close ends the connection for both: both transports' awaitTermination() complete, so AcpSyncAgent.run() returns when the client closes and the client fails its waiting requests at once instead of at their timeout; a request the agent sent the client and that is still unanswered fails with -32603, as on stdio. Messages sent before the end are delivered; a send after it fails with AcpConnectionException. Both reproduced first: the new lifecycle tests fail on the acp-test class. - connect() and start() complete at once, as the transport interfaces specify; one message's handler failure no longer stops the next; transport errors are logged at WARN by default. The send queue becomes InMemoryChannel, whose close is serialised with the sends (a plain tryEmitComplete could be lost to FAIL_NON_SERIALIZED). A Lincheck model check covers it and fails when the accept lock is removed. acp-test's InMemoryTransportPair is deprecated and delegates to the acp-core class. The repository's own tests move to the acp-core class, acp-core's private test copy is removed, and AcpAgentHostTest keeps its client open until the host stops, since closing it is now a transport end.
1 parent 67fd110 commit 0cd8df3

91 files changed

Lines changed: 1313 additions & 1020 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- **A supported in-process transport, `com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair`, in
13+
acp-core.** It connects an ACP client and an agent in the same JVM, without a process or a port: build the
14+
agent on `agentTransport()` and the client on `clientTransport()`. An application that serves its own agent
15+
to its own code (a web endpoint that drives an `@AcpAgent`, for instance) no longer needs acp-test at
16+
runtime. The two sides exchange ACP's JSON-RPC messages as `AcpSchema` objects, in order, from any number
17+
of sending threads. `create()` takes the JSON mapper from the classpath once for the pair;
18+
`create(AcpJsonMapper)` takes one you configure.
19+
20+
### Changed
21+
22+
- **Either side's close now ends the in-process connection for both.** Closing the client, the agent, either
23+
transport or the pair completes both transports' `awaitTermination()`: `AcpSyncAgent.run()` returns once
24+
the client closes, the client fails its requests still waiting for the agent at once instead of at their
25+
timeout, and a request the agent sent the client and that is still unanswered fails with `-32603`, as on
26+
stdio. Messages sent before the end are still delivered; a send after it fails with
27+
`AcpConnectionException` (it was a `RuntimeException`). Before, the agent transport ended only when the
28+
agent side closed and the client transport never reported an end.
29+
- **`connect()` and `start()` on the in-process transports complete at once**, as the transport interfaces
30+
specify, instead of when the connection ends. A handler failure on one message no longer stops delivery of
31+
the next on the client side, and transport errors are logged at WARN unless an exception handler is set.
32+
33+
### Deprecated
34+
35+
- **`com.agentclientprotocol.sdk.test.InMemoryTransportPair` (acp-test)** delegates to the acp-core class and
36+
is deprecated for removal in a later release. Change the import to
37+
`com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair`; nothing else changes.
38+
839
## [0.81.0] - 2026-11-10
940

1041
The six refusals below and the path check come from a whole-specification audit of the SDK against

‎README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ that authenticates in front. Browser requests whose `Origin` is not a loopback o
460460
| `com.agentclientprotocol.sdk.client` | Client SDK (`AcpClient`, `AcpAsyncClient`, `AcpSyncClient`) |
461461
| `com.agentclientprotocol.sdk.client.transport` | Client transports (`StdioAcpClientTransport`, `WebSocketAcpClientTransport`, `StreamableHttpAcpClientTransport`) |
462462
| `com.agentclientprotocol.sdk.agent` | Agent SDK (`AcpAgent`, `AcpAsyncAgent`, `AcpSyncAgent`, `AcpAgentFactory`) |
463-
| `com.agentclientprotocol.sdk.agent.transport` | Agent transports (`StdioAcpAgentTransport`; `StreamableHttpAcpServlet` from acp-http-servlet; `StreamableHttpAcpAgentTransport` from acp-streamable-http-jetty; `StreamableHttpAcpAgentTransportOptions` from acp-http-core) |
463+
| `com.agentclientprotocol.sdk.agent.transport` | Agent transports (`StdioAcpAgentTransport`; the in-process `InMemoryTransportPair`, which also hands out its client side; `StreamableHttpAcpServlet` from acp-http-servlet; `StreamableHttpAcpAgentTransport` from acp-streamable-http-jetty; `StreamableHttpAcpAgentTransportOptions` from acp-http-core) |
464464
| `com.agentclientprotocol.sdk.http.webflux` | The Spring WebFlux host from acp-http-webflux (`AcpWebFluxHost`) |
465465
| `com.agentclientprotocol.sdk.http.server` | The host contract from acp-http-core (`AcpHttpEndpoint`, `AcpHttpExchange`, `AcpHttpReply`, `AcpWsHandshake`), for writing a server adapter; unstable |
466466
| `com.agentclientprotocol.sdk.agent.support` | Annotation-based agent runtime (`AcpAgentSupport`), with its `resolver`, `handler`, `interceptor` and `invocation` extension points |
@@ -469,7 +469,7 @@ that authenticates in front. Browser requests whose `Origin` is not a loopback o
469469
| `com.agentclientprotocol.sdk.error` | Exceptions (`AcpProtocolException`, `AcpCapabilityException`) |
470470
| `com.agentclientprotocol.sdk.json` | JSON mapping abstraction (`AcpJsonMapper`, `TypeRef`); the Jackson 2 implementation (`JacksonAcpJsonMapper`) from acp-json-jackson2 |
471471
| `com.agentclientprotocol.sdk.json.jackson3` | Jackson 3 implementation (`Jackson3AcpJsonMapper`) from acp-json-jackson3 |
472-
| `com.agentclientprotocol.sdk.test` | Test support from acp-test (`InMemoryTransportPair`, `MockAcpAgent`, `MockAcpClient`) |
472+
| `com.agentclientprotocol.sdk.test` | Test support from acp-test (`MockAcpAgent`, `MockAcpClient`) |
473473

474474
### Maven Artifacts
475475

@@ -494,6 +494,7 @@ that authenticates in front. Browser requests whose `Origin` is not a loopback o
494494
| Transport | Client | Agent | Module |
495495
|-----------|--------|-------|--------|
496496
| Stdio | `StdioAcpClientTransport` | `StdioAcpAgentTransport` | acp-core |
497+
| In-process (client and agent in one JVM) | `InMemoryTransportPair.clientTransport()` | `InMemoryTransportPair.agentTransport()` | acp-core |
497498
| WebSocket | `WebSocketAcpClientTransport` | `StreamableHttpAcpAgentTransport` (upgrade on the same path) | acp-core / acp-streamable-http-jetty |
498499
| Streamable HTTP | `StreamableHttpAcpClientTransport` | `StreamableHttpAcpAgentTransport` | acp-core / acp-streamable-http-jetty |
499500
| Streamable HTTP and WebSocket in your own Servlet 6 container | `StreamableHttpAcpClientTransport`, `WebSocketAcpClientTransport` | `StreamableHttpAcpServlet` (WebSocket where the container has Jakarta WebSocket 2.1) | acp-core / acp-http-servlet |
@@ -574,9 +575,10 @@ profile on demand and uploads the report.
574575
Use the mock utilities for testing:
575576

576577
```java
578+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
577579
import com.agentclientprotocol.sdk.test.*;
578580

579-
// Create in-memory transport pair for testing
581+
// Connect a client and an agent in this JVM (acp-core's in-process transport)
580582
InMemoryTransportPair pair = InMemoryTransportPair.create();
581583

582584
// Use pair.clientTransport() for client, pair.agentTransport() for agent

‎acp-agent-support/src/test/java/com/agentclientprotocol/sdk/agent/support/AcpAgentSupportBuilderReuseTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import com.agentclientprotocol.sdk.spec.AcpSchema.PromptResponse;
3232
import com.agentclientprotocol.sdk.spec.AcpSchema.StopReason;
3333
import com.agentclientprotocol.sdk.spec.AcpSchema.TextContent;
34-
import com.agentclientprotocol.sdk.test.InMemoryTransportPair;
34+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
3535
import org.junit.jupiter.api.Test;
3636
import reactor.core.publisher.Mono;
3737

‎acp-agent-support/src/test/java/com/agentclientprotocol/sdk/agent/support/AcpAgentSupportBuilderStateTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.agentclientprotocol.sdk.client.AcpAsyncClient;
1414
import com.agentclientprotocol.sdk.client.AcpClient;
1515
import com.agentclientprotocol.sdk.spec.AcpSchema.PromptResponse;
16-
import com.agentclientprotocol.sdk.test.InMemoryTransportPair;
16+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
1717
import org.junit.jupiter.api.Test;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;

‎acp-agent-support/src/test/java/com/agentclientprotocol/sdk/agent/support/AcpAgentSupportConnectionContextTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import com.agentclientprotocol.sdk.spec.AcpSchema.SetSessionModeRequest;
4242
import com.agentclientprotocol.sdk.spec.AcpSchema.SetSessionModeResponse;
4343
import com.agentclientprotocol.sdk.spec.AcpSchema.TextContent;
44-
import com.agentclientprotocol.sdk.test.InMemoryTransportPair;
44+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
4545
import org.junit.jupiter.api.AfterEach;
4646
import org.junit.jupiter.api.Test;
4747
import reactor.core.publisher.Mono;

‎acp-agent-support/src/test/java/com/agentclientprotocol/sdk/agent/support/AcpAgentSupportErrorPathTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.agentclientprotocol.sdk.spec.AcpSchema.SetSessionConfigOptionResponse;
3535
import com.agentclientprotocol.sdk.spec.AcpSchema.StopReason;
3636
import com.agentclientprotocol.sdk.spec.AcpSchema.TextContent;
37-
import com.agentclientprotocol.sdk.test.InMemoryTransportPair;
37+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
3838
import org.junit.jupiter.api.AfterEach;
3939
import org.junit.jupiter.api.Test;
4040
import reactor.core.publisher.Mono;

‎acp-agent-support/src/test/java/com/agentclientprotocol/sdk/agent/support/AcpAgentSupportExtensionTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.agentclientprotocol.sdk.json.TypeRef;
2121
import com.agentclientprotocol.sdk.spec.AcpError;
2222
import com.agentclientprotocol.sdk.spec.AcpSchema.PromptResponse;
23-
import com.agentclientprotocol.sdk.test.InMemoryTransportPair;
23+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
2424
import org.junit.jupiter.api.AfterEach;
2525
import org.junit.jupiter.api.BeforeEach;
2626
import org.junit.jupiter.api.Test;

‎acp-agent-support/src/test/java/com/agentclientprotocol/sdk/agent/support/AcpAgentSupportHandlerExecutorTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.agentclientprotocol.sdk.annotation.Prompt;
1111
import com.agentclientprotocol.sdk.spec.AcpSchema.PromptRequest;
1212
import com.agentclientprotocol.sdk.spec.AcpSchema.PromptResponse;
13-
import com.agentclientprotocol.sdk.test.InMemoryTransportPair;
13+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
1414
import org.junit.jupiter.api.Test;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;

‎acp-agent-support/src/test/java/com/agentclientprotocol/sdk/agent/support/AcpAgentSupportLifecycleTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.agentclientprotocol.sdk.annotation.Prompt;
1111
import com.agentclientprotocol.sdk.spec.AcpSchema.PromptRequest;
1212
import com.agentclientprotocol.sdk.spec.AcpSchema.PromptResponse;
13-
import com.agentclientprotocol.sdk.test.InMemoryTransportPair;
13+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
1414
import org.junit.jupiter.api.Test;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;

‎acp-agent-support/src/test/java/com/agentclientprotocol/sdk/agent/support/AcpAgentSupportTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
import com.agentclientprotocol.sdk.spec.AcpSchema.TextContent;
6767
import com.agentclientprotocol.sdk.agent.support.interceptor.AcpInterceptor;
6868
import com.agentclientprotocol.sdk.agent.support.invocation.AcpInvocationContext;
69-
import com.agentclientprotocol.sdk.test.InMemoryTransportPair;
69+
import com.agentclientprotocol.sdk.agent.transport.InMemoryTransportPair;
7070

7171
import reactor.core.publisher.Mono;
7272

0 commit comments

Comments
 (0)