What You’ll Learn
- How to wire CrewAI’s crew output directly into a Declaw sandbox for safe execution
- The two-agent pattern: researcher defines requirements, coder writes executable code
- Why code produced by a multi-agent crew must be sandboxed before running
- Demo mode: simulate the full crew workflow without an API key
Prerequisites
- Declaw running locally or in the cloud (see Deployment)
DECLAW_API_KEYandDECLAW_DOMAINset in your environmentOPENAI_API_KEYset in your environment (optional — demo mode runs without it)pip install crewai(required for live mode only)
This example is available in Python. TypeScript support coming soon.
Code Walkthrough
The crew architecture
Live mode — defining the crew
Executing the crew output in a sandbox
Demo mode — simulated crew workflow
The demo mode simulates the researcher and coder agents with hardcoded outputs, then executes the generated code in a real sandbox:Expected Output (demo mode)
Why Sandbox the Crew Output
CrewAI agents can produce arbitrary Python code. Without sandboxing:- The generated code runs on your host machine with your credentials and filesystem access
- A compromised or hallucinating agent could produce code that reads secrets, makes outbound calls, or modifies files
- There is no way to audit or restrict what the generated code does