Skip to content

fix: use correct 'content' key in AgentEngineSandboxCodeExecutor input files#5912

Open
Thapza888 wants to merge 2 commits into
google:mainfrom
Thapza888:fix/sandbox-content-key-missed
Open

fix: use correct 'content' key in AgentEngineSandboxCodeExecutor input files#5912
Thapza888 wants to merge 2 commits into
google:mainfrom
Thapza888:fix/sandbox-content-key-missed

Conversation

@Thapza888
Copy link
Copy Markdown

@Thapza888 Thapza888 commented May 30, 2026

Fixes the same root cause as #5505 which was missed in agent_engine_sandbox_code_executor.py.

Root Cause

AgentEngineSandboxCodeExecutor builds input file payloads with key 'contents' (plural), but the Vertex AI SDK (sandboxes.py) reads 'content' (singular). This causes file.get("content", b"") to always return empty bytes -- all input files are silently created as zero bytes in the sandbox.

The executor returns SUCCESS, so the failure is completely silent.

What changed

'contents' to 'content' at line 183 of agent_engine_sandbox_code_executor.py.

Impact

Security policies, access-control templates, verification scripts, and boundary configuration files passed via input_files to the sandbox code executor are silently created as empty (zero-byte) resources. The sandbox executes untrusted code without the intended operational constraints. No error is raised -- the SUCCESS status blinds monitoring and logging.

Testing Plan

Added regression test test_execute_code_input_files_content_key that verifies execute_code is called with input_data containing the 'content' key (singular). The mock assertion explicitly checks:

expected_input_data = {
    "code": 'print("hello world")',
    "files": [
        {
            "name": "test.txt",
            "content": b"hello world",
            "mimeType": "text/plain",
        }
    ],
}
mock_api_client.agent_engines.sandboxes.execute_code.assert_called_once_with(
    name=...,
    input_data=expected_input_data,
)

Before the fix, this test fails because the code sends 'contents' instead of 'content'. After the fix, the test passes (will be verified in CI).

References

…t files

The AgentEngineSandboxCodeExecutor builds input file payloads with key 'contents' (plural), but the Vertex AI SDK reads 'content' (singular). This causes file.get('content', b'') to always return empty bytes — all input files are silently created as zero bytes in the sandbox with SUCCESS status returned.

Fixes the same root cause as PR google#5505 which fixed this in other files but missed agent_engine_sandbox_code_executor.py.

Ref: google#5500, google#5505, google#5824
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 30, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label May 30, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented May 30, 2026

Response from ADK Triaging Agent

Hello @Thapza888, thank you for submitting this pull request to fix the sandbox code executor!

To help us move forward with reviewing your contribution, please make sure the following guidelines from our Contribution Guidelines are met:

  1. Sign the Contributor License Agreement (CLA): It looks like the CLA check has failed. Please visit Google Developers CLA to sign or verify your agreement.
  2. Unit Tests & Test Results: Since this is a bug fix, please add or update unit tests (e.g., under tests/unittests/) to cover this change and prevent future regressions. Additionally, please run the tests locally and include a summary of passed pytest results in your PR description.

These steps help maintain high code quality and streamline the review process. Thanks again for your contribution!

Verifies that AgentEngineSandboxCodeExecutor sends input_files with the 'content' key (singular), matching what the Vertex AI Sandbox API expects. Without this fix, file.get('content', b'') returns empty bytes and all input files are silently created empty.

Ref: google#5500, google#5505, google#5824
@Thapza888 Thapza888 closed this May 30, 2026
@Thapza888 Thapza888 reopened this May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants