-
Notifications
You must be signed in to change notification settings - Fork 144
Description
Describe the bug
In Python, long-running tools can return None, which means their response is not recorded into an Event (and therefore not fed into the model). This is implemented here.
In Java, BaseTool::runAsync returns Single<...>, which means they must provide a return value, even if they're long-running. This causes the invocation to continue calling the LLM instead of ending. Ideally, BaseTool::runAsync should be returning Maybe<...> instead. There is some code to handle a null response here akin to the python one , but the BaseTool API simply doesn't allow returning null.
A (hacky) workaround is to call toolContext.actions().setEndInvocation(true) and then delete or filter out the initial response event before the next invocation with the real tool response.
To Reproduce
Self evident, just try creating a tool with a return type like Maybe
public Single<Map<String, Object>> runAsync(Map<String, Object> args, ToolContext toolContext) { |
Expected behavior
Long running tools should be allowed to return empty function responses
Desktop (please complete the following information):
- ADK version: latest