Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tracerazor_crewai-1.0.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tracerazor_crewai-1.0.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file tracerazor_crewai-1.0.0.tar.gz.

File metadata

  • Download URL: tracerazor_crewai-1.0.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

Hashes for tracerazor_crewai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 64f38ceb156b04ef2e61da64a7e2c16170cacbacd3b7d536bb65b604b295c739
MD5 414ca79a138ffd62a58d686b17b301bc
BLAKE2b-256 1eea70566cfebfb53783fc310360cac70910b5563382034f2f48ec9cb67400a5

See more details on using hashes here.

File details

Details for the file tracerazor_crewai-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tracerazor_crewai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf018a19e51aa7bb605e9f06936004ede7fb6f60c043939bf45fca6ab02df342
MD5 0c9f8d21e9a14ffae62635d9301d69ed
BLAKE2b-256 a3fb7d9d657ae9b1db5e5538462b4a3cf073be756413d6e52c0253a14449f093

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page