Skip to content

Commit 537ead4

Browse files
author
Mark Pollack
committed
Update README with PromptContext API and IT test docs
- Update agent examples to use context parameter instead of updater - Remove AtomicReference workaround from file request example - Add Integration Tests section with Gemini CLI requirements - Update test counts (246/232 → 258)
1 parent d7009e5 commit 537ead4

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

README.md

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ AcpSyncAgent agent = AcpAgent.sync(transport)
8888
new InitializeResponse(1, new AgentCapabilities(), List.of()))
8989
.newSessionHandler(req ->
9090
new NewSessionResponse(UUID.randomUUID().toString(), null, null))
91-
.promptHandler((req, updater) -> {
91+
.promptHandler((req, context) -> {
9292
// Send updates using blocking void method
93-
updater.sendUpdate(req.sessionId(),
93+
context.sendUpdate(req.sessionId(),
9494
new AgentMessageChunk("agent_message_chunk",
9595
new TextContent("Hello from the agent!")));
9696
// Return response directly (no Mono!)
@@ -121,8 +121,8 @@ AcpAsyncAgent agent = AcpAgent.async(transport)
121121
new InitializeResponse(1, new AgentCapabilities(), List.of())))
122122
.newSessionHandler(req -> Mono.just(
123123
new NewSessionResponse(UUID.randomUUID().toString(), null, null)))
124-
.promptHandler((req, updater) ->
125-
updater.sendUpdate(req.sessionId(),
124+
.promptHandler((req, context) ->
125+
context.sendUpdate(req.sessionId(),
126126
new AgentMessageChunk("agent_message_chunk",
127127
new TextContent("Hello from the agent!")))
128128
.then(Mono.just(new PromptResponse(StopReason.END_TURN))))
@@ -142,12 +142,12 @@ Send real-time updates to the client during prompt processing.
142142

143143
**Agent (Sync) - recommended:**
144144
```java
145-
.promptHandler((req, updater) -> {
145+
.promptHandler((req, context) -> {
146146
// Blocking void calls - simple and straightforward
147-
updater.sendUpdate(req.sessionId(),
147+
context.sendUpdate(req.sessionId(),
148148
new AgentThoughtChunk("agent_thought_chunk",
149149
new TextContent("Thinking...")));
150-
updater.sendUpdate(req.sessionId(),
150+
context.sendUpdate(req.sessionId(),
151151
new AgentMessageChunk("agent_message_chunk",
152152
new TextContent("Here's my response.")));
153153
return new PromptResponse(StopReason.END_TURN);
@@ -156,11 +156,11 @@ Send real-time updates to the client during prompt processing.
156156

157157
**Agent (Async):**
158158
```java
159-
.promptHandler((request, updater) -> {
160-
return updater.sendUpdate(request.sessionId(),
159+
.promptHandler((request, context) -> {
160+
return context.sendUpdate(request.sessionId(),
161161
new AgentThoughtChunk("agent_thought_chunk",
162162
new TextContent("Thinking...")))
163-
.then(updater.sendUpdate(request.sessionId(),
163+
.then(context.sendUpdate(request.sessionId(),
164164
new AgentMessageChunk("agent_message_chunk",
165165
new TextContent("Here's my response."))))
166166
.then(Mono.just(new PromptResponse(StopReason.END_TURN)));
@@ -181,31 +181,25 @@ AcpSyncClient client = AcpClient.sync(transport)
181181

182182
### 4. Agent-to-Client Requests
183183

184-
Agents can request file operations from the client.
184+
Agents can request file operations from the client. The `context` parameter provides access to all agent capabilities.
185185

186186
**Agent (Sync) - reading files:**
187187
```java
188-
// Store agent reference for use in prompt handler
189-
AtomicReference<AcpSyncAgent> agentRef = new AtomicReference<>();
190-
191188
AcpSyncAgent agent = AcpAgent.sync(transport)
192-
.promptHandler((req, updater) -> {
193-
AcpSyncAgent agentInstance = agentRef.get();
194-
189+
.promptHandler((req, context) -> {
195190
// Read a file from the client's filesystem
196-
var fileResponse = agentInstance.readTextFile(
191+
var fileResponse = context.readTextFile(
197192
new ReadTextFileRequest(req.sessionId(), "pom.xml", null, 10));
198193
String content = fileResponse.content();
199194

200195
// Write a file
201-
agentInstance.writeTextFile(
196+
context.writeTextFile(
202197
new WriteTextFileRequest(req.sessionId(), "output.txt", "Hello!"));
203198

204199
return new PromptResponse(StopReason.END_TURN);
205200
})
206201
.build();
207202

208-
agentRef.set(agent); // Store reference before running
209203
agent.run();
210204
```
211205

@@ -338,10 +332,28 @@ agent.start().block(); // Starts WebSocket server on port 8080
338332

339333
```bash
340334
./mvnw compile # Compile
341-
./mvnw test # Run tests (246 tests across 2 modules)
335+
./mvnw test # Run unit tests (258 tests)
336+
./mvnw verify # Run unit tests + integration tests
342337
./mvnw install # Install to local Maven repository
343338
```
344339

340+
### Integration Tests
341+
342+
Integration tests connect to real ACP agents and require additional setup:
343+
344+
```bash
345+
# Gemini CLI integration tests (requires API key and gemini CLI)
346+
export GEMINI_API_KEY=your_key_here
347+
./mvnw verify -pl acp-core
348+
```
349+
350+
**Test Categories:**
351+
| Type | Command | Count | Requirements |
352+
|------|---------|-------|--------------|
353+
| Unit tests | `./mvnw test` | 258 | None |
354+
| Clean shutdown IT | `./mvnw verify` | 4 | None |
355+
| Gemini CLI IT | `./mvnw verify` | 5 | `GEMINI_API_KEY`, `gemini` CLI in PATH |
356+
345357
## Testing Your Code
346358

347359
Use the mock utilities for testing:
@@ -368,7 +380,7 @@ MockAcpClient mockClient = MockAcpClient.builder(pair.clientTransport())
368380
- Capability negotiation
369381
- Structured error handling
370382
- Full protocol compliance (all SessionUpdate types, MCP configs, `_meta` extensibility)
371-
- 232 tests
383+
- 258 tests
372384

373385
### v1.0.0 (Planned)
374386
- Maven Central publishing

0 commit comments

Comments
 (0)