Inline CSV uploads in code execution can reuse a stale file or corrupt raw bytes
Los mantenedores suelen responder en 3 días
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Environment
ADK main (2.14.1), macOS, Python 3.11.17. Offline reproductions; no model, credentials, Docker, or network services needed. Regression introduction is unknown.
Symptoms and impact
With optimize_data_file=True, inline CSV attachments are extracted into executor input files. Two defects in the same extraction path can cause analysis of incorrect data:
- With
include_contents="none", uploadb"value\n10\n", finish the turn, then uploadb"value\n99\n"at the same part position. Both requests derivedata_1_1.csv. The second request reuses the first cached file and skips preprocessing because that name is already processed. - Upload the valid one-cell CSV
b"1234". The encoding helper mistakes these raw bytes for encoded content. The executor decodes them intob"\xd7m\xf8"instead of the original CSV.
Expected versus actual
| Input | Expected | Actual on upstream/main |
|---|---|---|
Raw inline CSV b"1234" |
Executor receives b"1234" |
Executor receives b"\xd7m\xf8" |
| Second current-turn CSV with value 99 | Placeholder resolves to value 99; eligible for preprocessing | Placeholder resolves to cached value 10; preprocessing skipped |
| Identical upload repeated at the same position | Reuse its cached file without duplicates | Reuses the filename regardless of content |
Offline reproduction
Run the following script using Python 3.11 with dependencies installed and PYTHONPATH=<checkout>/src. It prints both symptoms before asserting the expected behavior. It fails on upstream/main and passes with the local fix.
"""Offline regression check: no model, credentials, or executor service."""
from google.genai import types
from google.adk.code_executors.code_executor_context import CodeExecutorContext
from google.adk.events.event import Event
from google.adk.flows.llm_flows.context._contents import _get_current_turn_contents
from google.adk.flows.llm_flows.extensions._code_execution import (
_extract_and_replace_inline_files, get_content_as_bytes,
)
from google.adk.models.llm_request import LlmRequest
def upload(context, history, data):
history.append(Event(author='user', content=types.Content(role='user', parts=[
types.Part.from_bytes(data=data, mime_type='text/csv')
])))
request = LlmRequest(contents=_get_current_turn_contents(None, history, 'agent'))
files = _extract_and_replace_inline_files(context, request)
placeholder = request.contents[0].parts[0].text
current = next(f for f in files if f'`{f.name}`' in placeholder)
history.append(Event(author='agent', content=types.Content(role='model', parts=[
types.Part(text='Done')
])))
return files, current
_, raw = upload(CodeExecutorContext({}), [], b'1234')
raw_bytes = get_content_as_bytes(raw.content)
context, history = CodeExecutorContext({}), []
_, first = upload(context, history, b'value\n10\n')
context.add_processed_file_names([first.name])
second_files, second = upload(context, history, b'value\n99\n')
repeated_files, repeated = upload(context, history, b'value\n99\n')
second_bytes = get_content_as_bytes(second.content)
new_files = [f for f in second_files if f.name not in context.get_processed_file_names()]
print('Raw upload decoded for executor:', repr(raw_bytes))
print('Second turn decoded for executor:', repr(second_bytes))
print('Cached files:', len(second_files), 'New files to preprocess:', len(new_files))
print('Identical re-upload adds files:', len(repeated_files) - len(second_files))
assert raw_bytes == b'1234'
assert second_bytes == b'value\n99\n'
assert len(second_files) == 2 and new_files == [second]
assert repeated_files == second_files and repeated == second
assert get_content_as_bytes(second_files[0].content) == b'value\n10\n'
The original independent reproductions are also recorded locally at out/reports/correctness-review-2/repro_csv_base64.py and out/reports/correctness-review-2/repro_csv_cache_collision.py. Those original scripts assert the buggy behavior and therefore intentionally fail once fixed.
Cause and proposed fix
_extract_and_replace_inline_files derives filenames from request-local indices but caches files across turns. Its filename-only check ignores newly uploaded bytes. Separately, get_encoded_file_content guesses whether bytes are encoded even though inline_data.data is known to be raw.
Encode raw inline bytes directly. Compare encoded content and MIME before reusing a positional filename; on collision, append a stable digest of MIME and content. Preserve earlier cached files and placeholders, and reuse the digest filename on identical re-upload. Leave the general encoding helper's existing behavior intact for compatibility.
Duplicate re-check
No matching issues or PRs updated since 2026-11-17 were returned by read-only searches for code execution CSV, inline_data csv, data file cache, get_encoded_file_content, base64 csv, and optimize_data_file. The earlier review separately distinguished historical PR #4024 (persisting replacements in history) from these new-upload collisions.
- Lenguaje dominante
- Python
- Estrellas
- 22.3k
- Forks
- 4.4k
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de google/adk-python
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
google/adk-python#8360 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
google/adk-python#8359 ·
Los mantenedores suelen responder en 3 días
-
Can pin to litellm version be changed?Posiblemente ocupada @llalitkumarrr la tomó hace 10 días. Abiertomodels
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
google/adk-python#8129 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
OpenAPI tools ignore operation- and path-level server overridesPosiblemente ocupada @sanketpatil06 la tomó hace 14 días. Abiertotools
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
google/adk-python#8064 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
Two docstrings in openapi_tool document parameters the signatures do not acceptPosiblemente ocupada @surajksharma07 la tomó hace 17 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
google/adk-python#8024 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 3 días
Todos los issues de google/adk-python
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
vllm-project/vllm#70030 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TigreGotico/tugaphone#408 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
gke-labs/kube-agents#7308 ·
Los mantenedores suelen responder en 1 día
-
t: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 3 días
-
chore
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
lugassawan/swe-workbench#841 ·