Skip to main content

TraceRazor LangGraph/LangChain callback — token efficiency auditing

Project description

tracerazor-langgraph

LangGraph/LangChain callback adapter for TraceRazor.

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

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().

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_langgraph-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

tracerazor_langgraph-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file tracerazor_langgraph-0.1.0.tar.gz.

File metadata

  • Download URL: tracerazor_langgraph-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for tracerazor_langgraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eef42eda926a27afa5cb3220f6e3e812fa01d539fd2708fe8018e92b5dc5f58e
MD5 94c62b7130cebf6cf3d76cc6581dc659
BLAKE2b-256 7afaff9d63fa54f618870f6f1c9b4cf515b4e1e9228a60552da170ca3bac6261

See more details on using hashes here.

File details

Details for the file tracerazor_langgraph-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tracerazor_langgraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee8883777c4ab0f8a8d372378cc5141f059bd53eabe9dfd2220f8d321f04ec18
MD5 d120485f7738a18ff4222d2d04b2b60b
BLAKE2b-256 72c1156a14ad747607898683348e121f84f814593f45f7cd846e910154e64231

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