mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Ignore AsyncGenerator return types in function declarations
For Vertex model backend, we send response back. This doesn't work for streaming tools that the return type is AsyncGenerator. So the fix here is to ignore the return type when it's AsyncGenerator. We can't distinguish streaming vs non-streaming tool with AsyncGenerator though as LiveRequestQueue is optional in streaming tool. Adds an `ignore_response` option to `build_function_declaration` to skip including the return type in the function declaration. This is enabled for tools that return `AsyncGenerator`, as the model does not yet support understanding these return types, while streaming tools can still handle them. Also, removes redundant return statements in `_get_mandatory_params`. PiperOrigin-RevId: 794392846
This commit is contained in:
committed by
Copybara-Service
parent
8c65967cdc
commit
e2518dc371
@@ -22,6 +22,7 @@ from google.adk.tools.base_tool import BaseTool
|
||||
from google.adk.tools.tool_context import ToolContext
|
||||
from google.genai import types
|
||||
import pytest
|
||||
from typing_extensions import override
|
||||
|
||||
|
||||
class _TestingTool(BaseTool):
|
||||
@@ -33,7 +34,10 @@ class _TestingTool(BaseTool):
|
||||
super().__init__(name='test_tool', description='test_description')
|
||||
self.declaration = declaration
|
||||
|
||||
def _get_declaration(self) -> Optional[types.FunctionDeclaration]:
|
||||
@override
|
||||
def _get_declaration(
|
||||
self, ignore_return_declaration: bool = False
|
||||
) -> Optional[types.FunctionDeclaration]:
|
||||
return self.declaration
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user