Repository navigation
fix(a2a-server): begin a task stream with the task object - #587
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Spec 3.1.2: "If the agent returns a `Task`, the stream MUST begin with the Task object". `send_streaming_message` relayed the executor's first event, and the examples, ITK and ACTS agents open with a status update. `start_execution` also returns the task the execution starts from (a new SUBMITTED task, or the stored task with the turn's message), taken before the executor starts. When the stream's first item is a status or artifact update, `send_streaming_message` emits that task first; it is the state before the update, so nothing is delivered twice. A first Task, a Message, an error, `send_message`, subscriptions and push notifications are unchanged. Fixes: a2aproject#585 Signed-off-by: Mohammad Hossein Khoshechin Jorshari <[email protected]>
5ff8e49 to
617b237
Compare
muscariello
left a comment
There was a problem hiding this comment.
The change is sound: open_with_task prepends the task the execution started from only when the first item is a status or artifact update, so a Task-first stream, a Message answer, an error and the subscriptions are untouched, and nothing is delivered twice (the artifact test shows the Task does not carry the artifact). I merged this onto current main and ran a2a-server-lf (291 unit, 8 integration, 1 doc), a2a-client-lf, a2a-grpc and a2a-cli: all pass. Running the quickstart greeter, hello now streams task SUBMITTED, statusUpdate INPUT_REQUIRED.
- The quickstart page now disagrees with the server.
docs/quickstart/agent/streaming-and-multi-turn.mdshows theSendStreamingMessagecall as five events starting with astatusUpdateand says "There are five events". With this change the same call returns six, the first ataskinTASK_STATE_SUBMITTED. The page needs the new sample output and count, in this PR since it changes what the page shows. - A continuation opens with the previous state. The Task that now starts turn two of the greeter is the stored one:
INPUT_REQUIREDwith its status message "Who should I greet?". That is the right "as the turn found it" snapshot and the test pins the state, but a client that readsstatus.messagefrom every Task event will see the old question again before the answer. A line in the description would help. - ACTS and ITK are the check for event counters. STREAM-SSE-001 counts events and ITK reads
Task.status.message; I could not run either locally and the workflows are waiting for approval. Worth watching once they run.
The streaming send now begins with the task. The quickstart's `SendStreamingMessage` sample has six events, the first a `task` in `TASK_STATE_SUBMITTED`, and the a2acli page's `send --stream` sample begins with a `State: SUBMITTED` block. Both match the greeter's output on this branch. Signed-off-by: Mohammad Hossein Khoshechin Jorshari <[email protected]>
|
Thanks for the review and for running the greeter.
On this head, |
test_cancel_push_failure_ends_running_stream (a2aproject#554) read the stream's first item as the working status. Since the stream now begins with the Task object, the test takes the task id from that item and reads the working status second. Signed-off-by: Mohammad Hossein Khoshechin Jorshari <[email protected]>
|
The CI failure after the reopen was |
The shape checks of the task-first tests, and the first-item check of the push-failure test, had a failure arm that never runs, which the patch coverage counted as uncovered lines. The tests now assert the stream's shape and take each item through one test macro, so the failure paths no longer occupy lines of their own. Signed-off-by: Mohammad Hossein Khoshechin Jorshari <[email protected]>
This change was found and re-checked with Daavar, a conformance checker we develop at MPI-SWS (https://github.com/joulook/daavar); the issue it fixes is #585.
Spec §3.1.2 (L187): "If the agent returns a
Task, the stream MUST begin with the Task object".send_streaming_messagerelayed the executor's first event, and the examples, ITK and ACTS agents open with a status update.Change.
start_executionalso returns the task the execution starts from (a new SUBMITTED task, or the stored task with the turn's message), taken before the executor starts. When the stream's first item is a status or artifact update,send_streaming_messageemits that task first; it is the state before the update, so nothing is delivered twice. A first Task, a Message, an error,send_message, subscriptions and push notifications are unchanged.Tests. Six new; the regression test is
test_status_first_stream_begins_with_the_task. Built and tested onmain32b3f4d(rustc 1.99.1):a2a-server284 pass (278 before), workspace 1 014 (1 008), clippy--all-targets -D warningsandfmt --checkclean;cargo hack --each-feature, the header check and coverage are left to CI.Re-check (evidence at tag
a2a-fixes-2026-11-21). The re-check model (of700a6a2) mirrors this PR and #586's fix together. Unit: N/M = behaviours of the SDK's visible roles (sequences of sends and receives with final statuses) that the specification program does not produce, out of M explored: one server 10/16 before, 1/16 after; summed over all 14 scenarios, 112 before, 24 after. Of these behaviours, all 86 that began a stream with a status update are gone (this PR), and so are the 3 with a status after a Message (the other PR); one word had both the status item and a kept task, so the counts overlap by one. The 24 left are 6 kept-task words (a2aproject/A2A#2498) and 18 error-only streams at a downstream server that only a restriction of our specification program rejects (a2aproject/A2A#2497). The ACTS suite has no test for the first event of a streaming send.Fixes: #585
Rebased on main; the new upstream test
test_empty_cancel_unblocks_running_streamnow also asserts that the stream begins with the Task.Continuation turns: the Task that opens turn two is the stored one as the turn found it (for the greeter,
INPUT_REQUIREDwith its question instatus.message), before the new turn's updates; a client that readsstatus.messagefrom every Task event sees the earlier question again before the answer.