Expand description
Vertex AI Agent Engine sandbox client (sandboxEnvironments, v1beta1).
A managed code-execution sandbox lives under a reasoning engine at
projects/*/locations/*/reasoningEngines/*/sandboxEnvironments/*. This
module provides:
VertexSandboxClient— the REST surface: create (LRO), get, list, delete (LRO), and the synchronous:executemethod, plusexecute_codeimplementing the chunk conventions shared with adk-python and the Vertex AI SDK.SandboxCodeExecutor— adk-pythonAgentEngineSandboxCodeExecutorparity: per-session lazy sandbox creation with recreate-on-not-running semantics.VertexSandboxTool— anadk_core::Toolexposing sandbox code execution to LLM agents, keyed by the calling session.
Transport, credential caching, LRO polling, and scope validation come
from adk_gcp.
§Chunk conventions
:execute exchanges opaque Chunk values. The code-execution
conventions over them (adk-python/SDK parity):
| Chunk | mimeType | data (base64 of) | metadata.attributes |
|---|---|---|---|
| Code input | application/json | {"code": "<source>"} | — |
| Input file | the file’s MIME type | raw bytes | file_name = base64(filename) |
| Console output | application/json | {"msg_out": ..., "msg_err": ...} | no file_name |
| Output file | may be absent | raw bytes | file_name = base64(filename) |
Files are limited to 100 MB per request and per response. The request side is enforced before sending; the response side is bounded by the client’s response-size limit (140 MiB, covering base64 overhead).
§Example
use adk_code::vertex_sandbox::{
CreateSandboxRequest, VertexSandboxClient, VertexSandboxConfig,
};
let config = VertexSandboxConfig::new("my-project", "us-central1");
let client = VertexSandboxClient::new_with_adc(config)?;
let sandbox = client
.create_sandbox("4242", CreateSandboxRequest::new("my-sandbox"))
.await?;
let name = sandbox.name.expect("created sandbox has a name");
let result = client.execute_code(&name, "print('hello')", &[]).await?;
assert_eq!(result.stdout, "hello\n");
client.delete_sandbox(&name).await?;Structs§
- Chunk
- One unit of
:executeinput or output. - Chunk
Metadata - Optional metadata carried by a
Chunk. - Code
Execution Environment - Spec of a code-execution sandbox environment.
- Computer
UseEnvironment - Spec of a computer-use sandbox environment (no fields).
- Create
Sandbox Request - Input to
create_sandbox. - Input
File - An input file for
execute_code. - Output
File - A file the executed code wrote.
- Sandbox
Code Executor - Executes code in Agent Engine sandboxes with per-session lifecycle
management, matching adk-python’s
AgentEngineSandboxCodeExecutor. - Sandbox
Environment - A
SandboxEnvironmentwire resource. - Sandbox
Environment Spec - The
sandbox_environment_categoryoneof: exactly one category is set. - Sandbox
Execution Result - Decoded result of one code execution.
- Vertex
Sandbox Client - Client for Agent Engine sandbox environments.
- Vertex
Sandbox Config - Configuration for
VertexSandboxClient. - Vertex
Sandbox Tool - A tool that executes model-written code in a managed Vertex AI Agent Engine sandbox.
Enums§
- Code
Language - Language runtime of a code-execution sandbox.
- Machine
Config - Machine shape of a code-execution sandbox.
- Sandbox
State - Lifecycle state of a sandbox environment (output only).
Constants§
- DEFAULT_
SANDBOX_ DISPLAY_ NAME - Display name
SandboxCodeExecutoruses for lazily created sandboxes (adk-python parity). - DEFAULT_
SANDBOX_ TTL - TTL
SandboxCodeExecutorsends for lazily created sandboxes: one year, matching adk-python. - MAX_
REQUEST_ FILE_ BYTES - Maximum raw file bytes accepted per
:executerequest (100 MB).
Functions§
- decode_
output_ chunks - Decodes
:executeoutput chunks into stdout, stderr, and output files. - encode_
code_ chunk - Encodes source code as the code-input chunk.
- encode_
file_ chunk - Encodes an input file as a file chunk (
file_nameattribute set).