a2aproject / a2aproject/a2a-samples

[Java Example] task stream output error

Abierto
#181 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
1.8k
Forks
751
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### What happened?

In A2AClient.java

public CompletableFuture sendTaskStreaming(TaskSendParams params, StreamingEventListener listener) {

..........

HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(baseUrl + "/a2a/stream"))
.header("Content-Type", "application/json")
.header("Accept", "text/event-stream")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();

HttpResponse response = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());

if (response.statusCode() != 200) {
listener.onError(new A2AClientException("HTTP " + response.statusCode() + ": " + response.body()));
return;
}

this code snnipet here is not stream out,should use like `HttpResponse.BodyHandlers.ofLines()` or ` HttpResponse.BodyHandlers.ofInputStream()` instead

after modify:

=== Streaming Translation (French to English) ===
Original French: Bonjour le monde! Comment allez-vous?
当前时间: 2025-06-25 19:58:43:354
Streaming translation event: {id=french-streaming-task, status={state=working, timestamp=2025-06-25T11:58:43.339288800Z}, final=false}
当前时间: 2025-06-25 19:58:44:250
Streaming translation event: {id=french-streaming-task, status={state=completed, timestamp=2025-06-25T11:58:44.249476800Z}, final=true}
Translation streaming completed
Streaming translation finished successfully

before modify:

=== Streaming Translation (French to English) ===
Original French: Bonjour le monde! Comment allez-vous?
当前时间: 2025-06-25 20:12:07:251
Streaming translation event: {id=french-streaming-task, status={state=working, timestamp=2025-06-25T12:12:06.439230200Z}, final=false}
当前时间: 2025-06-25 20:12:07:252
Streaming translation event: {id=french-streaming-task, status={state=completed, timestamp=2025-06-25T12:12:07.237351500Z}, final=true}
Translation streaming completed
Streaming translation finished successfully


look at the difference of time output above

### Relevant log output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.