CrewAI Integration

Trace CrewAI crew kickoffs and individual task executions. Each crew run becomes a trace with task spans nested inside.

Installation

pip install twosignal[crewai]

Usage

from twosignal import TwoSignal
from twosignal.wrappers.crewai import wrap_crewai
from crewai import Agent, Crew, Task

ts = TwoSignal()

researcher = Agent(
    role="Researcher",
    goal="Find information",
    backstory="You are an expert researcher.",
)

writer = Agent(
    role="Writer",
    goal="Write clear summaries",
    backstory="You are a skilled writer.",
)

research_task = Task(
    description="Research AI testing tools",
    agent=researcher,
    expected_output="A list of tools",
)

write_task = Task(
    description="Write a summary of the research",
    agent=writer,
    expected_output="A summary paragraph",
)

crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task])
crew = wrap_crewai(crew)

# the entire kickoff is traced with task-level spans
result = crew.kickoff()

What Gets Traced

EventSpan TypeDetails
Crew kickoffAGENTOverall crew execution, agent list, inputs/output
Task executionAGENTTask description, assigned agent, output

How It Works

wrap_crewai(crew) monkey-patches crew.kickoff() and each task's execute_sync(). The kickoff span acts as the parent, with individual task spans nested underneath. Agent roles are captured in span names for easy identification.

Have questions? Join our community!

Connect with other developers and the 2Signal team.

Join Discord