The precipiq.integrations.crewai module wraps CrewAI’s step_callback hook so every AgentAction (a mid-task tool call) and AgentFinish (task complete) is automatically recorded as a Precipiq decision. Pass the callback when you construct a crewai.Agent and all subsequent task executions land in your ledger with full input/output capture and a reasoning trace.
Like the LangChain adapter, this module is import-time optional — the base precipiq package never imports anything from crewai.
Install
pip install precipiq crewai
Usage
from crewai import Agent, Crew, Task
from precipiq import Precipiq
from precipiq.integrations.crewai import PrecipiqCrewAICallback
pq = Precipiq(api_key="pq_test_demo_key_REPLACE_ME")
callback = PrecipiqCrewAICallback(pq, agent_id="researcher")
researcher = Agent(
role="Researcher",
goal="Find three sources on a topic",
backstory="…",
step_callback=callback,
)
task = Task(
description="Research the AI Consequences Ledger",
agent=researcher,
expected_output="three bullet points",
)
Crew(agents=[researcher], tasks=[task]).kickoff()
What gets recorded per step
Every step_callback invocation produces a decision record with the following fields:
action_type — "agent_action" for an AgentAction (mid-task tool call), or "agent_finish" for an AgentFinish (task complete).
inputs — the tool_input on an action, or the prior output on a finish.
outputs — the tool’s result on an action, or the agent’s final answer on a finish.
metadata — the CrewAI step log, which contains the agent’s reasoning trace.
Multi-agent crews
Instantiate one callback per agent so each agent’s decisions are attributed to its own agent_id. All decisions land on the same org-wide ledger — use the dashboard’s agent filter to separate them for reporting.
researcher_cb = PrecipiqCrewAICallback(pq, agent_id="researcher")
writer_cb = PrecipiqCrewAICallback(pq, agent_id="writer")
researcher = Agent(
role="Researcher",
step_callback=researcher_cb,
goal="Find three primary sources on the topic",
backstory="A careful reader.",
)
writer = Agent(
role="Writer",
step_callback=writer_cb,
goal="Turn research into a one-page brief",
backstory="A clear prose stylist.",
)
With multiple agents in the ledger, the Precipiq dashboard’s agent filter lets you drill down to the decisions made by a single agent while still viewing the aggregate P&L across the full crew.