Policy structure
A policy has static sections —filesystem_policy, landlock, and process — that are locked at sandbox creation, and a dynamic section — network_policies — that can be hot-reloaded on a running sandbox.
Static sections (
filesystem_policy, landlock, process) are locked at sandbox creation. Changing them requires destroying and recreating the sandbox. The network_policies section can be updated on a running sandbox with openshell policy set.Apply a custom policy
Pass a policy YAML file when creating the sandbox:openshell sandbox create keeps the sandbox running after the initial command exits, which is useful when you plan to iterate on the policy. Add --no-keep if you want the sandbox deleted automatically instead.
To avoid passing --policy every time, set a default policy with an environment variable:
Iterate on a running sandbox
The policy iteration workflow is: create the sandbox, monitor logs for denied actions, pull the current policy, modify it, push it, verify. Repeat until the agent can reach everything it needs.1
Create the sandbox with your initial policy
Follow Apply a custom policy above, or set
OPENSHELL_SANDBOX_POLICY.2
Monitor denials
Each log entry shows host, port, binary, and reason. Use
openshell term for a live dashboard.3
Pull the current policy
Strip the metadata header (Version, Hash, Status) before reusing the file.
4
Edit the policy YAML
Add or adjust
network_policies entries, binaries, access, or rules.5
Push the updated policy
Exit codes:
0 = loaded, 1 = validation failed, 124 = timeout.6
Verify the new revision
If status is
loaded, repeat from step 2 as needed. If failed, fix the policy and repeat from step 4.Hot-reload behavior
Changes tonetwork_policies take effect immediately — no sandbox restart required. The proxy picks up the new revision within seconds of openshell policy set completing.
Changes to static sections (filesystem_policy, landlock, process) cannot be hot-reloaded. You must destroy and recreate the sandbox with the updated policy.
Global policy override
Use a global policy to apply one policy payload to every sandbox:- The global payload is applied in full for all sandboxes.
- Sandbox-level policy updates are rejected until the global policy is removed.
Policy examples
Add these blocks to thenetwork_policies section of your sandbox policy. Apply with openshell policy set <name> --policy <file> --wait.
- Simple endpoint
- Granular rules (REST)
Allow Endpoints without
pip install and uv pip install to reach PyPI:protocol use TCP passthrough — the proxy allows the stream without inspecting payloads.Debug denied requests
Checkopenshell logs <name> --tail --source sandbox for the denied host, path, and binary.
When triaging a denied request, check:
- Destination host and port — confirm which endpoint entry is missing.
- Calling binary path — confirm which
binariesentry needs to be added or adjusted. - HTTP method and path (for REST endpoints) — confirm which
rulesentry needs to be added or adjusted.
Next steps
Policy schema reference
Full field-by-field YAML definition for all policy sections.
Default policy reference
Breakdown of the built-in default policy and agent compatibility.
Architecture
Sandbox isolation layers and network access rules explained.
GitHub sandbox tutorial
End-to-end walkthrough combining a GitHub provider with a scoped policy.