Repository navigation
AgentEngineSandboxCodeExecutor sends 'contents' but Vertex SDK reads 'content' — input file payload silently dropped #5500
Description
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-adk1.31.0 (latest, 2026-04-16) — bug presentgoogle-adk1.27.2 — bug present (initial discovery)- Verified by reading
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):
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— 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 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
- AgentEngineSandboxCodeExecutor: external-delete recovery catches wrong exception class (genai.ClientError vs api_core.NotFound) #5480 — Sibling bug in the same file (external-delete recovery catches wrong exception class)
- AgentEngineSandboxCodeExecutor uses wrong JSON field names for stdout/stderr #3690 — Earlier related field-name-mismatch bug in this executor (stdout/stderr keys)
Activity
klateefa commentedon Apr 29, 2026
@Number531 The issue is caused by a small
key mismatch.The executor is sending file data usingcontents, but theVertex sandboxis only checking for content. Because of this, the file gets created butends up empty.Changing contents tocontent fixesthe problem and the file data ispassed correctly.This looks like a simple fix, and PR #5505 seems to address it
Can you try this and let me know if the issue persists?
surajksharma07 commentedon May 27, 2026
@Number531 — just following up here. The 'contents' vs 'content' key mismatch is confirmed as the root cause — it's a one-liner fix and PR #5505 by @weiguangli-io targets exactly this, though it hasn't merged yet.
Duplicate issue #5824 filed a few days ago also tracks this, so the bug is still active in the latest ADK versions.
Since we haven't heard back since klateefa's comment last month, going ahead and closing this out — feel free to reopen or keep an eye on PR #5505 for when the fix lands!
test: add regression test for input_files content key (google#5912)
fix: use correct 'content' key in AgentEngineSandboxCodeExecutor inpu…
test: add regression test for input_files content key (google#5912)
fix: use correct 'content' key in sandbox code executor input files
fix: use correct 'content' key in sandbox code executor input files