Skip to main content

What You’ll Learn

  • How to create a sandbox with network={"allow_out": [...]} to restrict outbound access
  • How to write an agent that tests TCP connectivity from inside the sandbox
  • How to verify that non-allowlisted destinations are blocked
  • The pattern of combining agent execution with network-level isolation

Prerequisites

  • Declaw running locally or in the cloud (see Deployment)
  • DECLAW_API_KEY and DECLAW_DOMAIN set in your environment
This example is available in Python. TypeScript support coming soon.

Code Walkthrough

1. Create the sandbox with a network allow-list

The network parameter accepts an object with allow_out (list of allowed domains) or deny_out (list of denied domains). When allow_out is specified, all traffic except to listed domains is blocked. See Network Policies for full details.

2. The agent script — testing connectivity

The agent script runs inside the sandbox and tests TCP connectivity to several hosts:

3. Upload the test plan and run the agent

4. Read and analyze results

Expected Output

How Network Policy + Agent Isolation Work Together

The proxy enforces network policy at the TCP layer, not the application layer. This means the restriction applies to all processes inside the sandbox — not just the primary agent — regardless of what language or library they use.

Combining with SecurityPolicy

For defense-in-depth, combine network policies with a full SecurityPolicy:
See the Secured Agent example for the full security stack.