fix: Keep stream open on interrupted state changes#756
fix: Keep stream open on interrupted state changes#756kabir wants to merge 3 commits intoa2aproject:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where task event streams were prematurely closed when a task entered an interrupted state, such as INPUT_REQUIRED. By refining the TaskState classification and updating the stream termination logic to align with the A2A Protocol Specification, streams will now correctly persist through interrupted states, allowing for subsequent updates, and will only terminate when a task reaches a definitive final state. This ensures a more robust and compliant event streaming experience. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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