Skip to main content
This cookbook shows you how to add complete observability to CrewAI multi-agent pipelines—tracing agent-to-agent handoffs, measuring individual agent performance, and tracking per-agent costs.

Open in Google Colab

Run the complete notebook in your browser
All company names (ContentCraft) and scenarios in this cookbook are entirely fictional and used for demonstration purposes only.

What You’ll Learn

Trace Agent Handoffs

Capture the message flow between agents as tasks pass through the pipeline

Track Per-Agent Costs

Monitor token usage and costs for each agent role to identify cost drivers

Debug Multi-Agent Flows

Understand why agents made specific decisions and where quality degrades

Compare Configurations

Run experiments with different model assignments to find the cost/quality sweet spot
Prerequisites:
  • Python >=3.10, <3.14
  • OpenAI API key
  • Netra API key (Get started here)
  • CrewAI installed

Why Trace Multi-Agent Systems?

Multi-agent systems introduce complexity that single-agent workflows don’t have: Without per-agent visibility, you can’t optimize individual roles or identify where the pipeline breaks down.

CrewAI Architecture

CrewAI organizes multi-agent work into three components: Processes:
  • Sequential: Tasks execute one after another (A → B → C)
  • Hierarchical: Manager agent delegates to workers

Building an Example Pipeline

Installation

Environment Setup

Define the Agents

Create a 4-agent content pipeline: Researcher → Writer → Editor → SEO:

Define the Tasks

Create tasks that chain together:

Create the Crew


Adding Netra Observability

Initialize Netra with Auto-Instrumentation

Netra provides auto-instrumentation for CrewAI that captures agent execution automatically:
With auto-instrumentation enabled, Netra automatically captures:
  • Agent execution spans with role and backstory
  • Task execution with descriptions and outputs
  • LLM calls with prompts, completions, and token usage
  • Cost calculations per agent

Using the Workflow Decorator

For more control, wrap your pipeline with the @workflow decorator:

Adding Custom Span Attributes

Track additional metadata for each pipeline run:

Viewing Traces in Netra

After running the pipeline, navigate to Observability → Traces in Netra.

What the Trace Shows

Netra trace view showing multi-agent pipeline
The trace shows:
  • Pipeline span: Overall execution time
  • Agent spans: Each agent’s task execution
  • LLM calls: Nested under each agent with prompts and completions
  • Token usage: Per-agent and total

Running Configuration Experiments

Test different model configurations to find the optimal cost/quality balance.

Define Configurations

Run Experiments

Compare in Dashboard

After running all configurations, compare costs and latency:

Debugging Multi-Agent Issues

Common Problems and Solutions

Using Traces to Debug

  1. Find slow agents: Sort spans by duration
  2. Trace context flow: Check task outputs passed between agents
  3. Identify cost drivers: Filter by token usage
  4. Compare successful vs failed: Look for pattern differences

Summary

You’ve learned how to add comprehensive observability to CrewAI pipelines:
  • Auto-instrumentation captures agent execution with minimal code
  • Per-agent tracing reveals costs, latency, and token usage
  • Custom attributes enable filtering by topic, config, and more
  • Configuration experiments find the optimal cost/quality balance

Key Takeaways

  1. Multi-agent systems need per-agent visibility to identify bottlenecks
  2. Cost allocation by role reveals which agents benefit from premium models
  3. Trace context flow to debug handoff issues
  4. Use configuration experiments for data-driven model selection

See Also

CrewAI Integration

Complete CrewAI instrumentation guide

Agents Documentation

Deep dive into agent observability features

Usage APIs

Query cost and usage data programmatically
Last modified on March 17, 2026