Skip to content

Commit 92cf192

Browse files
committed
fix: Resolve circular import in base_tool
Importing `ToolContext` at the top level in `base_tool.py` created a circular import cycle when `google.adk.tools.function_tool` was imported. The cycle was: `base_tool` -> `tool_context` -> `CallbackContext` -> `agents` -> `BaseAgent` -> `Event` -> `LlmResponse` -> `LlmRequest` -> `BaseTool`. Moving `ToolContext` to `TYPE_CHECKING` breaks this runtime cycle, using `from __future__ import annotations` to preserve type hints. Change-Id: I34731f46cf5aa4665ad3c6604495ad5fd84f8aa5
1 parent 9fd0e07 commit 92cf192

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/google/adk/tools/base_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333

3434
from ..utils.variant_utils import get_google_llm_variant
3535
from ..utils.variant_utils import GoogleLLMVariant
36-
from .tool_context import ToolContext
3736

3837
logger = logging.getLogger("google_adk." + __name__)
3938

4039
if TYPE_CHECKING:
4140
from ..models.llm_request import LlmRequest
4241
from .tool_configs import ToolArgsConfig
42+
from .tool_context import ToolContext
4343

4444
SelfTool = TypeVar("SelfTool", bound="BaseTool")
4545

0 commit comments

Comments
 (0)