We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
ToolContext
tool_context
1 parent 93aad61 commit f31226eCopy full SHA for f31226e
1 file changed
src/google/adk/tools/_function_parameter_parse_util.py
@@ -29,6 +29,7 @@
29
from google.genai import types
30
import pydantic
31
32
+from ..tools.tool_context import ToolContext
33
from ..utils.variant_utils import GoogleLLMVariant
34
35
_py_builtin_type_to_schema_type = {
@@ -315,6 +316,13 @@ def _parse_schema_from_parameter(
315
316
)
317
_raise_if_schema_unsupported(variant, schema)
318
return schema
319
+ if inspect.isclass(param.annotation) and issubclass(
320
+ param.annotation, ToolContext
321
+ ):
322
+ raise ValueError(
323
+ '`ToolContext` parameter must be named as `tool_context`. Found'
324
+ f' `{param.name}` instead in function `{func_name}`.'
325
+ )
326
if param.annotation is None:
327
# https://swagger.io/docs/specification/v3_0/data-models/data-types/#null
328
# null is not a valid type in schema, use object instead.
0 commit comments