What this section covers
End-to-end examples that wire the OpenAI Agents SDK up to a declaw sandbox withpip install "declaw[openai]". Every bash, file, and
PTY tool call the agent makes is dispatched through a declaw microVM
with the platform’s full security posture applied at the network
edge — PII redaction, prompt-injection detection, per-sandbox domain
allowlists, audit logging, env-var masking.
Install
Credentials
Import surface
Every declaw knob — sandbox config, security policy, network policy, lifecycle — is re-exported fromdeclaw.openai so recipes import
from a single place:
Template coverage
| Recipe | Template | What it shows |
|---|---|---|
| Data analyst | python | pandas + matplotlib + PII rehydration |
| Code reviewer | ai-agent | git clone, ruff, structured output, env-driven config |
| Customer support | base | Multi-agent handoffs, PII redact + rehydrate |
| Web scraper | python | Single-host network allowlist, BeautifulSoup |
| TypeScript API | node | Background server, curl, compile + run |
| DevOps audit | devops | Static checks, transformation rules, hadolint |
| ML training | code-interpreter | scikit-learn + matplotlib, zero-install |
| Custom transformations | python | End-to-end proof of regex-based directional rewrites at the edge proxy |
Two layers of isolation every recipe relies on
- Filesystem isolation: every sandbox boots with a fresh
/workspaceoverlay. Artifacts an agent writes (reports, logs, compiled binaries, trained models) disappear when the sandbox terminates. No host bleed-through, no scratch cleanup to manage. - Environment isolation:
envs={...}pushes key/value pairs into the microVM as real process env vars. The agent reads them withprintenv— they never need to appear in the prompt, so secrets stay out of the LLM trace.
PIIConfig(rehydrate_response=True)— redact PII on the way out, restore it on the way back in, so the agent code works unchanged while the upstream model never sees real PII.NetworkPolicy(allow_out=[...])— default-deny outbound; only the listed hosts reach the internet.InjectionDefenseConfig(enabled=True)— flag prompt-injection attempts in HTTP bodies before they hit the upstream LLM.TransformationRule(match=..., replace=...)— directional regex rewrites, e.g. redact AWS keys before they leave the VM.