type: cloud environments. To run sandboxes on your own infrastructure, see Self-hosted sandboxes.
Managed Agents API requests require the
managed-agents-2026-04-01 beta header, except memory store endpoints, which use agent-memory-2026-07-22 instead. The SDK sets the correct beta header automatically. See Beta headers.Create an environment
name so you can tell environments apart.
Use the environment in a session
Pass the environment ID as a string when creating a session.Configuration options
Packages
Thepackages field pre-installs packages into the sandbox before the agent starts. Packages are installed by their respective package managers and cached across sessions that share the same environment. When multiple package managers are specified, they run in alphabetical order (apt, cargo, gem, go, npm, pip). You can optionally pin specific versions. Unpinned packages install the latest version.
Networking
Thenetworking field controls the sandbox’s outbound network access. It does not affect the allowed domains for the web_search or web_fetch tools.
The following example creates an environment with
limited networking:
For production deployments, use
limited networking with an explicit allowed_hosts list. Follow the principle of least privilege by granting only the minimum network access your agent requires, and regularly audit your allowed domains.limited networking:
allowed_hostsspecifies domains the sandbox can reach. Specify bare hostnames or wildcard patterns (such as*.example.com). Do not include a URL scheme, port, or path.allow_mcp_serversallows outbound access to MCP server endpoints configured on the agent, beyond those listed in theallowed_hostsarray. Defaults tofalse.allow_package_managersallows outbound access to public package registries (such as PyPI and npm) beyond those listed in theallowed_hostsarray. Defaults tofalse.
Environment lifecycle
- Environments persist until explicitly archived or deleted.
- Each session gets its own sandbox instance, even when multiple sessions reference the same environment. Sessions do not share filesystem state.
- Environments are not versioned. If you update an environment frequently, keep your own record of the changes so you can tell which configuration each session used.
Manage environments
Pre-installed runtimes
Cloud sandboxes include common runtimes out of the box. See Cloud sandbox reference for the full list of pre-installed languages, databases, and utilities.Next steps
Cloud sandbox reference
Pre-installed packages, databases, and utilities available in cloud sandboxes.
Start a session
Create a session to run your agent and start running tasks.