Skip to content

Commit a6bb10a

Browse files
authored
feat: Add tests for AUTH_REQUIRED (#684)
Fixes #504 🦕
1 parent 03fb539 commit a6bb10a

5 files changed

Lines changed: 857 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,17 @@ public EventKind onMessageSend(MessageSendParams params, ServerCallContext conte
496496
pushConfigStore.setInfo(createdTask.id(), params.configuration().pushNotificationConfig());
497497
}
498498

499-
if (blocking && interruptedOrNonBlocking) {
499+
// Check if task requires immediate return (AUTH_REQUIRED)
500+
// AUTH_REQUIRED expects the client to receive it immediately and handle it out-of-band,
501+
// while the agent continues executing in the background
502+
boolean requiresImmediateReturn = kind instanceof Task task &&
503+
task.status().state() == io.a2a.spec.TaskState.TASK_STATE_AUTH_REQUIRED;
504+
if (requiresImmediateReturn) {
505+
LOGGER.debug("DefaultRequestHandler: Task {} in AUTH_REQUIRED state, skipping fire-and-forget handling",
506+
taskId.get());
507+
}
508+
509+
if (blocking && interruptedOrNonBlocking && !requiresImmediateReturn) {
500510
// For blocking calls: ensure all consumed events are persisted to TaskStore before returning
501511
// Order of operations is critical to avoid circular dependency and race conditions:
502512
// 1. Wait for agent to finish enqueueing events (or timeout)

0 commit comments

Comments
 (0)