fix: function is not found in the tools_dict #2289
Open
+2
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix issues #1532
Problem
This issue is caused by the following reasons:

When using certain models (such as doubao-1-5-pro-256k-250115) in the context of
stream=True
and tool invocation, anempty funciton_call
may occur. Specifically, the name field of function_call isNone
orempty string
. This PR resolves this bug by filtering this field in the function.As shown in the figure:
Solution
Filter out empty function calls in advance in
handle_function_calls_async
Testing plan
In the scenario of the current version (google-adk==1.9.0), when executing the following code using
adk web
(please add the two environment variablesark_api_key
andapi_base_url
), this bug may be reproduced (not guaranteed, but highly likely).I only tried this model and found that this bug can be reproduced relatively stably. For other issues mentioned in #1532, they should be similar, but I don't have his model.
Before fixing:

After fixing:
