a2aproject / a2aproject/a2a-samples

[Java Example] task stream output error

オープン
#181 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Jupyter Notebook
スター
1.8k
フォーク
751
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。