Agent Engine Code Execution

Many agent tasks, like financial calculations and data science workflows require an agent to generate and execute code. Agent Engine Code Execution, allows your agent 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 request or response.

  • Sandboxes maintain their execution state (memory) for up to 14 days. This time to live (TTL) setting is configurable.

Code Execution is part of the Agent Engine suite. However, you don't need to deploy your agent to Agent Engine to use Code Execution. Your agent can be 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 to run untrusted or potentially harmful code. This isolation reduces security 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, such as for data science agents, orchestration scripts, or during development testing. The sandbox offers a limited file system and no network access.

  • Get sandbox: shows the configuration and status of a specific Code Execution sandbox. You can check details like its current state (for example, running or stopped) and time to live (TTL). This lets you track your sandboxes and verify their status before or after running code.

  • List sandboxes: list all of the Code Execution sandboxes in your project. You can filter the results by criteria like sandbox status or type. This helps with checking, monitoring, and managing many sandboxes in your project.

  • Execute code: sends your code along with any required input files to the sandbox for safe execution. The response includes the results, such as standard output (stdout), standard error (stderr), and any files the code generates. The sandbox can also maintain state, which allows subsequent Execute Code calls to build on previous calls. This is crucial for interactive sessions or complex tasks that need the environment to maintain state across several code runs.

What's next