Skip to content

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

Closed

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 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

  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

Activity

  1. added
    agent engine[Component] This issue is related to Vertex AI Agent Engine
    on Apr 27, 2026
  2. added theissue type on Apr 27, 2026
  3. klateefa commented on Apr 29, 2026

    @klateefa

    @Number531 The issue is caused by a small key mismatch.The executor is sending file data using contents, but the Vertex sandbox is only checking for content. Because of this, the file gets created but ends up empty.Changing contents to content fixes the problem and the file data is passed 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?

  4. surajksharma07 commented on May 27, 2026

    @surajksharma07
    Collaborator

    @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!

  5. added a commit that references this issue on Jun 12, 2026
    6262f94
  6. added a commit that references this issue on Aug 11, 2026
    2bffda4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agent engine[Component] This issue is related to Vertex AI Agent Enginerequest clarification[Status] The maintainer need clarification or more information from the author

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions