Skip to main content
Open In Colab This guide shows you how to use Weave to monitor and trace CrewAI multi-agent applications, including both Crews and Flows. CrewAI is a Python framework for building autonomous AI agents. It’s independent of LangChain and other agent frameworks, and supports two abstractions: high-level Crews and low-level Flows. CrewAI applications often consist of multiple agents working together, which makes it important to understand how they collaborate and communicate. Weave automatically captures traces for your CrewAI applications so you can monitor and analyze your agents’ performance and interactions. The following sections walk through tracing a Crew, tracking tool usage, tracing a Flow, and wrapping a guardrail function as a Weave op.

Get started with Crew

To run this example, install CrewAI and Weave. For more information about CrewAI installation, see the CrewAI installation guide.
The following example creates a CrewAI Crew and traces the execution with Weave. To enable tracing, call weave.init() at the beginning of your script. The argument to weave.init() is the project name where Weave logs traces.
Weave tracks and logs all calls made through the CrewAI library, including agent interactions, task executions, and LLM calls. You can view the traces in the Weave web interface. crew_trace.png
CrewAI provides several methods for better control over the kickoff process: kickoff(), kickoff_for_each(), kickoff_async(), and kickoff_for_each_async(). The integration supports logging traces from all these methods.

Track tools

CrewAI tools give agents capabilities like web searching, data analysis, collaboration, and delegating tasks among coworkers. The integration traces them as well. The following example improves the quality of the generated report from the previous example by giving the agent access to a tool that can search the internet and return the most relevant results. First, install the extra dependency:
This example uses the SerperDevTool to enable the ‘Research Analyst’ agent to search relevant information on the internet. For more information about this tool and its API requirements, see the SerperDevTool documentation.
Running this Crew with an agent that has internet access produces a more relevant result. Weave automatically traces the tool usage, as shown in the following image. crew_with_tool_trace.png
The integration automatically patches all the tools available in the crewAI-tools repository.

Get started with Flow

The following example defines a CrewAI Flow and traces it with Weave. As with Crews, call weave.init() before defining the Flow so that Weave automatically captures the Flow.kickoff entry point and the @start, @listen, @router, @or_, and @and_ decorators.
flow.png
The integration automatically patches the Flow.kickoff entry point and all the available decorators (@start, @listen, @router, @or_, and @and_).

Crew guardrail: track your own ops

Task guardrails let you validate and transform task outputs before CrewAI passes them to the next task. You can use a Python function to validate the agent’s execution on the fly. Wrapping the guardrail function with @weave.op captures its inputs, outputs, and app logic so you can debug how data is validated through your agents. It also automatically versions the code as you experiment, capturing ad-hoc details that haven’t been committed to git. The following example extends the research analyst and writer Crew by adding a guardrail that validates the length of the generated report.
By decorating the guardrail function with @weave.op, you can track the input and output to this function along with execution time, token information if the function uses an LLM, code version, and more. guardrail.png

Conclusion

You now have a Weave-traced CrewAI application that captures agent interactions, tool usage, Flow execution, and guardrail validations. To suggest improvements or report problems with this integration, open an issue on GitHub. To learn more about building multi-agent systems with CrewAI, see the CrewAI examples and documentation.