Skip to main content

Use case

A support ticket comes in containing an email, a phone number, and a complaint that spans billing and a product bug. A triage agent classifies it, hands off to specialists, and each specialist runs tools in the same sandbox — so filesystem state persists across the handoff.

Template

base — the smallest template, boots fastest. All this recipe needs is a shell and /workspace.

Run it

export DECLAW_API_KEY=dcl_...
export DECLAW_DOMAIN=api.declaw.ai
export OPENAI_API_KEY=sk-...

python cookbook/openai_agents_customer_support.py

Security policy

SecurityPolicy(
    pii=PIIConfig(enabled=True, action="redact", rehydrate_response=True),
    network=NetworkPolicy(allow_out=["api.openai.com"]),
)
rehydrate_response=True is the key knob for support workflows. Walk-through:
  1. User ticket contains alice.johnson@example.com and +1-415-555-0182.
  2. Triage agent needs to send the ticket to the LLM. Outbound request is scanned — email and phone become REDACTED_EMAIL_ADDRESS_1, REDACTED_PHONE_NUMBER_1.
  3. LLM reasons about the redacted ticket. Its response echoes the tokens back in the reply draft.
  4. Edge proxy rehydrates the tokens before the sandbox receives the response. The agent’s drafted reply now contains the real email and phone.
  5. Specialist writes the final reply to /workspace/reply.txt with the real PII — correct for the customer, while the LLM never saw real values.

Multi-agent handoff

triage_agent = SandboxAgent(
    name="triage",
    handoffs=[billing_agent, technical_agent],
    ...
)
Both specialists run inside the same session. Triage writes /workspace/ticket.txt; billing reads it; billing writes /workspace/billing.log; technical appends to /workspace/reply.txt. That would not work if each agent got its own sandbox.

Env isolation

envs={"SUPPORT_TIER": "gold", "AGENT_VERSION": "v3"}
Specialists read these with printenv so they branch on tier (gold/silver/bronze) or agent version without the dispatcher needing to pass them in the prompt.

Full source

See cookbook/openai_agents_customer_support.py in the repo.