[Bug]: Response Stream Array-Wrapping Crash (Transport Layer Mismatch)

Aperta
#1,089 6 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@ishymko ci sta già lavorando.

Dal 30/6/2026.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Ambito
api, backend

Direzione di ricerca

Esamina la discrepanza nel livello di trasporto in a2a/compat/v0_3/rest_transport.py (CompatRestTransport) e a2a/client/transports/rest.py. Il problema è che il transport di compatibilità non aggiunge ?alt=sse agli URL degli endpoint di streaming, facendo sì che Google racchiuda le risposte in un array JSON. Parse del transport standard si aspetta un singolo oggetto JSON. Inizia esaminando come vengono costruiti gli URL di streaming e dove dovrebbe essere aggiunto il parametro alt=sse. Controlla la logica di parsing degli eventi SSE. «Done» significa che le risposte di streaming funzionano senza il workaround lato client.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

component: client
What happened?

This is continuation from #1074 as splitting into two issues are suggested by @ishymko

Copied the issue description below for context

Response Stream Array-Wrapping Crash (Transport Layer Mismatch)

By default, Google wraps streaming RPC responses (Flow<StreamResponse>) inside a JSON array [ {"task": ...} ] to frame stream chunk boundaries on the wire.

  • The Mismatch: The SDK's legacy compatibility transport (CompatRestTransport inside a2a/compat/v0_3/rest_transport.py) fails to request standard SSE transcoding from Google because it does not append the standard ?alt=sse query parameter to the stream endpoint URL. This forces Google to fall back to default plain JSON array-wrapped streams.
  • The Crash: Standard transports in a2a/client/transports/rest.py parse stream events using standard Parse (from google.protobuf.json_format):
    event: StreamResponse = Parse(sse_data, StreamResponse())
    
    Because standard Parse strictly expects a single JSON object {...}, the leading and trailing array brackets ([ and ]) cause json_format.Parse to crash immediately on the very first chunk:
    google.protobuf.json_format.ParseError: Failed to parse {'task': {...}} field: unhashable type: 'dict'.
    

Thanks for pointing this issue is not specific to v0.3 but v1 as well. Regarding the workaround mentioned in https://github.com/a2aproject/a2a-python/issues/1074#issuecomment-4555290758 , yes it will work with the workaround but this mean all the customer/developer who integrated with Google A2A APIs will require this workaround introduces developer friction. Is there any way we could make this smoother so developer can use SDK with Google A2A API out of the box? Thanks!

Code of Conduct
  • I agree to follow this project's Code of Conduct
Lingua principale
Python
Stelle
2.2k
Fork
496
Merge medio
1g 23h
PR unite (30g)
16

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di a2aproject/a2a-python

Tutte le issue di a2aproject/a2a-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.