Documentation
CrewAI Integration
Track multi-agent CrewAI systems with automatic task tracking, agent steps, and tool executions.
What Gets Tracked Automatically
Agent Steps
Every step each agent takes with reasoning.
Task Completions
When tasks complete with outputs.
Tool Calls
All tool executions with inputs and outputs.
Agent Thoughts
Reasoning and decision making.
Installation
pip install guardy crewaiBasic Usage with Callbacks
Add GuardyCrewHandler callbacks to your Crew:
from crewai import Agent, Task, Crew
from guardy import GuardyClient
from guardy.crewai import GuardyCrewHandler
# Initialize Guardy
client = GuardyClient(api_key="guardy_live_xxx")
# Create session
session_id = client.create_session(
name="Research Team",
agent_name="crewai-research",
user_id="user_123"
)
# Create handler
handler = GuardyCrewHandler(client, session_id, verbose=True)
# Define agents
researcher = Agent(
role="Senior Researcher",
goal="Find comprehensive information",
backstory="Expert researcher with years of experience",
)
writer = Agent(
role="Content Writer",
goal="Write engaging content",
backstory="Skilled writer who creates clear content",
)
# Define tasks
research_task = Task(description="Research {topic}", agent=researcher)
writing_task = Task(description="Write article", agent=writer)
# Create crew with callbacks
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
step_callback=handler.on_step,
task_callback=handler.on_task_complete,
)
# Run
result = crew.kickoff(inputs={"topic": "AI agents"})
# Finish
handler.finish(success=True, output=str(result))Simple Decorator Usage
Use the @track_crew decorator for simpler tracking:
from guardy import GuardyClient
from guardy.crewai import track_crew
client = GuardyClient(api_key="guardy_live_xxx")
@track_crew(client, agent_name="research-crew", user_id="user_123")
def run_research(topic: str):
crew = Crew(agents=[...], tasks=[...])
return crew.kickoff(inputs={"topic": topic})
# Just call - automatically tracked!
result = run_research("AI Safety")Wrap Existing Crew
handler = GuardyCrewHandler(client, session_id)
# Wrap adds callbacks automatically
crew = handler.wrap_crew(crew)
# Now kickoff is tracked
result = crew.kickoff(inputs={"topic": "AI"})
handler.finish(success=True)