Skip to content

Commit 2f75223

Browse files
author
Mark Pollack
committed
Javadoc: correct the -32800 answer and the advertised capabilities
AcpProtocolException said any other exception from a handler is answered -32603; a CancellationException is answered -32800 with its own message, as ACP asks for a request cancelled internally. The logoutHandler and loadSessionHandler setters told users to advertise the capability themselves; the default initialize answer advertises it, and only an initialize handler must. Comments only.
1 parent 24ad914 commit 2f75223

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

‎acp-core/src/main/java/com/agentclientprotocol/sdk/agent/AcpAgent.java‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,9 @@ public AsyncAgentBuilder authenticateHandler(AuthenticateHandler handler) {
12981298

12991299
/**
13001300
* Sets the handler for {@code logout}, which ends the client's authenticated state.
1301-
* Advertise it in the initialize answer ({@code AgentAuthCapabilities.withLogout()});
1302-
* clients check for it before sending {@code logout}.
1301+
* Clients send {@code logout} only to an agent that advertises {@code auth.logout}; the
1302+
* default {@code initialize} answer advertises it, and an initialize handler must
1303+
* advertise it itself ({@code AgentAuthCapabilities.withLogout()}).
13031304
* @param handler the handler; must not be null
13041305
* @return this builder
13051306
*/
@@ -1325,8 +1326,10 @@ public AsyncAgentBuilder newSessionHandler(NewSessionHandler handler) {
13251326

13261327
/**
13271328
* Sets the handler for {@code session/load}, which reopens a session the agent kept: the
1328-
* agent replays the conversation to the client as session updates, then answers. Advertise
1329-
* it with the {@code loadSession} agent capability.
1329+
* agent replays the conversation to the client as session updates, then answers. Clients
1330+
* send {@code session/load} only to an agent that advertises the {@code loadSession}
1331+
* capability; the default {@code initialize} answer advertises it, and an initialize
1332+
* handler must advertise it itself.
13301333
* @param handler the handler; must not be null
13311334
* @return this builder
13321335
*/
@@ -1761,8 +1764,9 @@ public SyncAgentBuilder authenticateHandler(SyncAuthenticateHandler handler) {
17611764

17621765
/**
17631766
* Sets the handler for {@code logout}, which ends the client's authenticated state.
1764-
* Advertise it in the initialize answer ({@code AgentAuthCapabilities.withLogout()});
1765-
* clients check for it before sending {@code logout}.
1767+
* Clients send {@code logout} only to an agent that advertises {@code auth.logout}; the
1768+
* default {@code initialize} answer advertises it, and an initialize handler must
1769+
* advertise it itself ({@code AgentAuthCapabilities.withLogout()}).
17661770
* @param handler the handler; must not be null
17671771
* @return this builder
17681772
*/
@@ -1788,8 +1792,10 @@ public SyncAgentBuilder newSessionHandler(SyncNewSessionHandler handler) {
17881792

17891793
/**
17901794
* Sets the handler for {@code session/load}, which reopens a session the agent kept: the
1791-
* agent replays the conversation to the client as session updates, then answers. Advertise
1792-
* it with the {@code loadSession} agent capability.
1795+
* agent replays the conversation to the client as session updates, then answers. Clients
1796+
* send {@code session/load} only to an agent that advertises the {@code loadSession}
1797+
* capability; the default {@code initialize} answer advertises it, and an initialize
1798+
* handler must advertise it itself.
17931799
* @param handler the handler; must not be null
17941800
* @return this builder
17951801
*/

‎acp-core/src/main/java/com/agentclientprotocol/sdk/error/AcpProtocolException.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
* {@code Mono} with it, for a failure the caller should see, with a code from
1414
* {@link AcpErrorCodes}; this works the same in agent and client handlers, builder lambdas and
1515
* annotated methods. Its message and data go to the peer as they are, so keep secrets out of them.
16-
* An {@code AcpError} that escapes a handler passes on the error it carries. Any other exception
17-
* from a handler is answered {@code -32603} (internal error) with the generic
18-
* message "Internal error"; that exception is logged on the handling side and not sent.
16+
* An {@code AcpError} that escapes a handler passes on the error it carries, and a
17+
* {@link java.util.concurrent.CancellationException} is answered {@code -32800} (request
18+
* cancelled) with its own message, as ACP asks for a request cancelled internally. Any other
19+
* exception from a handler is answered {@code -32603} (internal error) with the generic message
20+
* "Internal error"; that exception is logged on the handling side and not sent.
1921
*
2022
* <p>The caller of the request never receives this type. On the caller's side the error response
2123
* fails the request with {@link com.agentclientprotocol.sdk.spec.AcpError}, which carries the same

0 commit comments

Comments
 (0)