feat: Enforce Task or Message as an initial response for Send Streaming Message#964
Closed
sokoliva wants to merge 7 commits intoa2aproject:1.0-devfrom
Closed
feat: Enforce Task or Message as an initial response for Send Streaming Message#964sokoliva wants to merge 7 commits intoa2aproject:1.0-devfrom
Task or Message as an initial response for Send Streaming Message#964sokoliva wants to merge 7 commits intoa2aproject:1.0-devfrom
Conversation
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/server/request_handlers/default_request_handler_v2.py | 92.67% | 92.95% | 🟢 +0.27% |
| Total | 92.49% | 92.50% | 🟢 +0.01% |
Generated by coverage-comment.yml
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a README for the samples directory and refactors the CLI sample to use utility functions for message and artifact text extraction. It also adds gRPC channel factory configuration. Feedback includes correcting the sample count in the documentation and improving the robustness of task ID assignment in the CLI while removing redundant checks.
samples/cli.pyTask or Message as an initial response for Send Streaming Message
Comment on lines
+327
to
+332
| submitted_task = Task( | ||
| id=task_id, | ||
| context_id=context_id, | ||
| status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED), | ||
| history=[params.message], | ||
| ) |
Member
There was a problem hiding this comment.
The task_manager is already covering this use case, we can use the task created and saved on the task store
Member
Author
|
Proceeding with a different solution - should emit error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The A2A spec (§3.1.2) requires that the first event in a streaming response is always a Task or Message object. However, agents commonly emit TaskStatusUpdateEvent(WORKING) as their first event without explicitly emitting a Task first. Previously the v2 handler forwarded these events as-is, violating the spec.
Changes
default_request_handler_v2.py: when the v2 handler (DefaultRequestHandlerV2) receives a new streaming request and the agent's first event is not a Task or Message, it now injects aTask(SUBMITTED)before forwarding the agent's event.samples/cli.pyto reflect changes insend_messagereturn typesamples/cli.pyto expectTaskorMessageas first streaming eventREADME.mdfor samplesget_artifact_text,get_message_texthelpers insamples/cli.pyTested
Changes seen in
tests/integration/test_scenarios.pyNote
The legacy handler (
DefaultRequestHandler) is intentionally left unchanged to avoid breaking existing users who consume its streaming output directly. Also,spec v0.3does not define the initial event in send stream message.Fixes: #965