Skip to content

AgentEngineSandboxCodeExecutor sends 'contents' but Vertex SDK reads 'content' — input file payload silently dropped #5500

@Number531

Description

@Number531

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 sidesrc/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 sidevertexai/_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

  1. Build any code-executor agent with code_executor=AgentEngineSandboxCodeExecutor(...).
  2. Pass a non-empty CodeExecutionInput.input_files=[File(name='data.csv', content=<some bytes>, mime_type='text/csv')].
  3. Have the agent run import pandas as pd; print(pd.read_csv('data.csv')).
  4. 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

Metadata

Metadata

Assignees

Labels

agent engine[Component] This issue is related to Vertex AI Agent Engine

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions