a2aproject / a2aproject/a2a-inspector

[Bug]: Streaming chat fails with "received a streamed Message from the server after first response" (a2a-sdk 0.3.10)

Aperta
#153 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
490
Fork
152
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### What happened?

Sending a chat message to an A2A agent whose card advertises `streaming: true` fails with:

```
Failed to send message: Invalid state error: received a streamed Message from the server after first response; this is not supported
```

The Inspector backend catches the exception and surfaces it to the chat UI.

### Reproduction

1. `docker run -d -p 8080:8080 ` (pinned `a2a-sdk==0.3.10` via `uv.lock`).
2. Connect to an agent card with `capabilities.streaming=true` and `url=.../message:stream` (e.g. an **Agno AgentOS** server exposing `/a2a/agents/{id}/.well-known/agent-card.json`, whose `message:stream` SSE returns a `Task` event followed by a `Message`).
3. Send "Hello" in the chat.

### Expected

The agent's streamed response is displayed.

### Actual

`A2AClientInvalidStateError` is raised; no response shown.

### Root cause

`backend/app.py` creates `ClientConfig` without `streaming=False`, so the client uses streaming. The pinned `a2a-sdk` v0.3.10 raises the error in `src/a2a/client/base_client.py:108-111` when a `Message` appears after the first event in a Task-based stream — it only allows either a single `Message` response or a pure Task-update stream (no trailing `Message`):

```python
async def _process_response(self, tracker, event):
if isinstance(event, Message):
raise A2AClientInvalidStateError(
'received a streamed Message from server after first response; this is not supported')
```

This strict check was removed in the refactored `send_message` of `a2a-sdk` `main`/v1.x (no `A2AClientInvalidStateError`), so newer SDK no longer fails on `Task`→`Message` streams.

`uv.lock` pins `a2a-sdk==0.3.10` (https://github.com/a2aproject/a2a-inspector/blob/main/uv.lock#L87), so the official image is affected.

### Workaround

Add `streaming=False` to the `ClientConfig` in `backend/app.py` to use `message/send` (non-streaming). Loses live streaming but unblocks chat/inspection. Server must expose `message:send` (Agno AgentOS does).

### Suggested fix

- Bump `a2a-sdk` to the latest (v1.x) in `pyproject.toml`/`uv.lock` and re-verify backend imports, **or**
- Expose a UI/config toggle to disable streaming, and/or relax handling of `Message` after Task events.

### Environment

- Inspector: latest `main`, `a2a-sdk==0.3.10`
- Agent server: Agno AgentOS (A2A JSON-RPC transport, `streaming: true`)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

The issue is in backend/app.py where ClientConfig is created. First, examine the pyproject.toml and uv.lock files to understand the current a2a-sdk version (0.3.10). The fix involves updating the dependency to a newer version (v1.x) that removes the strict check. Check the a2a-sdk changelog and update the lockfile. Then, verify that the backend imports and the streaming functionality still work correctly with the new SDK version. Run the reproduction steps to confirm the fix.

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

Valutazione

Stack tecnologico
python, typescript
Ambito
api, backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
65/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.