Documentation Index
Fetch the complete documentation index at: https://springaicommunity.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Module 22: Async Agent
The reactive, non-blocking version of Module 12 (Echo Agent).What You’ll Learn
AcpAgent.async()instead ofAcpAgent.sync()- Handlers returning
Mono<T>instead ofT - Chaining
sendMessage()withthen()before returning the response - Agent lifecycle:
start().block()+awaitTermination().block()
The Code
Sync vs Async Agent Comparison
| Aspect | AcpAgent.sync() | AcpAgent.async() |
|---|---|---|
| Handler return | T | Mono<T> |
sendMessage() | void (blocking) | Mono<Void> (must chain) |
| Lifecycle | agent.run() | agent.start().block() + awaitTermination().block() |
context.sendMessage() returns Mono<Void>. You must chain it with .then() before returning the response Mono. If you skip the chain, the message won’t be sent before the response.
Source Code
View on GitHubRunning the Example
Key Points
- No API key — the async agent runs entirely locally, same as Module 12
- Same protocol — sync and async agents are interchangeable from the client’s perspective
- Reactive integration — async agents work naturally with Project Reactor, R2DBC, and other reactive libraries