Skip to main content
An environment is a computer the agent can use: it runs shell commands, reads and writes files, and executes code there. Without one, the agent can only talk and call tools. You choose the environment when you create a session, and it stays with that session until the session is deleted.

Pick a type

openai_hosted is the name the Agents API uses for a managed sandbox. On Orca it means “managed by Orca”. Nothing runs at OpenAI.
Self-hosted environments are coming soon to hosted Orca. Until then, creating one there returns 400 with “Self-hosted environments are coming soon to Orca”; use openai_hosted. They work today with an Orca server you run on the same machine as the executor.

Managed sandbox

A managed sandbox is a private Linux machine created for one session, the size the pricing page shows. The agent works in /workspace. Anything it writes to /workspace/outputs is saved as a downloadable artifact when a turn completes. A managed sandbox uses machine time from your plan while it runs, and it needs your plan’s minimum balance of Orca credit in your wallet, even within your included hours.

Create one

Examples on this page assume client is an OpenAI client configured as in Build with the API. Pass environment with type: "openai_hosted". You can copy files in at the start, either inline (base64) or from an uploaded file.

Choose network access

The sandbox’s internet access is set by network.access. If you do not set it, it is enabled. Start with the least access that works. On hosted Orca, choose disabled or enabled. This setting only controls commands the agent runs inside the sandbox. Model calls and MCP tool calls are made by the Orca server and are not affected. On Free, a sandbox has no network, whatever network.access asks, until your organization has credit, bought or granted: “The network is off in Free sandboxes until you add credit. Agents can still run code, but can’t install packages or reach the internet.” See machine time on Free.

Configure the sandbox

Besides files and network, a managed environment accepts:

Add files later

You can add a file to a running sandbox and list what is there:

Reuse a setup with a template

If many sessions need the same setup, save it once as an environment template and pass environment_template_id when creating a session. A template accepts the same fields as above. Fields you also set on the session override the template’s, with one exception: a session can tighten the template’s network policy but not loosen it. See skills and templates.

When a sandbox sleeps

A sandbox that has not been used for the idle time the pricing page shows goes to sleep on its own. You can also put it to sleep yourself, at once (below). Awake, it counts as machine time; asleep, it does not. The session keeps its conversation, and its environment’s status becomes disconnected. The next message, or a request for one of its files, wakes it. Waking takes a few seconds, longer for a large workspace, and the message waits for it. What comes back: everything in /workspace, declared packages, environment variables and network rules. Setup commands (setup_commands) run again while it wakes, so keep them safe to repeat. What does not: running programs and their memory, such as a server the agent started. Start them again after it wakes.

Put a sandbox to sleep now

When you are done for now, put the session’s sandbox to sleep instead of waiting for the idle time. From the CLI, orca sessions sleep <session-id>; in the dashboard, Put sandbox to sleep in the session’s ⋯ menu; from an agent, the sleep_session tool; over HTTP, POST /api/sessions/{session_id}/sandbox/sleep (see session sandbox).
  • It is refused while a turn is running. Wait for the turn to end, or stop it, then try again.
  • Saving the files can take a few seconds to a few minutes for a large workspace. The CLI waits and tells you when it is asleep.
  • Running programs stop first, so they are stopped even if the sandbox then stays awake.
  • A sandbox whose files are too large to save stays awake, and you are told. Delete files in /workspace and try again.
  • Opening the session does not wake a sandbox you put to sleep. Sending a message does.
  • Nothing extra is charged: machine time stops, and the saved files count as storage, as with idle sleep.
  • Deleting the session is different: it deletes the conversation, the artifacts and the sandbox’s files.

Self-hosted environment

Coming soon on hosted Orca. The stock executor connects with an API key only to OpenAI hosts or to localhost, so today this section applies to an Orca server you run on the same machine.
A self-hosted environment lets the agent work on a machine you control: your laptop, a build server, a VM inside your network. Orca never logs in to that machine. Instead, you run a small program there, the executor (the stock codex exec-server), which connects out to Orca and carries out the agent’s commands.

Steps

1

Create the session

Give the folder the agent should work in. The path must be absolute and must not go through a symbolic link. On macOS, /tmp is a symlink, so use the real path (for example from realpath).
The environment starts as pending and the session as requires_action (environment_connection). Any input you send is held until the executor connects.
2

Start the executor

On the machine, run the stock Codex executor with the values from the previous step and an Orca API key for the same account:
3

Wait for it to connect

Poll agents.environments.retrieve(environment_id).status until it is connected. Then use the session as normal.
Artifacts work the same way: files under <workspace_directory>/outputs are captured when a turn completes.

What you must know about trust

Commands from the agent run with the same permissions as the executor process. The workspace folder limits Orca’s file tools, but a shell command can read or change anything the executor’s user can. Run the executor as a dedicated low-privilege user, in a container or VM, or on a machine with nothing sensitive on it.
  • If the executor disconnects, the environment becomes disconnected, any running turn stops, and the session shows requires_action until an executor connects again. The interrupted turn is not re-run.
  • Deleting the session cuts the executor off, but does not stop the process or delete files on your machine. Clean those up yourself.
  • capability_directories must be empty for self-hosted environments. Put any files the agent needs inside the workspace folder.

Common mistakes

  • Choosing none and asking the agent to run code. It has no machine. Create a new session with an environment.
  • Expecting files outside /workspace/outputs to become artifacts. Only that folder is captured.
  • Leaving network access at its default. The default is enabled. Set disabled unless the task needs the internet.
  • A relative or symlinked workspace_directory. It is rejected when the first turn runs, so the turn fails rather than the create call.
See also: files and artifacts, runnable managed and self-hosted examples, and the environments reference.