Skip to content

fix(client): skip stream events whose payload kind is not recognised - #770

Merged
JakubWorek merged 2 commits into
a2aproject:mainfrom
harshitwandhare:fix/skip-unknown-stream-payloads
Oct 14, 2026
Merged

JakubWorek merged 2 commits into
a2aproject:mainfrom
harshitwandhare:fix/skip-unknown-stream-payloads

Conversation

@harshitwandhare

@harshitwandhare harshitwandhare commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What was broken

When a server sends a StreamResponse with a payload kind this SDK does not know, StreamResponse.fromJSON drops the unknown key and the client yields { payload: undefined } to the caller. Every caller then has to special-case an event that carries nothing. Hit it with a local SSE server sending task, then {"futureUpdate": {...}}, then statusUpdate:

main    rest    ["task","undefined","statusUpdate"]
main    jsonrpc ["task","undefined","statusUpdate"]
main    grpc    ["task","undefined","statusUpdate"]
branch  rest    ["task","statusUpdate"]
branch  jsonrpc ["task","statusUpdate"]
branch  grpc    ["task","statusUpdate"]

Background

This came out of a2aproject/A2A#2269. The TSC agreed that adding a payload kind should not break existing clients, and @herczyn added wording to the bidi PR (a2aproject/A2A#2153) saying a client that gets a StreamResponse payload kind it does not recognise MUST skip it and keep reading the stream.

What the fix does

Client.sendMessageStream and Client.resubscribeTask skip any event with no payload before it reaches the after-interceptors or the caller, then keep reading. Doing it in Client puts the rule in one place for every transport. I checked REST, JSON-RPC and gRPC end to end. Over gRPC, ts-proto drops the unknown field and the frame decodes to {}, so the same skip applies. The Transport classes are unchanged, so anyone driving a transport directly still sees the raw events.

How it was verified

  • Three new tests in test/client/multitransport-client.spec.ts. The sendMessageStream and resubscribeTask ones fail on main (expected [ 'task', undefined, 'task' ] to deeply equal [ 'task', 'task' ]) and pass here.
  • The end-to-end run above, through the real RestTransport, JsonRpcTransport and GrpcTransport (sendMessageStream only for gRPC).
  • npm test on 2c81b86: 1844 passed on the branch, 1841 on main. On my Windows machine both runs also fail the same sqlite push-store test, in its afterEach cleanup (rmSync of the temp dir gets EPERM). I installed with --ignore-scripts on both sides.
  • npm run lint:ci, npm run build, and the workers-safe, grpc and express build checks all pass.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

Base PR Delta
src/client/multitransport-client.ts 97.32% 97.36% 🟢 +0.04%
src/types/protojson.ts 54.47% 54.68% 🟢 +0.21%
Total 86.75% 86.79% 🟢 +0.04%

Generated by coverage-comment.yml

@harshitwandhare

Copy link
Copy Markdown
Contributor Author

I ran the gRPC path too, which the description said I hadn't. A grpc-js server streams raw bytes into the real GrpcTransport and Client.sendMessageStream: a task, then a frame with only field 9 set (a payload kind this SDK doesn't know), then a statusUpdate. ts-proto drops the unknown field, so that frame decodes to {}.

main    grpc ["task","undefined","statusUpdate"]
branch  grpc ["task","statusUpdate"]

gRPC behaves the same as REST and JSON-RPC. I only drove sendMessageStream this way, not resubscribeTask. I've updated the description to match.

@harshitwandhare
harshitwandhare force-pushed the fix/skip-unknown-stream-payloads branch 4 times, most recently from c3fcd0d to 94187ee Compare October 8, 2026 13:56
A StreamResponse with a payload kind the SDK does not know decodes to an
event with no payload, and Client yielded it to the caller. Skip it in
sendMessageStream and resubscribeTask and keep reading, per the forward
compatibility rule agreed in a2aproject/A2A#2269.
@harshitwandhare
harshitwandhare force-pushed the fix/skip-unknown-stream-payloads branch from 94187ee to 11bef60 Compare October 9, 2026 13:32

@JakubWorek JakubWorek 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.

Thank you. Putting this check in the Client is the right spot, it covers all transports

@JakubWorek
JakubWorek merged commit cf8ccff into a2aproject:main Oct 14, 2026
19 checks passed
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