Skip to main content
Open In Colab CrewAI is a lean, lightning-fast Python framework built entirely from scratch—completely independent of LangChain or other agent frameworks. CrewAI empowers developers with both high-level simplicity (Crews) and precise low-level control (Flows), ideal for creating autonomous AI agents tailored to any scenario. Learn more about CrewAI here. When working with AI agents, debugging and monitoring their interactions is crucial. CrewAI applications often consist of multiple agents working together, making it essential to understand how they collaborate and communicate. Weave simplifies this process by automatically capturing traces for your CrewAI applications, enabling you to monitor and analyze your agents’ performance and interactions. The integration supports both Crews and Flows.

Getting Started with Crew

You need to install CrewAI (more details) and weave to run this example:
Now we will create a CrewAI Crew and trace the execution using Weave. To get started, simply call weave.init() at the beginning of your script. The argument in weave.init() is a project name where the traces will be logged.
Weave will track and log 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 empower agents with capabilities ranging from web searching and data analysis to collaboration and delegating tasks among coworkers. The integration can trace them as well. We will improve the quality of the generated report in the above example by giving it access to a tool that can search the internet and return the most relevant results. Let us first install the extra dependency.
In this example, we are using the SerperDevTool to enable our ‘Research Analyst’ agent to search relevant information on the internet. Learn more about this tool and API requirements here.
Running this Crew with an agent with access to internet produces better and more relevant result. We automatically trace the tool usage as shown in the image below. crew_with_tool_trace.png
The integration automatically patches all the tools available in the crewAI-tools repository.

Getting Started with Flow

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 provide a way to validate and transform task outputs before they are passed to the next task. We can use a simple python function to validate the agent’s execution on-the-fly. Wrapping this function with @weave.op starts capturing inputs, outputs and app logic so you can debug how data is validated through your agents. This also starts automatically versioning code as you experiment to capture ad-hoc details that haven’t been committed to git. Let’s take the example of research analyst and writer. We add a guardrail to validate the length of the generated report.
By simply decorating the guardrail function with @weave.op we are able to keep track of the input and output to this function along with execution time, token information if an LLM is used under the hood, code version and more. guardrail.png

Conclusion

Do let us know what we should improve about this integration. Please open an issue if you encounter one here. Learn more about how to build powerful multiagent systems using CrewAI through their many examples and documentation.