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 13: Agent Handlers
Implement all handler types that an ACP agent can provide.What You’ll Learn
- All five handler types: initialize, newSession, loadSession, prompt, cancel
- Session tracking with
ConcurrentHashMap - Logging to stderr (stdout is reserved for the protocol)
The Code
An ACP agent has five handler types. Three are required (initialize, newSession, prompt) and two are optional (loadSession, cancel). This example shows all five wired up with the sync builder API. Note that stdout is reserved for the JSON-RPC protocol — agent logging goes to stderr:
Handler Reference
| Handler | Method | Required | Description |
|---|---|---|---|
initializeHandler | initialize | Yes | Protocol handshake, capability exchange |
newSessionHandler | session/new | Yes | Create session with working directory |
loadSessionHandler | session/load | No | Resume an existing session by ID |
promptHandler | session/prompt | Yes | Process user prompts |
cancelHandler | session/cancel | No | Handle cancellation (fire-and-forget notification) |
cancelHandler receives a CancelNotification, not a request — it has no response. This is the JSON-RPC notification pattern: the client sends it and does not expect a reply.