a2aproject / a2aproject/a2a-samples

[Java Example] task stream output error

Open
#181 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.8k
Forks
751
PR merge metrics
No merged PRs in 30d

Description

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.