dprovenance.dev / integrations / crewai

CrewAI tracing
that fails the PR.

DProvenanceKit hooks CrewAI's global event bus with a single event listener: construct it once and every crew.kickoff() is recorded as a queryable, diffable trace. Then diff a candidate run against a golden baseline and gate CI when the crew's reasoning drifts — a dropped task, a looping tool, a changed execution path. Crew regression testing, one line of setup.

Works with modern CrewAI (0.85+, the LangChain-free line) via crewai.events. Constructing the listener registers it on the bus — no other code changes.

# 01 · install

Install

shell
$ pip install "dprovenancekit[crewai]"

Python 3.10+ · zero third-party deps in the core · the extra pulls in crewai>=1.0.0.

# 02 · attach the listener

Attach the listener

Constructing DProvenanceKitEventListener(store) registers it on CrewAI's global event bus. Every crew.kickoff() after that is recorded — no other code changes.

trace_crew.pypython
from crewai import Agent, Crew, Task
from dprovenancekit import SQLiteTraceStore
from dprovenancekit.integrations.crewai import (
    CrewAITraceEvent,
    DProvenanceKitEventListener,
)

store = SQLiteTraceStore(CrewAITraceEvent, "traces.sqlite")
listener = DProvenanceKitEventListener(store) # registers on crewai's event bus

# ... build your agents / tasks / crew as usual ...
crew.kickoff()                       # recorded: crew / task / agent / tool / llm events
listener.force_flush()               # drain crewai's event bus and persist the run

Full reference: the CrewAI section of the README.

# 03 · what gets recorded

What gets recorded

DProvenanceKitEventListener is a crewai.events.BaseEventListener, so it sees the same lifecycle stream CrewAI emits:

  • Each crew.kickoff() becomes one diffable run.
  • crew.start/.end, task.*, agent.*, tool.*, and llm.* become typed events in a span tree.
  • The agent's role, the tool's name, or the model becomes the event's engine.
  • Events are ordered by CrewAI's own emission_sequence — its bus is multithreaded, so arrival order isn't emission order, and ordering by sequence keeps the run (and its fingerprint) stable.
  • Lifecycle provenance edges are emitted: DERIVED_FROM (start → end) and INFORMED (parent → child).

Two runs of the same crew share a fingerprint, so the fingerprint / diff / gate tooling flags a dropped task, a skipped tool, or a looping agent.

# 04 · gate in ci

Then gate it in CI

Once runs are recorded, diff any run against a golden baseline and fail the PR when the reasoning drifts. The server-less gate CLI exits non-zero on regression, and the DProvenanceKit Regression Gate GitHub Action drops it into any workflow — see the full gate story on the main page.