Skip to content

Commit f81ffd1

Browse files
kabirclaude
andauthored
fix: Reject messages to tasks in terminal states (#760)
Per A2A spec CORE-SEND-002, SendMessage must return UnsupportedOperationError when attempting to send messages to tasks in terminal states (completed, canceled, rejected, failed). Added validation in DefaultRequestHandler.initMessageSend() to check if the existing task is in a terminal state (using TaskState.isFinal()) and throw UnsupportedOperationError before the message reaches the AgentExecutor. This fixes the issue on all three transports (JSON-RPC, gRPC, HTTP+JSON) since they all use the same DefaultRequestHandler code path. Fixes #741 🦕 Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 79cea44 commit f81ffd1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

server-common/src/main/java/io/a2a/server/requesthandlers/DefaultRequestHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,13 @@ private MessageSendSetup initMessageSend(MessageSendParams params, ServerCallCon
10451045
task.id(), task.contextId(), messageContextId));
10461046
}
10471047

1048+
// Per spec CORE-SEND-002: Reject messages to tasks in terminal states
1049+
if (task.status().state().isFinal()) {
1050+
throw new UnsupportedOperationError(null, String.format(
1051+
"Cannot send message to task %s: task is in terminal state %s and cannot accept further messages",
1052+
task.id(), task.status().state()), null);
1053+
}
1054+
10481055
LOGGER.debug("Found task updating with message {}", params.message());
10491056
task = taskManager.updateWithMessage(params.message(), task);
10501057

0 commit comments

Comments
 (0)