Repository navigation
fix: Keep stream open on interrupted state changes - #756
Conversation
There was a problem hiding this comment.
Code Review
This pull request correctly resolves an issue where event streams were prematurely closing for tasks in an interrupted state, such as INPUT_REQUIRED. The fix aligns the stream termination logic in EventConsumer with the A2A protocol specification, ensuring streams only terminate when a task reaches a final state. The refactoring of the TaskState enum to explicitly define and track isInterrupted states is a solid design improvement that enhances code clarity. Additionally, the new integration test, testSubscribeToTaskWithInterruptedStateKeepsStreamOpen, provides excellent coverage and validation for the corrected behavior. The changes are well-implemented and I have no further suggestions.
|
@kabir The JSON-RPC reproducer still fails: At this point, the task is in TASK_STATE_INPUT_REQUIRED. BTW, the At this point, I was expecting the request to stay open until I complete the task with another message such as: |
The EventConsumer grace period logic was incorrectly closing the queue after agent completion, even when the task was in an interrupted state (INPUT_REQUIRED or AUTH_REQUIRED). Per A2A Protocol Specification 3.1.6, streams must remain open for interrupted states to receive future state updates, regardless of whether the agent has completed. Changes: - Track last seen task state in EventConsumer - Prevent grace period queue close if task is in interrupted state - Add logging for interrupted state detection This fixes the issue where SubscribeToTask would close immediately after delivering the initial Task snapshot for INPUT_REQUIRED tasks. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
@jmesnil I've tried to make the test do what the reproducer does |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request provides a critical fix to ensure that event streams remain open for tasks in an interrupted state (like INPUT_REQUIRED), adhering to the A2A specification. The changes are well-implemented across several files. In EventConsumer, the logic for closing the stream is corrected to check for interrupted states. The TaskState enum is refactored to explicitly include the concept of an "interrupted" state, which is a great design improvement that enhances clarity and maintainability. The isStreamTerminatingTask method is also corrected. The changes are supported by excellent tests, including an updated unit test and a new, comprehensive integration test that thoroughly validates the end-to-end behavior. The code quality is high, and the fix appears robust and correct.

Fixes #754