google / google/adk-python

BaseToolset caches prefixed tools by a single invocation ID, breaking multi-agent concurrency

未关闭
#5,721 1 条评论 0 个 reaction 已指派 2 人 在 GitHub 查看

@rohityan 已经在做这个了。

开始于 2026年5月20日。

needs review tools
主要语言
Python
星标
21.6k
派生
4k
平均合并
13 小时 49 分钟
30 天内合并 PR
10

描述

Description

In google.adk.tools.base_toolset.BaseToolset, prefixed tool wrappers are cached using a single instance variable self._cached_invocation_id.

When orchestrating multiple agents concurrently (e.g., via ParallelAgent or custom asyncio.TaskGroup harnesses), concurrent worker coroutines call get_tools(invocation_id="worker_N"). Because self._cached_invocation_id only stores the last caller's ID, concurrent workers constantly overwrite each other's cached ID. This results in a cache miss on every single turn, forcing redundant tool wrapper re-instantiations and causing severe lock contention.

Proposed Solution

Refactor self._cached_prefixed_tools to be a dictionary keyed by invocation_id:

self._cached_prefixed_tools: dict[Optional[str], list[BaseTool]] = {}

When get_tools is called, check if invocation_id in self._cached_prefixed_tools and return the cached list for that specific agent thread. Ensure close() clears the dictionary (self._cached_prefixed_tools.clear()).

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。