Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,14 @@ public AgentEmitter(RequestContext context, EventQueue eventQueue) {
this.contextId = context.getContextId();
}

private void updateStatus(TaskState taskState) {
updateStatus(taskState, null, taskState.isFinal());
}

/**
* Updates the task status to the given state with an optional message.
*
* @param taskState the new task state
* @param message optional message to include with the status update
*/
public void updateStatus(TaskState taskState, @Nullable Message message) {
updateStatus(taskState, message, taskState.isFinal());
}

/**
* Updates the task status to the given state with an optional message and finality flag.
*
* @param state the new task state
* @param message optional message to include with the status update
* @param isFinal whether this is a final status (prevents further updates)
*/
private void updateStatus(TaskState state, @Nullable Message message, boolean isFinal) {
boolean isFinal = taskState.isFinal();
// Check terminal state first (fail fast)
if (terminalStateReached.get()) {
throw new IllegalStateException("Cannot update task status - terminal state already reached");
Expand All @@ -152,7 +138,7 @@ private void updateStatus(TaskState state, @Nullable Message message, boolean is
TaskStatusUpdateEvent event = TaskStatusUpdateEvent.builder()
.taskId(taskId)
.contextId(contextId)
.status(new TaskStatus(state, message, null))
.status(new TaskStatus(taskState, message, null))
.build();
eventQueue.enqueueEvent(event);
}
Expand Down Expand Up @@ -371,7 +357,7 @@ public void reject(@Nullable Message message) {
* Marks the task as INPUT_REQUIRED, indicating the agent needs user input to continue.
*/
public void requiresInput() {
requiresInput(null, false);
requiresInput(null);
}

/**
Expand All @@ -380,33 +366,39 @@ public void requiresInput() {
* @param message optional message to include
*/
public void requiresInput(@Nullable Message message) {
requiresInput(message, false);
updateStatus(TaskState.TASK_STATE_INPUT_REQUIRED, message);
}

/**
* Marks the task as INPUT_REQUIRED with a finality flag.
* Marks the task as INPUT_REQUIRED.
*
* @param isFinal whether this is a final status (prevents further updates)
* @param isFinal ignored — interrupted states are not final per the A2A specification.
* Use {@link #requiresInput()} instead.
* @deprecated The {@code isFinal} parameter has no effect. Use {@link #requiresInput()} instead.
*/
@Deprecated(forRemoval = true)
public void requiresInput(boolean isFinal) {
requiresInput(null, isFinal);
requiresInput();
}

/**
* Marks the task as INPUT_REQUIRED with an optional message and finality flag.
* Marks the task as INPUT_REQUIRED with an optional message.
*
* @param message optional message to include
* @param isFinal whether this is a final status (prevents further updates)
* @param isFinal ignored — interrupted states are not final per the A2A specification.
* Use {@link #requiresInput(Message)} instead.
* @deprecated The {@code isFinal} parameter has no effect. Use {@link #requiresInput(Message)} instead.
*/
@Deprecated(forRemoval = true)
public void requiresInput(@Nullable Message message, boolean isFinal) {
updateStatus(TaskState.TASK_STATE_INPUT_REQUIRED, message, isFinal);
requiresInput(message);
}

/**
* Marks the task as AUTH_REQUIRED, indicating the agent needs authentication to continue.
*/
public void requiresAuth() {
requiresAuth(null, false);
requiresAuth(null);
}

/**
Expand All @@ -415,26 +407,32 @@ public void requiresAuth() {
* @param message optional message to include
*/
public void requiresAuth(@Nullable Message message) {
requiresAuth(message, false);
updateStatus(TaskState.TASK_STATE_AUTH_REQUIRED, message);
}

/**
* Marks the task as AUTH_REQUIRED with a finality flag.
* Marks the task as AUTH_REQUIRED.
*
* @param isFinal whether this is a final status (prevents further updates)
* @param isFinal ignored — interrupted states are not final per the A2A specification.
* Use {@link #requiresAuth()} instead.
* @deprecated The {@code isFinal} parameter has no effect. Use {@link #requiresAuth()} instead.
*/
@Deprecated(forRemoval = true)
public void requiresAuth(boolean isFinal) {
requiresAuth(null, isFinal);
requiresAuth();
}

/**
* Marks the task as AUTH_REQUIRED with an optional message and finality flag.
* Marks the task as AUTH_REQUIRED with an optional message.
*
* @param message optional message to include
* @param isFinal whether this is a final status (prevents further updates)
* @param isFinal ignored — interrupted states are not final per the A2A specification.
* Use {@link #requiresAuth(Message)} instead.
* @deprecated The {@code isFinal} parameter has no effect. Use {@link #requiresAuth(Message)} instead.
*/
@Deprecated(forRemoval = true)
public void requiresAuth(@Nullable Message message, boolean isFinal) {
updateStatus(TaskState.TASK_STATE_AUTH_REQUIRED, message, isFinal);
requiresAuth(message);
}

/**
Expand Down Expand Up @@ -569,7 +567,6 @@ public void addTask(Task task) {
* .taskId(context.getTaskId())
* .contextId(context.getContextId())
* .status(new TaskStatus(TaskState.WORKING))
* .isFinal(false)
* .build();
* emitter.emitEvent(event);
* }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,17 @@
checkTaskStatusUpdateEventOnQueue(false, TaskState.TASK_STATE_INPUT_REQUIRED, SAMPLE_MESSAGE);
}

@SuppressWarnings("deprecation")
@Test
public void testRequiresInputWithFinalTrue() throws Exception {
agentEmitter.requiresInput(true);

Check warning on line 190 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test-0-3 (17)

[removal] requiresInput(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 190 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test-0-3 (17, multi-version)

[removal] requiresInput(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 190 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test (17, multi-version)

[removal] requiresInput(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 190 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test (17)

[removal] requiresInput(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 190 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / test-cloud-deployment

[removal] requiresInput(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 190 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 17)

[removal] requiresInput(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 190 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / build (windows-latest, 17)

[removal] requiresInput(boolean) in AgentEmitter has been deprecated and marked for removal
checkTaskStatusUpdateEventOnQueue(false, TaskState.TASK_STATE_INPUT_REQUIRED, null);
}

@SuppressWarnings("deprecation")
@Test
public void testRequiresInputWithMessageAndFinalTrue() throws Exception {
agentEmitter.requiresInput(SAMPLE_MESSAGE, true);

Check warning on line 197 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test-0-3 (17)

[removal] requiresInput(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 197 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test-0-3 (17, multi-version)

[removal] requiresInput(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 197 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test (17, multi-version)

[removal] requiresInput(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 197 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test (17)

[removal] requiresInput(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 197 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / test-cloud-deployment

[removal] requiresInput(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 197 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 17)

[removal] requiresInput(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 197 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / build (windows-latest, 17)

[removal] requiresInput(Message,boolean) in AgentEmitter has been deprecated and marked for removal
checkTaskStatusUpdateEventOnQueue(false, TaskState.TASK_STATE_INPUT_REQUIRED, SAMPLE_MESSAGE);
}

Expand All @@ -208,15 +210,17 @@
checkTaskStatusUpdateEventOnQueue(false, TaskState.TASK_STATE_AUTH_REQUIRED, SAMPLE_MESSAGE);
}

@SuppressWarnings("deprecation")
@Test
public void testRequiresAuthWithFinalTrue() throws Exception {
agentEmitter.requiresAuth(true);

Check warning on line 216 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test-0-3 (17)

[removal] requiresAuth(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 216 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test-0-3 (17, multi-version)

[removal] requiresAuth(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 216 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test (17, multi-version)

[removal] requiresAuth(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 216 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test (17)

[removal] requiresAuth(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 216 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / test-cloud-deployment

[removal] requiresAuth(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 216 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 17)

[removal] requiresAuth(boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 216 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / build (windows-latest, 17)

[removal] requiresAuth(boolean) in AgentEmitter has been deprecated and marked for removal
checkTaskStatusUpdateEventOnQueue(false, TaskState.TASK_STATE_AUTH_REQUIRED, null);
}

@SuppressWarnings("deprecation")
@Test
public void testRequiresAuthWithMessageAndFinalTrue() throws Exception {
agentEmitter.requiresAuth(SAMPLE_MESSAGE, true);

Check warning on line 223 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test-0-3 (17)

[removal] requiresAuth(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 223 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test-0-3 (17, multi-version)

[removal] requiresAuth(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 223 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test (17, multi-version)

[removal] requiresAuth(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 223 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / tck-test (17)

[removal] requiresAuth(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 223 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / test-cloud-deployment

[removal] requiresAuth(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 223 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 17)

[removal] requiresAuth(Message,boolean) in AgentEmitter has been deprecated and marked for removal

Check warning on line 223 in server-common/src/test/java/org/a2aproject/sdk/server/tasks/AgentEmitterTest.java

View workflow job for this annotation

GitHub Actions / build (windows-latest, 17)

[removal] requiresAuth(Message,boolean) in AgentEmitter has been deprecated and marked for removal
checkTaskStatusUpdateEventOnQueue(false, TaskState.TASK_STATE_AUTH_REQUIRED, SAMPLE_MESSAGE);
}

Expand Down
Loading