> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracectrl.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# CrewAI

> Instrument CrewAI agents and crews with TraceCtrl

## Installation

`tracectrl` is on PyPI. The CrewAI instrumentor is not yet published — install it from the source tree.

```bash theme={"dark"}
pip install tracectrl
pip install ./sdk/tracectrl-instrumentation-crewai
```

<Note>
  PyPI publication of `tracectrl-instrumentation-crewai` is pending. Until then, install from a local checkout or via `pip install git+https://github.com/cloudsine/tracectrl.git#subdirectory=sdk/tracectrl-instrumentation-crewai`.
</Note>

## Usage

```python theme={"dark"}
import tracectrl
from tracectrl import tag_agent
from tracectrl.instrumentation.crewai import CrewAIInstrumentor

tracectrl.configure(service_name="my-crew")
CrewAIInstrumentor().instrument()

from crewai import Agent, Task, Crew

researcher = Agent(role="Researcher", goal="Find data", backstory="...")
writer = Agent(role="Writer", goal="Write report", backstory="...")
tag_agent(researcher)
tag_agent(writer)

crew = Crew(agents=[researcher, writer], tasks=[...])
crew.kickoff()
```

Tag each agent in the crew so delegation edges resolve to the correct identities in TraceCtrl's topology.

## What Gets Captured

Each agent in the crew generates spans with:

* Agent identity (`tracectrl.agent.id`, `tracectrl.agent.name`, `tracectrl.agent.role`)
* Tool calls with risk categories
* Agent-to-agent delegation (crew → agent parent-child spans)
* LLM calls with model name and system prompt hash

CrewAI's multi-agent delegation appears as nested spans in the trace tree, with the crew as the root and each agent as a child.

## API

### `CrewAIInstrumentor()`

<ParamField path="instrument" type="method">
  `instrument(tracer_provider=None, skip_dep_check=False)` — Registers the TraceCtrl span processor and wraps the OpenInference CrewAI instrumentor.
</ParamField>

<ParamField path="uninstrument" type="method">
  `uninstrument()` — Shuts down the TraceCtrl processor and unwraps the OpenInference instrumentor.
</ParamField>

<ParamField path="instrumented" type="bool">
  Whether the instrumentor is currently active.
</ParamField>
