Summary
AgentEngineSandboxCodeExecutor.execute_code() builds the per-file dict with key 'contents' (plural), but the Vertex AI SDK reads the singular key 'content'. Result: when an agent passes input files via CodeExecutionInput.input_files, the file is created in the sandbox's working directory with its declared name but zero bytes. No exception is raised; the agent just sees an empty file.
This is a sibling of #5480 (external-delete recovery class mismatch), which I filed earlier from the same investigation.
Versions
google-adk 1.31.0 (latest, 2026-04-16) — bug present
google-adk 1.27.2 — bug present (initial discovery)
- Verified by reading
src/google/adk/code_executors/agent_engine_sandbox_code_executor.py directly at the v1.31.0 tag.
Code paths
Producer side — src/google/adk/code_executors/agent_engine_sandbox_code_executor.py (v1.31.0, ~line 147):
if code_execution_input.input_files:
input_data['files'] = [
{
'name': f.name,
'contents': f.content, # ← writes 'contents'
'mimeType': f.mime_type,
}
for f in code_execution_input.input_files
]
Consumer side — vertexai/_genai/sandboxes.py (~line 641, current SDK):
for file in input_data.get("files", []):
file_name = file.get("name", "")
input_chunks.append(
types.Chunk(
mime_type=file.get("mimeType", ""),
data=file.get("content", b""), # ← reads 'content', not 'contents'
metadata={"attributes": {"file_name": file_name.encode("utf-8")}},
)
)
The data=file.get("content", b"") falls through to the default b"" because the dict only has 'contents'. The Chunk is created with empty data.
Reproduction
- Build any code-executor agent with
code_executor=AgentEngineSandboxCodeExecutor(...).
- Pass a non-empty
CodeExecutionInput.input_files=[File(name='data.csv', content=<some bytes>, mime_type='text/csv')].
- Have the agent run
import pandas as pd; print(pd.read_csv('data.csv')).
- Observe
pandas.errors.EmptyDataError: No columns to parse from file — because data.csv exists but contains zero bytes.
Fix
One-line change. In agent_engine_sandbox_code_executor.py, the dict key should be 'content' (singular) to match what vertexai/_genai/sandboxes.py reads:
input_data['files'] = [
{
'name': f.name,
'content': f.content, # was: 'contents'
'mimeType': f.mime_type,
}
for f in code_execution_input.input_files
]
Workaround
For projects that need to ship before this is fixed upstream, subclassing AgentEngineSandboxCodeExecutor and overriding execute_code() with a near-verbatim copy of the upstream method plus the corrected key works. (We also patch the related #5480 in the same subclass.) Happy to share the reference implementation if helpful.
Related
Summary
AgentEngineSandboxCodeExecutor.execute_code()builds the per-file dict with key'contents'(plural), but the Vertex AI SDK reads the singular key'content'. Result: when an agent passes input files viaCodeExecutionInput.input_files, the file is created in the sandbox's working directory with its declared name but zero bytes. No exception is raised; the agent just sees an empty file.This is a sibling of #5480 (external-delete recovery class mismatch), which I filed earlier from the same investigation.
Versions
google-adk1.31.0 (latest, 2026-04-16) — bug presentgoogle-adk1.27.2 — bug present (initial discovery)src/google/adk/code_executors/agent_engine_sandbox_code_executor.pydirectly at the v1.31.0 tag.Code paths
Producer side —
src/google/adk/code_executors/agent_engine_sandbox_code_executor.py(v1.31.0, ~line 147):Consumer side —
vertexai/_genai/sandboxes.py(~line 641, current SDK):The
data=file.get("content", b"")falls through to the defaultb""because the dict only has'contents'. TheChunkis created with empty data.Reproduction
code_executor=AgentEngineSandboxCodeExecutor(...).CodeExecutionInput.input_files=[File(name='data.csv', content=<some bytes>, mime_type='text/csv')].import pandas as pd; print(pd.read_csv('data.csv')).pandas.errors.EmptyDataError: No columns to parse from file— becausedata.csvexists but contains zero bytes.Fix
One-line change. In
agent_engine_sandbox_code_executor.py, the dict key should be'content'(singular) to match whatvertexai/_genai/sandboxes.pyreads:Workaround
For projects that need to ship before this is fixed upstream, subclassing
AgentEngineSandboxCodeExecutorand overridingexecute_code()with a near-verbatim copy of the upstream method plus the corrected key works. (We also patch the related #5480 in the same subclass.) Happy to share the reference implementation if helpful.Related