Skip to main content

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_KEY and DECLAW_DOMAIN set in your environment
  • OPENAI_API_KEY set 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

Both agents run on the host (talking to the LLM API). Only the final code output is sent into the sandbox for execution.

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
With Declaw, the crew produces code; Declaw executes it in an isolated sandbox. The host process remains safe regardless of what the agents generate.