Combines Agent Control (security/compliance) with CrewAI Guardrails (quality retries) for production customer support.
Agent Control (Security): PRE/POST/FINAL blocks unauthorized access and PII. CrewAI Guardrails (Quality): validates length/structure/tone with up to 3 retries.
Before running this example, ensure you have:
- Python 3.12+
- uv — Fast Python package manager (
curl -LsSf https://astral.sh/uv/install.sh | sh) - Docker — For running PostgreSQL (required by Agent Control server)
From the monorepo root, install all workspace packages:
cd /path/to/agent-control
make syncThis installs the Agent Control SDK and all workspace packages in editable mode.
Navigate to the CrewAI example and install its specific dependencies:
cd examples/crewai
uv pip install -e . --upgradeCreate a .env file or export the environment variable:
export OPENAI_API_KEY="your-key-here"In a separate terminal, start the server from the monorepo root:
cd /path/to/agent-control
make server-runVerify server is running:
curl http://localhost:8000/healthFrom the examples/crewai directory, run the setup script:
uv run python setup_content_controls.pyMake sure you're in the examples/crewai directory and run:
uv run python content_agent_protection.py| Scenario | Layer | Result |
|---|---|---|
| Unauthorized access | Agent Control PRE | Blocked |
| PII in tool output | Agent Control POST | Blocked |
| Short/low-quality response | Guardrails | Retry then pass |
| Agent bypass attempt | Agent Control FINAL | Blocked |
PRE checks input before the LLM. POST checks tool output for PII. FINAL checks the crew’s final response. Agent Control blocks immediately (no retries), violations are logged. Guardrails retry with feedback (quality-only).
Agent Control works seamlessly with CrewAI's agent orchestration:
- CrewAI Agent Layer: Plans tasks, selects tools, manages conversation flow
- Agent Control Layer: Enforces controls and business rules at tool boundaries
User Request
↓
CrewAI Agent (planning & orchestration)
↓
Decides to call tool
↓
@control() decorator (PRE-execution) ← LAYER 1: Validates input
↓
Tool executes (LLM generation)
↓
@control() decorator (POST-execution) ← LAYER 2: Validates tool output
↓
If blocked, agent may generate own response
↓
Final Output Validation ← LAYER 3: Validates crew output (catches bypass)
↓
Return to user (or block if control violated)