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 required

Step-by-Step Guide

1. Import callback

from agentrust_sdk.adapters.crewai import AgentTrustCallback

2. 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_id per 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_id for all crew members (loses per-role audit granularity)
  • Missing Team API key
  • Not handling task failures when governance blocks output

Troubleshooting

IssueFix
TierGateErrorTeam tier required
Callback not firingVerify callback in Task callbacks list
Crew continues after blockConfigure block behavior in callback/SDK