Get started with Crew
To run this example, install CrewAI and Weave. For more information about CrewAI installation, see the CrewAI installation guide.weave.init() at the beginning of your script. The argument to weave.init() is the project name where Weave logs traces.
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: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.
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, callweave.init() before defining the Flow so that Weave automatically captures the Flow.kickoff entry point and the @start, @listen, @router, @or_, and @and_ decorators.
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.
@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.