Skip to content

Commit f9097cb

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: Fix missing dynamically loaded tools in SkillToolset during the same invocation
Currently, BaseToolset caches its tools per invocation_id. Because SkillToolset dynamically resolves additional tools from the state when a skill is loaded, the cache prevents new tools from being picked up in the same invocation right after a load_skill call. This change sets `_use_invocation_cache = False` in SkillToolset so that it correctly re-evaluates the state-dependent tools at each step of the LLM generation loop within an invocation, preventing "Tool not found" errors. PiperOrigin-RevId: 914997555
1 parent e377cb5 commit f9097cb

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/google/adk/tools/skill_toolset.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,8 @@ def __init__(
895895
script_timeout: Timeout in seconds for shell script execution via
896896
subprocess.run. Defaults to 300 seconds. Does not apply to Python
897897
scripts executed via exec().
898+
additional_tools: Optional list of `BaseTool` or `BaseToolset` instances
899+
to be made available to the agent when certain skills are activated.
898900
"""
899901
super().__init__()
900902

@@ -911,6 +913,8 @@ def __init__(
911913
self._registry = registry
912914
self._code_executor = code_executor
913915
self._script_timeout = script_timeout
916+
# Needed for mid-turn reloading of skill tools.
917+
self._use_invocation_cache = False
914918
self._invocation_cache: dict[
915919
str,
916920
dict[str, models.Skill | asyncio.Future[models.Skill | None] | None],

0 commit comments

Comments
 (0)