ContainerCodeExecutor drops output files that are hard links

Offen Anfängerfreundlich
#7,906 2 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 4 Tagen

@llalitkumarrr arbeitet bereits daran.

Seit 02.11.2026.

  • #7932 von @OKAN-SOFTWARE — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
76/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
docker, python
Bereich
backend

Rechercherichtung

Lies _extract_output_files in src/google/adk/code_executors/container_code_executor.py und die Muster für gemockte Container in tests/unittests/code_executors/test_container_code_executor.py. Füge einen Regressionstest hinzu, der ein Archiv mit einem Hardlink erstellt, und führe dann diese Testdatei aus. Fertig ist die Aufgabe, wenn CodeExecutionResult.output_files beide verknüpften Namen mit demselben Inhalt enthält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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)
Vorherrschende Sprache
Python
Sterne
22.1k
Forks
4.3k
Ø Merge
1 T. 10 Std.
Gemergte PRs (30 T.)
5

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus google/adk-python

Alle Issues in google/adk-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.