ContainerCodeExecutor drops output files that are hard links

未关闭 适合新手
#7,906 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 4 天内回复

@llalitkumarrr 已经在做这个了。

开始于 2026年11月2日。

  • #7932 来自 @OKAN-SOFTWARE —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
docker, python
领域
backend

调研方向

阅读 src/google/adk/code_executors/container_code_executor.py 中的 _extract_output_files,以及 tests/unittests/code_executors/test_container_code_executor.py 中模拟容器的模式。添加一个回归测试,用于构建包含硬链接的归档,然后运行该测试文件。当 CodeExecutionResult.output_files 包含两个链接名称且内容相同时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

ContainerCodeExecutor (input/output files added in effd641) returns only the first name when the executed code leaves two hard-linked names in the output directory, for example after os.link("a.csv", "b.csv") or cp -l. The second file is silently missing from CodeExecutionResult.output_files.

Docker's get_archive writes the second path to an inode it has already archived as a hard-link entry (type LNK, size 0), as Python's tarfile.add does. _extract_output_files keeps only entries where member.isfile() is true, and that is false for link entries.

src/google/adk/code_executors/container_code_executor.py, in _extract_output_files:

for member in tar.getmembers():
  if member.isfile():

To Reproduce

The repro builds the archive from a real directory with tarfile, as Docker would return it, and feeds it to the executor through a mocked container, the same way tests/unittests/code_executors/test_container_code_executor.py does.

archive members: [('outputs', 'DIR'), ('outputs/a.csv', 'REG'), ('outputs/b.csv', 'LNK')]
output_files: ['a.csv']        # expected ['a.csv', 'b.csv']

Expected behavior

Both names are returned with the same content.

Suggested fix

if member.isfile() or member.islnk():

tar.extractfile() already resolves a hard-link member to its target's data inside the archive, so no other change is needed. Plus a regression test that builds the archive from a directory containing a hard link.

Question (separate, smaller)

CodeExecutorContext.add_input_files() only appends. If code adds data.csv in one turn and an updated data.csv in a later turn, every later execution fails with ValueError: Duplicate input file name: 'data.csv', and since the list lives in session state the session can't recover. The flow's own inline-file path avoids this by skipping known names. Should add_input_files replace an existing file with the same name, or is the error intended?

I can open a PR for the hard-link fix if that's welcome.

Desktop (please complete the following information):

  • OS: macOS
  • Python version: 3.12
  • ADK version: main (8cd3b12, 2.13.0)
主要语言
Python
星标
22.1k
派生
4.3k
平均合并
1 天 10 小时
30 天内合并 PR
5

环境准备

从这里开始

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

google/adk-python 的其他 Issue

查看 google/adk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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