Integrations
CrewAI Integration
CrewAI callback integration for multi-agent crew governance.
CrewAI Integration
Overview
The CrewAI adapter provides AgentTrustCallback — a callback handler attached to CrewAI tasks that validates agent output after each task execution.
Tier: Team+
Why It Matters
CrewAI multi-agent crews need per-task governance so individual agent outputs are validated before being passed to downstream crew members.
Prerequisites
pip install "agentrust-sdk[crewai]"
# Team+ API key requiredStep-by-Step Guide
1. Import callback
from agentrust_sdk.adapters.crewai import AgentTrustCallback2. Attach to crew task
from crewai import Agent, Task, Crew
callback = AgentTrustCallback(agent_id="crew-researcher")
task = Task(
description="Research AI governance trends",
agent=researcher,
callbacks=[callback],
)
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()3. Configure block behavior
The callback validates output and can raise on block outcome based on SDK configuration.
Examples
See examples/crewai_agent.py.
Best Practices
- Attach callback to every task that produces user-facing output
- Use distinct
agent_idper crew role (researcher, writer, reviewer) - Run embedded gateway locally; remote gateway in production
- Combine with trust chain for multi-crew pipelines (Enterprise)
Common Mistakes
- Single
agent_idfor all crew members (loses per-role audit granularity) - Missing Team API key
- Not handling task failures when governance blocks output
Troubleshooting
| Issue | Fix |
|---|---|
TierGateError | Team tier required |
| Callback not firing | Verify callback in Task callbacks list |
| Crew continues after block | Configure block behavior in callback/SDK |