CrewAI (tracing)
CrewAI (tracing)
CrewAI is a framework for orchestrating role-playing autonomous AI agents. Respan’s first-party respan-instrumentation-crewai listener subscribes to CrewAI’s official lifecycle events and emits the canonical workflow, task, agent, tool, and chat span hierarchy directly. Chat spans include the model, provider, prompt, completion, and provider-reported token usage.
Complete first-party tracing requires: respan-instrumentation-crewai 0.2.0 or later and crewai 1.10.1 or later. Earlier 0.1.x instrumentation releases can export workflow structure without a chat child span or token usage.
Set up Respan
Create an account at platform.respan.ai and grab an API key.
Run npx @respan/cli setup to set up with your coding agent.
Use Respan Gateway
See CrewAI gateway setup to route this integration through the Respan gateway.
Example projects
Setup
Set environment variables
OPENAI_API_KEY is used for LLM requests. RESPAN_API_KEY is used to export traces to Respan.
Initialize and run
Initialize Respan before importing CrewAI so the listener is active before CrewAI emits lifecycle events.
View your trace
Open the Traces page to see your CrewAI workflow with agent spans, task execution, tool usage, and LLM calls with provider-reported token usage.
The coordinated backend release includes CrewAI LLM spans classified as chat in llm_call_count. Historical materialized aggregate rows are not backfilled, so traces aggregated before that release can retain their previous summary count; the LLM child span and its model, prompt, completion, and token fields remain the source of truth.
Configuration
CrewAIInstrumentor() takes no configuration. Activation and deactivation are idempotent, and the listener uses CrewAI’s official event bus to emit canonical spans directly.
LLM usage and cost
On the supported baseline, CrewAI tracing records the model, prompt, completion, and provider-reported prompt, completion, and total token counts. The instrumentation does not emit a direct cost. Respan can derive cost when the model is in its pricing catalog; custom or unknown models can show zero cost until custom pricing is configured.
Attributes
In Respan()
Set defaults at initialization. These apply to all spans.
With propagate_attributes
Override per-request using a context scope.
Decorators (optional)
Decorators are not required. On the supported baseline, each CrewAI kickoff automatically emits a workflow with task, agent, tool, and chat descendants. Use @workflow and @task to add structure when you want to group related crews into a named workflow with nested tasks.
Examples
Tool calls
Tool calls are automatically captured as spans with inputs, outputs, and timing.