Skip to main content

Overview

This example demonstrates integrating Agent Control with CrewAI to provide multi-layer security for a customer support agent:
  1. Agent Control for security/compliance — PII detection, unauthorized access blocking
  2. CrewAI Guardrails for quality validation — length, tone, structure
Both systems work together: Agent Control provides non-negotiable security blocks, while CrewAI Guardrails improve quality through iterative retries.
To run the full example yourself, visit the source on GitHub: CrewAI Example

Why This Matters

Customer support agents (human or AI) can accidentally:
  • Leak PII (emails, phones, SSNs, credit cards) in responses or logs
  • Access other users’ data when they shouldn’t
  • Disclose passwords, credentials, or admin information
  • Violate GDPR, CCPA, PCI-DSS compliance requirements
Agent Control solves this with three-layer protection:

Prerequisites

1. Start the Agent Control Server

Expected Behavior

The request is blocked before the LLM is ever called.
The tool ran, but the output was blocked because it contained PII.
CrewAI guardrails handle quality — they retry up to 3 times with feedback.
Even when CrewAI’s agent works around the tool-level block by generating its own response containing PII, the final output validation catches it.

Agent Control vs CrewAI Guardrails

How It Works

The @control() decorator with CrewAI tools

CrewAI tools are synchronous, but the @control() decorator is async. Use an asyncio.run() wrapper:

Three-layer validation flow

Why three layers?
  • Layers 1 & 2 protect at the tool boundary (standard @control() usage)
  • Layer 3 protects against orchestration bypass — when CrewAI’s agent generates its own response containing PII after a tool was blocked

Control configuration

Architecture

Files

Troubleshooting

CrewAI tools are sync by default, but @control requires async. Use an asyncio.run() wrapper:
Most common cause: the setup script was not run.
Also verify the tool name is set on the async function:
CrewAI may pass tool arguments in different formats. Make the tool handle both:

Source Code

See the full example on GitHub: CrewAI Example