Skip to main content

tracerazor-langgraph

LangGraph/LangChain callback adapter for TraceRazor.

Automatically captures every LLM call and tool call from your LangGraph graph with zero manual instrumentation.

v0.2.0 — New Metrics:

  • ✨ Semantic Continuity (CSD) — Detects when your agent's reasoning drifts topic mid-execution
  • ✨ Adherence Scoring (IAR) — After optimizing, validates that fixes actually improved metrics

Install

pip install tracerazor-langgraph
pip install tracerazor-langgraph[langgraph]  # includes langgraph

Requires the tracerazor binary:

cargo build --release
export TRACERAZOR_BIN=/path/to/TraceRazor/target/release/tracerazor

Usage

from tracerazor_langgraph import TraceRazorCallback
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI

callback = TraceRazorCallback(
    agent_name="support-agent",
    threshold=70,
)

model = ChatOpenAI(model="gpt-4o-mini")
agent = create_react_agent(model, tools=[...])

result = agent.invoke(
    {"messages": [HumanMessage(content="I want a refund")]},
    config={"callbacks": [callback]},
)

# After the agent 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 "langgraph-agent" shown in all reports
framework "langgraph" 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().

Multi-Agent Workflows

For workflows with multiple graphs or nodes, use a separate callback for each agent:

from tracerazor_langgraph import TraceRazorCallback

# Agent 1: Triage
triage_callback = TraceRazorCallback(agent_name="triage-agent")
triage_result = triage_graph.invoke(input, config={"callbacks": [triage_callback]})
triage_report = triage_callback.analyse()

# Agent 2: Resolution
resolution_callback = TraceRazorCallback(agent_name="resolution-agent")
resolution_result = resolution_graph.invoke(triage_result, config={"callbacks": [resolution_callback]})
resolution_report = resolution_callback.analyse()

# Aggregate metrics
total_tokens = triage_report.total_tokens + resolution_report.total_tokens
avg_efficiency = (triage_report.tas_score + resolution_report.tas_score) / 2

Each agent is audited independently, enabling per-agent optimization. See Multi-Agent Guide for complete example with cost analysis.

Metadata

Release files for tracerazor-langgraph 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tracerazor-langgraph 1.0.0
File Size Uploaded
tracerazor_langgraph-1.0.0.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tracerazor-langgraph 1.0.0
File Interpreter ABI Platform
tracerazor_langgraph-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / tracerazor_langgraph-1.0.0.tar.gz

Download URL tracerazor_langgraph-1.0.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3b0677d6a3e9a6f32a24e8d61c005ca7c635341a7fff5e8aa1981a2cacf71212
BLAKE2b-256 checksum
How to use checksums
58aa1f075ac206959258f50b78ce452308db07fc409e7e3e71cb193371c5d176
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release files / tracerazor_langgraph-1.0.0-py3-none-any.whl

Download URL tracerazor_langgraph-1.0.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4208ec33b36fccac4cb70291a343380410c4d5c9c7f04dc83497c7bfb70672a9
BLAKE2b-256 checksum
How to use checksums
7bede34f88eb250c7f5310a33a3afffc5eee780fb3779beafc62d6bfe4a00863
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page