CrewAI Integration
Safety validation for CrewAI agents and crews.
Installation
pip install sentinelseed[crewai]
Components
| Component | Description |
|---|
safe_agent | Wrap agent with Sentinel safety seed |
SentinelCrew | Crew wrapper with input/output validation |
AgentSafetyMonitor | Monitor and log agent activities |
create_safe_crew | Helper to create crews from config |
Quick Start
Option 1: Wrap Individual Agent
from crewai import Agent
from sentinelseed.integrations.crewai import safe_agent
researcher = Agent(
role="Researcher",
goal="Research topics thoroughly",
backstory="Expert researcher",
)
safe_researcher = safe_agent(
researcher,
seed_level="standard",
injection_method="auto", # auto, system_template, backstory
)
Option 2: SentinelCrew
from crewai import Agent, Task
from sentinelseed.integrations.crewai import SentinelCrew
crew = SentinelCrew(
agents=[researcher, writer],
tasks=[research_task, write_task],
seed_level="standard",
validate_outputs=True,
block_unsafe=True,
)
result = crew.kickoff()
if isinstance(result, dict) and result.get("blocked"):
print(f"Blocked: {result['reason']}")
Option 3: Create from Config
from sentinelseed.integrations.crewai import create_safe_crew
crew = create_safe_crew(
agents_config=[
{"role": "Researcher", "goal": "Find info", "backstory": "..."},
],
tasks_config=[
{"description": "Research topic X", "agent_role": "Researcher", "expected_output": "..."},
],
seed_level="standard",
)
Option 4: Monitor Activities
from sentinelseed.integrations.crewai import AgentSafetyMonitor
monitor = AgentSafetyMonitor()
monitor.track_agent(researcher)
monitor.log_activity("Researcher", "search", "Searching for tutorials")
report = monitor.get_report()
print(f"Safety rate: {report['safety_rate']:.1%}")
Injection Methods
| Method | Description |
|---|
auto | Try system_template first, fallback to backstory |
system_template | Use CrewAI's official template system |
backstory | Inject into backstory field |
Validation Flow
Input → validate() → [blocked?] → Crew.kickoff() → validate() → [blocked?] → Result
Configuration
SentinelCrew(
agents=[...],
tasks=[...],
seed_level="standard",
injection_method="auto",
validate_outputs=True,
block_unsafe=True,
use_semantic=False,
semantic_api_key=None,
)
Links