[Bug]: 0.3.3.Final - Agent terminates early when ADK tool returning RxJava Single hops threads

オープン
#872 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@malladinagarjuna2 がすでに取り組んでいます。

2026年8月9日 から。

  • #1027 @malladinagarjuna2 による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
kotlin

調査の方向性

バグは DefaultRequestHandler の cleanupProducer メソッドにあり、RxJava Single がスレッドを切り替えると ChildQueue が早期に閉じられます。Agent エンドポイントの処理と、非同期のツール結果をどのように待機しているかを確認してください。まず、別の Dispatcher 上で rxSingle を使用する Kotlin ツールで再現してください。1.0.0 の AgentEmitter を使った修正を確認し、解決方法を理解してください。修正には、適切な同期、または新しいスレッド上で Single の完了を待機する処理が含まれる可能性があります。

索引モデルが issue の本文から書いたものです。

説明

What happened?

When an ADK tool returns an RxJava Single executes on a different thread to the executor, the agent endpoint returns right after the function call is made. I noticed this bug using Kotlin, where using rxSingle executes on the global dispatcher, rather than the executor, e.g:

@Schema(description = "Get the weather summary in a city")
fun getWeather(@Schema(name = "city", description = "City to query") city: String): Single<Map<String, Any>> {
    return rxSingle {
        mapOf<String, Any>("result" to "It's 50 degrees and partly cloudy in $city")
    }
}

When running an agent with this tool, e.g. with message/send, the result cuts out after the tool call.

{
  "jsonrpc": "2.0",
  "id": "cli-check-2",
  "result": {
    "id": "565c05e1-8bfc-414c-950e-80d74e14350c",
    "contextId": "cli-demo-context",
    "status": {
      "state": "working",
      "timestamp": "2026-05-12T15:09:36.256177Z"
    },
    "artifacts": [
      {
        "artifactId": "80c03215-3225-4108-9f7f-040d5ad2ec82",
        "parts": [
          {
            "data": {
              "name": "getWeather",
              "id": "adk-183771c0-58a0-4f1b-87e9-d406ffaef646",
              "args": {
                "city": "Edinburgh"
              }
            },
            "metadata": {
              "adk_type": "function_call"
            },
            "kind": "data"
          }
        ],
        "metadata": {}
      }
    ],
    "history": [
      {
        "role": "user",
        "parts": [
          {
            "text": "What is the weather in Edinburgh?",
            "kind": "text"
          }
        ],
        "messageId": "cli-check-2",
        "contextId": "cli-demo-context",
        "taskId": "565c05e1-8bfc-414c-950e-80d74e14350c",
        "kind": "message"
      }
    ],
    "kind": "task"
  }
}

Using rxSingle(Dispatchers.Unconfined) works only if the function never actually suspends, otherwise the issue persists. A Java equivalent would be to e.g. call .subscribeOn(Schedulers.io()) on the Single, or any other change of Scheduler.

The issue appears to be in the cleanupProducer method of the DefaultRequestHandler, where the ChildQueue is closed prematurely. It does appear to be fixed in 1.0.0 with AgentEmitter - but I'm unsure if we'll be able to adopt it yet as the ADK doesn't support it (I've raised an issue for it here). Is there any chance a fix could be backported to 0.3? I'm happy to provide help if needed.

Code of Conduct
  • I agree to follow this project's Code of Conduct
主要言語
Java
スター
514
フォーク
200
平均マージ
1日 2時間
マージ済み PR(30日)
53

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

a2aproject/a2a-java のほかの issue

a2aproject/a2a-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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