Repository navigation
fix(server): send full Task on every v0.3 push trigger - #658
bartek-gralewicz merged 6 commits into
Conversation
🧪 Code Coverage
Generated by coverage-comment.yml |
|
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 I believe that |
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
7ea5fa0 to
3239eef
Compare
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. |
Thanks for pointing out, the changes got lost on their way up - now they landed. |
bartek-gralewicz
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
🤖 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]>
…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
What & why
As stated in Bug #624 the v0.3 spec (§9.5, and confirmed against the
v0.3.14reference implementation), a v0.3 push notification must deliver the fullTaskon every trigger — task, status, and artifact updates alike. The v1 core emits per-eventStreamResponses, so status/artifact triggers were being pushed as bareTaskStatusUpdateEvent/TaskArtifactUpdateEventbodies. This restores the v0.3 contract while leaving v1 untouched (v1 push keeps mirroring the client stream verbatim,historyLengthtrim included).The switch is gated on the a2a request's version (
isLegacyVersion(context.requestedVersion)).Why the code lives in
DefaultRequestHandlerThe 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 mergedTask, 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
sendMessageStreamthe mapper already feeds both the client SSEyieldand the push, and v0.3 streaming must stay event-shaped while only the push becomes aTask. So the mapper takes adeliveryTargetand is called once per target — raw events for the stream, fullTaskfor 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
send→_dispatchNotification→serialize(streamResponse, { task })and letV03PushNotificationSerializerpick theTask. It's the more correct option (it keys the Task-vs-event choice off each webhook's registeredwireVersion), but the downsides outweigh it for a v0.3-only fix:Taskbubbling through every layer,Taskto the v1 serializer, where it's useless,_mapEventToStreamResponse: droppedtaskStore.loadThe
taskcase previously didawait taskStore.load(taskId, context). We now readresultManager.getCurrentTask()(deep-cloned) instead — mainly a performance improvement for anyone running an alternativeTaskStore(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 theResultManageralready holds for this request.