TraceRazor callback adapter for CrewAI — automatic token efficiency auditing
Project description
tracerazor-crewai
CrewAI callback adapter for TraceRazor.
Automatically captures every task execution and tool call from your CrewAI crew with zero manual instrumentation.
v0.2.0 — New Metrics:
- ✨ Semantic Continuity (CSD) — Detects when your crew's agents drift topic mid-workflow
- ✨ Adherence Scoring (IAR) — After optimizing, validates that fixes actually improved metrics
Install
pip install tracerazor-crewai
pip install tracerazor-crewai[crewai] # includes crewai
Requires the tracerazor binary:
cargo build --release
export TRACERAZOR_BIN=/path/to/TraceRazor/target/release/tracerazor
Usage
from tracerazor_crewai import TraceRazorCallback
from crewai import Agent, Task, Crew
callback = TraceRazorCallback(
agent_name="support-crew",
threshold=70,
)
crew = Crew(
agents=[...],
tasks=[...],
callbacks=[callback],
)
crew.kickoff()
# After the crew finishes:
report = callback.analyse()
print(report.markdown())
# CI/CD gate — raises AssertionError if TAS < threshold:
callback.assert_passes()
API
TraceRazorCallback(agent_name, framework, threshold, task_value_score, tracerazor_bin)
| param | default | description |
|---|---|---|
agent_name |
"crewai-crew" |
shown in all reports |
framework |
"crewai" |
framework label |
threshold |
70.0 |
minimum TAS for assert_passes() |
task_value_score |
1.0 |
answer quality (0–1) |
tracerazor_bin |
auto | path to binary; falls back to TRACERAZOR_BIN env var |
callback.analyse() → TraceRazorReport
Finalise and submit the trace. Returns the report.
callback.assert_passes()
Raise AssertionError if TAS < threshold.
callback.set_task_value_score(score: float)
Update quality score before calling analyse().
Captured events
| CrewAI event | TraceRazor step type |
|---|---|
on_task_start / on_task_end |
reasoning |
on_agent_action |
reasoning or tool_call |
on_tool_use_start / on_tool_use_end |
tool_call (success) |
on_tool_error |
tool_call (failure → TCA misfire) |
Multi-Agent Crews
For complex workflows with multiple crews, use a separate callback for each:
from tracerazor_crewai import TraceRazorCallback
# Crew 1: Triage & classification
triage_crew = Crew(agents=[triage_agent], tasks=[triage_task],
callbacks=[TraceRazorCallback(agent_name="triage-crew")])
triage_result = triage_crew.kickoff()
# Crew 2: Resolution execution
resolution_crew = Crew(agents=[resolution_agent], tasks=[resolution_task],
callbacks=[TraceRazorCallback(agent_name="resolution-crew")])
resolution_result = resolution_crew.kickoff()
# Each crew is audited independently
See Multi-Agent Guide for complete example with per-agent optimization.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tracerazor_crewai-0.2.0.tar.gz.
File metadata
- Download URL: tracerazor_crewai-0.2.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ae9971c3182eb6d1860b226fe0ec3c60023ef049deba057b1a5fb86eb07b002
|
|
| MD5 |
14af762523de88e011a093765405d4bf
|
|
| BLAKE2b-256 |
5add6bb769d1fc849af113d06c3dc645be04246c90469f092a02b81a81bfa4be
|
File details
Details for the file tracerazor_crewai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tracerazor_crewai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ea418cb9e47c30a6ffa5fd47a096b5921277beae8695ad3b59f23033e77e9b0
|
|
| MD5 |
c947217244201a2cf51a6fd42c721a1f
|
|
| BLAKE2b-256 |
42904127b1b4e2fa91ba7ccf279dc2b2ddd74d15e7dcb4fc305ff0ff49dd0d89
|