Agent Engine Code Execution Stay organized with collections Save and categorize content based on your preferences.
Preview
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.
Many agent tasks, like financial calculations and data science workflows requirean agent to generate and execute code. Agent Engine Code Execution lets youragent to run code in a secure, isolated, and managed sandbox environment.
Features of Code Execution include:
Sandboxes can be created and execute code in under a second.
Sandboxes support file input and output up to 100MB for the entire requestor response.
Sandboxes maintain their execution state (memory) for up to 14 days. Thistime to live (TTL) setting is configurable.
us-central1 region.Code Execution is part of the Agent Engine suite. However, you don'tneed to deploy your agent to Agent Engine to use Code Execution. Your agent canbe running anywhere, even locally.
Code Execution works with any agent framework and any generative model.
Here are the major operations for working with a Code Execution sandbox:
Create sandbox: creates a secure, isolated space torun untrusted or potentially harmful code. This isolation reducessecurity risks by preventing the code from touching your system's resources,files, or network. A sandbox is vital when you need to run code safely, suchas for data science agents, orchestration scripts, or during developmenttesting. The sandbox offers a limited file system and no network access.
Get sandbox: shows the configuration and status of a specific Code Executionsandbox. You can check details like its current state (forexample, running or stopped) and time to live (TTL). This lets you trackyour sandboxes and verify their status before or after running code.
List sandboxes: list all of the Code Execution sandboxes in yourproject. You can filter the results by criteria like sandbox status or type.This helps with checking, monitoring, and managing many sandboxes in yourproject.
Execute code: sends your code along with any required input files to thesandbox for safe execution. The response includes the results, such asstandard output (
stdout), standard error (stderr), and any files the codegenerates. The sandbox can also maintainstate, which allows subsequentExecute Codecalls to build on previous calls. This is crucial forinteractive sessions or complex tasks that need the environment to maintainstate across several code runs.
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-18 UTC.
Open in Colab
Open in Colab Enterprise
Openin Vertex AI Workbench
View on GitHub