You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
docs: Update the error message for function parameter ToolContext not named as tool_context
Fixes https://github.com/google/adk-python/issues/1530 Co-authored-by: Xuan Yang <xygoogle@google.com> PiperOrigin-RevId: 830248414
This commit is contained in:
committed by
Copybara-Service
parent
93aad61198
commit
f31226ee92
@@ -29,6 +29,7 @@ from typing import Union
|
||||
from google.genai import types
|
||||
import pydantic
|
||||
|
||||
from ..tools.tool_context import ToolContext
|
||||
from ..utils.variant_utils import GoogleLLMVariant
|
||||
|
||||
_py_builtin_type_to_schema_type = {
|
||||
@@ -315,6 +316,13 @@ def _parse_schema_from_parameter(
|
||||
)
|
||||
_raise_if_schema_unsupported(variant, schema)
|
||||
return schema
|
||||
if inspect.isclass(param.annotation) and issubclass(
|
||||
param.annotation, ToolContext
|
||||
):
|
||||
raise ValueError(
|
||||
'`ToolContext` parameter must be named as `tool_context`. Found'
|
||||
f' `{param.name}` instead in function `{func_name}`.'
|
||||
)
|
||||
if param.annotation is None:
|
||||
# https://swagger.io/docs/specification/v3_0/data-models/data-types/#null
|
||||
# null is not a valid type in schema, use object instead.
|
||||
|
||||
Reference in New Issue
Block a user