Skip to content

fix(server): send full Task on every v0.3 push trigger - #658

Merged
bartek-gralewicz merged 6 commits into
a2aproject:mainfrom
RonaldMarske:fix-push-notifications-in-v03
Aug 25, 2026
Merged

bartek-gralewicz merged 6 commits into
a2aproject:mainfrom
RonaldMarske:fix-push-notifications-in-v03

Conversation

@RonaldMarske

@RonaldMarske RonaldMarske commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

What & why

As stated in Bug #624 the v0.3 spec (§9.5, and confirmed against the v0.3.14 reference implementation), a v0.3 push notification must deliver the full Task on every trigger — task, status, and artifact updates alike. The v1 core emits per-event StreamResponses, so status/artifact triggers were being pushed as bare TaskStatusUpdateEvent / TaskArtifactUpdateEvent bodies. This restores the v0.3 contract while leaving v1 untouched (v1 push keeps mirroring the client stream verbatim, historyLength trim included).

The switch is gated on the a2a request's version (isLegacyVersion(context.requestedVersion)).

Why the code lives in DefaultRequestHandler

The snapshot has to be captured synchronously and in order, right after resultManager.processEvent(event) — the drain loop is the only place that holds the ordered event, the authoritative merged Task, and the wire version at that moment. It also carries the least legacy into the v1 code base: the sender and serializers stay version-agnostic, and the single v0.3 gate lives here.

It's also simply the most convenient place: in sendMessageStream the mapper already feeds both the client SSE yield and the push, and v0.3 streaming must stay event-shaped while only the push becomes a Task. So the mapper takes a deliveryTarget and is called once per target — raw events for the stream, full Task for the legacy push.

Why we don't read the Task in the sender

The sender is fire-and-forget, so loading the Task at dispatch time races the event stream — by the time the async read resolves, a later event may have advanced the store past the triggering state. We tried exactly this in our own code base with a DB-backed TaskStore, and it failed consistently in our tests through that race. Freezing the snapshot by value in the drain loop side-steps it.

Alternatives we considered

  • Per-config serializer plumbing — thread the frozen snapshot through send → _dispatchNotification → serialize(streamResponse, { task }) and let V03PushNotificationSerializer pick the Task. It's the more correct option (it keys the Task-vs-event choice off each webhook's registered wireVersion), but the downsides outweigh it for a v0.3-only fix:
    • carries too much legacy through the whole code base,
    • keeps the Task bubbling through every layer,
    • would push the Task to the v1 serializer, where it's useless,
    • adds unused code just to hold the interface contracts.

_mapEventToStreamResponse: dropped taskStore.load

The task case previously did await taskStore.load(taskId, context). We now read resultManager.getCurrentTask() (deep-cloned) instead — mainly a performance improvement for anyone running an alternative TaskStore (as we do with a DB): it drops a per-event store round-trip on the hot event path in favor of the in-memory task the ResultManager already holds for this request.

@RonaldMarske
RonaldMarske requested a review from a team as a code owner August 14, 2026 07:38
@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

Base PR Delta
src/compat/v0_3/server/push_notification/v03_push_notification_serializer.ts 91.17% 92.85% 🟢 +1.68%
src/server/push_notification/default_push_notification_sender.ts 96.59% 96.71% 🟢 +0.12%
src/server/request_handler/default_request_handler.ts 87.86% 87.99% 🟢 +0.13%
Total 91.19% 91.21% 🟢 +0.02%

Generated by coverage-comment.yml

@bartek-gralewicz

Copy link
Copy Markdown
Collaborator

Hey, thank you for submitting a PR on this issue. I have a comment regarding the proposal:

The code changes in this PR are taking the information about the version from the trigger and not from the moment the webhook was registered. Hence, if a v0.3 registered webhook sends a v1.0 trigger, it would receive a v1.0 StreamResponse{statusUpdate} when the v0.3 Task should be returned. Same goes the other way around (v1.0 webhook with v0.3 trigger).
Note: Expectation that the webhook registration version is the controlling component is even mentioned in the original issue (3rd clause).

I believe that src/server/push_notification/push_notification_serializer.ts might be the best location for such logic but I am open for other proposals as well.

v0.3 pushes now carry the full Task on task, status, and artefact updates as tag 0.3.14 does and aligns with the legacy behaviour.
V1 is unchanged and still sends raw events as push notification
@RonaldMarske
RonaldMarske force-pushed the fix-push-notifications-in-v03 branch from 7ea5fa0 to 3239eef Compare August 24, 2026 08:55
@RonaldMarske

Copy link
Copy Markdown
Contributor Author

Hey, thank you for submitting a PR on this issue. I have a comment regarding the proposal:

The code changes in this PR are taking the information about the version from the trigger and not from the moment the webhook was registered. Hence, if a v0.3 registered webhook sends a v1.0 trigger, it would receive a v1.0 StreamResponse{statusUpdate} when the v0.3 Task should be returned. Same goes the other way around (v1.0 webhook with v0.3 trigger). Note: Expectation that the webhook registration version is the controlling component is even mentioned in the original issue (3rd clause).

I believe that src/server/push_notification/push_notification_serializer.ts might be the best location for such logic but I am open for other proposals as well.

Hey @bartek-gralewicz , thanks for reviewing. I moved the decision to the Serializer now by handling the task all the way through as an additional parameter. This is the option i wanted to avoid but the only one i saw which still holds the snap shot of the exact moment.

Hope this is fine now. Sorry for the force push, rebased my branch to latest main.

@bartek-gralewicz

Copy link
Copy Markdown
Collaborator

Hey, thank you for submitting a PR on this issue. I have a comment regarding the proposal:
The code changes in this PR are taking the information about the version from the trigger and not from the moment the webhook was registered. Hence, if a v0.3 registered webhook sends a v1.0 trigger, it would receive a v1.0 StreamResponse{statusUpdate} when the v0.3 Task should be returned. Same goes the other way around (v1.0 webhook with v0.3 trigger). Note: Expectation that the webhook registration version is the controlling component is even mentioned in the original issue (3rd clause).
I believe that src/server/push_notification/push_notification_serializer.ts might be the best location for such logic but I am open for other proposals as well.

Hey @bartek-gralewicz , thanks for reviewing. I moved the decision to the Serializer now by handling the task all the way through as an additional parameter. This is the option i wanted to avoid but the only one i saw which still holds the snap shot of the exact moment.

Hope this is fine now. Sorry for the force push, rebased my branch to latest main.

Hey, thanks for following up on this. Are you sure that you included all of your changes after the rebase? It seems like your comment above misaligns with the PR changes at the moment.

@RonaldMarske

RonaldMarske commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Hey, thanks for following up on this. Are you sure that you included all of your changes after the rebase? It seems like your comment above misaligns with the PR changes at the moment.

Thanks for pointing out, the changes got lost on their way up - now they landed.

@bartek-gralewicz bartek-gralewicz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Added a few small suggestions. The rest looks good

1. sendMessage ends up in a race condition and might modify the history entries for tasks
2. sendMessageStream does strip the history from the event - fine in v1 not in v03.

@bartek-gralewicz bartek-gralewicz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for contributing with this change.

Note: we currently have issues with ITK testing suite which are being resolved. Disregard the failing CI check. It should be fixed shortly.

@bartek-gralewicz
bartek-gralewicz merged commit b3afbe4 into a2aproject:main Aug 25, 2026
17 of 19 checks passed
This was referenced Aug 21, 2026
bartek-gralewicz added a commit that referenced this pull request Aug 26, 2026
🤖 I have created a release *beep* *boop*
---


## [1.1.0](v1.0.1...v1.1.0)
(2026-08-26)


### Features

* make event bus keep-alive states configurable
([#669](#669))
([f844dad](f844dad)),
closes [#620](#620)


### Bug Fixes

* Add serialization for listTasks input/output parameters.
([#610](#610))
([c863497](c863497))
* clone push notification configs before storing
([#662](#662))
([4d175a0](4d175a0))
* **compat/v0_3/translate:** add null and undefined checks to array and
string fields ([#618](#618))
([108736b](108736b))
* **deps:** replace `uuid` package with `crypto.randomUUID()`
([#665](#665))
([636b060](636b060))
* Do not filter tasks in ListTasks if task state is unspecified
([#622](#622))
([1c6eb32](1c6eb32))
* **errors:** global error branding via Symbol.hasInstance to fix
instanceof checks across bundle entry points
([#612](#612))
([cc33173](cc33173))
* **scripts:** update generate script to use buf and remove obsolete
generateTypes ([#653](#653))
([8bf3cd3](8bf3cd3))
* **server:** send full Task on every v0.3 push trigger
([#658](#658))
([b3afbe4](b3afbe4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: bartek-gralewicz <[email protected]>
bartek-gralewicz pushed a commit that referenced this pull request Sep 16, 2026
…ts (#729)

# Description

The push-notification table in the compat guide still describes the
pre-#658 wire shape. It lists `TaskStatusUpdateEvent` and
`TaskArtifactUpdateEvent` as bodies a v0.3 webhook can receive, and
since #658 it never receives either.

`src/compat/v0_3/README.md` was updated by #658 and already states the
corrected behaviour:

> Per the v0.3 spec example (§9.5), a push notification **always
delivers the full `Task`** on every trigger, status and artifact updates
are sent as the current `Task` snapshot, not as a bare
`TaskStatusUpdateEvent` / `TaskArtifactUpdateEvent`.

So the two documents contradict each other today, and the guide is the
one an upgrader reads first. This aligns the guide with the README and
with what the code does.

This is the second of the three questions in #624, which asked for
exactly this to be called out for anyone moving from `0.3.14`. The other
two are answered in [a comment
there](#624 (comment)):
the behaviour itself was a regression and #658 already fixed it in
`v1.1.0`.

## Why the wording says "or a bare v0.3 `Message`"

The consolidation applies to the task, status and artifact cases. A
`message` payload still serializes to a bare v0.3 `Message` via
`toCompatMessage`, so the row names both shapes rather than only `Task`.

The delta shapes are still reachable in principle, but not through this
path: `V03PushNotificationSerializer` falls back to
`toCompatTaskStatusUpdateEvent` / `toCompatTaskArtifactUpdateEvent` when
it is handed no task snapshot. Both push call sites in
`DefaultRequestHandler` pass `resultManager.getCurrentTask()`, so the
default server never takes that branch. I left that nuance out of the
table deliberately, since the table documents what a webhook receives
rather than the serializer's full surface, but say the word if you would
rather it were spelled out.

## Verification

Docs only, no source change.

- Checked the claim against the code rather than the issue text: at
`v1.0.1` the serializer was `serialize(streamResponse)` with no task
parameter, and on `main` it is `serialize(streamResponse, task?)` with
`toCompatTask(task)` on the `statusUpdate` and `artifactUpdate` arms.
- `git tag --contains b3afbe4` returns `v1.1.0` only, so the fix is not
in `v1.0.1`.
- `test/server/push_notification_integration.spec.ts` drives a real
executor through a v0.3-registered webhook and asserts all three
notifications come back `kind: 'task'` with states `submitted` /
`working` / `completed`. 18/18 pass on `main`.
- `npm run lint:ci` exit 0, which is what covers prettier on this file.
- `npm test` 71 files, 1571 passed, 5 todo.
- The file was prettier-clean before this change, verified by stashing
and re-checking, so the table's column-width churn in the diff comes
from this edit and not from pre-existing drift.

`build-tests.yml` has `paths-ignore: '**.md'`, so the build matrix does
not run on this one.

- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/a2aproject/a2a-js/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- [x] Ensure the tests and linter pass
- [x] Appropriate docs were updated (if necessary)

Refs #624
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.

2 participants