Repository navigation
Description
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
Activity
kabir commentedon May 13, 2026
Hi, 1.0.0 will have a compat layer for 0.3. We'll hopefully do a release candidate next week.
However, we are also putting important fixes into the 0.3.x branch. I don't remember if we have done anything about what you mention though. Have you tried with a snapshot built from there?
EDIT: The issue is that for 1.0 we totally refactored how the event queues worked, and introduced a background 'processor' for the events. For 0.3 this was kind of driven by the view layer, which wasn't ideal
fluxehub commentedon May 13, 2026
Hi @kabir, can confirm this issue persists in 0.3.4-SNAPSHOT. As for the compat layer, because the actual library API surface has changed, ADK will still need to be updated regardless (many of the method names have changed for example) - I opened an issue over there for that.
fluxehub commentedon May 14, 2026
@kabir I'd also be happy to look at contributing a patch for the 0.3 version in the meantime if you think that might be helpful?
kabir commentedon May 14, 2026
@fluxehub That would be great! I'm pretty tied up with 1.0 at the moment :-)
fluxehub commentedon May 14, 2026
@kabir Sure thing! Is there a CLA/CCLA to sign? Legal is happy to approve if not, but it may help others in future as well!
kabir commentedon May 14, 2026
@fluxehub No, no paperwork needed :-) The only thing is we need whitelist your first contribution for CI.
FYI when working in this area the TCK is often the stumbling block so you might want to try running that before opening the PR. Hopefully what it does in https://github.com/a2aproject/a2a-java/blob/0.3.x/.github/workflows/run-tck.yml is clear enough to get you up to speed :-)
Thanks!
fluxehub commentedon Jun 26, 2026
Hi @kabir, just wanted to follow up since it's been a while. Unfortunately, for other reasons our team has had to move back to the Python ADK, so I won't be able to provide support on fixing this issue 😭.