Skip to content

fix(a2a-server): begin a task stream with the task object - #587

Merged
muscariello merged 6 commits into
a2aproject:mainfrom
joulook:fix/task-first-stream
Nov 27, 2026
Merged

muscariello merged 6 commits into
a2aproject:mainfrom
joulook:fix/task-first-stream

Conversation

@joulook

@joulook joulook commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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_message relayed the executor's first event, and the examples, ITK and ACTS agents open with a status update.

Change. 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.

Tests. Six new; the regression test is test_status_first_stream_begins_with_the_task. Built and tested on main 32b3f4d (rustc 1.99.1): a2a-server 284 pass (278 before), workspace 1 014 (1 008), clippy --all-targets -D warnings and fmt --check clean; 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 (of 700a6a2) 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_stream now 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_REQUIRED with its question in status.message), before the new turn's updates; a client that reads status.message from every Task event sees the earlier question again before the answer.

@joulook
joulook requested a review from a team as a code owner November 22, 2026 01:28
Copilot AI balanced review requested due to automatic review settings November 22, 2026 01:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

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]>
@joulook
joulook force-pushed the fix/task-first-stream branch from 5ff8e49 to 617b237 Compare November 24, 2026 20:54
Copilot AI balanced review requested due to automatic review settings November 24, 2026 20:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@muscariello muscariello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  1. The quickstart page now disagrees with the server. docs/quickstart/agent/streaming-and-multi-turn.md shows the SendStreamingMessage call as five events starting with a statusUpdate and says "There are five events". With this change the same call returns six, the first a task in TASK_STATE_SUBMITTED. The page needs the new sample output and count, in this PR since it changes what the page shows.
  2. A continuation opens with the previous state. The Task that now starts turn two of the greeter is the stored one: INPUT_REQUIRED with 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 reads status.message from every Task event will see the old question again before the answer. A line in the description would help.
  3. 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.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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]>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@joulook

joulook commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for running the greeter.

  1. Done in d30e16b, a new commit on top of your merge, for both quickstart pages. streaming-and-multi-turn.md now
    shows six events, the first a task in TASK_STATE_SUBMITTED, and says "six". The a2acli page's --stream
    sample begins with a State: SUBMITTED block. Both are real output on this branch.
  2. The description now notes the continuation case: turn two opens with the stored Task as the turn found it
    (INPUT_REQUIRED, with its question in status.message), before the answer's updates.
  3. We will watch ACTS (STREAM-SSE-001) and ITK once the workflows are approved.

On this head, a2a-server-lf has 300 tests and the workspace 1 041, all passing; clippy and fmt are clean.

@muscariello muscariello reopened this Nov 26, 2026
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]>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 19:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@joulook

joulook commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The CI failure after the reopen was test_cancel_push_failure_ends_running_stream from #554, which read the stream's first item as the working status. With this change the stream begins with the Task object, so the test now takes the task id from that item and reads the working status second (a38cacf, on top of a merge of current main). The a2a-server suite passes locally (311 tests).

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]>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 20:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@muscariello muscariello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

send_streaming_message does not begin the stream with the task object when the executor opens the task with a status update (spec §3.1.2)

3 participants