Skip to main content

TraceRazor hooks adapter for the OpenAI Agents SDK

Project description

tracerazor-openai-agents

OpenAI Agents SDK hooks adapter for TraceRazor.

Automatically captures every LLM call, tool execution, and agent handoff from a Runner.run() invocation — zero manual instrumentation required.

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-openai-agents
pip install tracerazor-openai-agents[agents]  # includes openai-agents

Requires the tracerazor binary:

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

Usage

from tracerazor_openai_agents import TraceRazorHooks
from agents import Agent, Runner

hooks = TraceRazorHooks(
    agent_name="support-agent",
    threshold=70,
)

result = await Runner.run(
    agent,
    "I need a refund for order ORD-9182",
    hooks=hooks,
)

# After the run:
report = hooks.analyse()
print(report.markdown())

# CI/CD gate — raises AssertionError if TAS < threshold:
hooks.assert_passes()

API

TraceRazorHooks(agent_name, framework, threshold, task_value_score, tracerazor_bin)

param default description
agent_name "openai-agent" shown in all reports
framework "openai-agents" 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

hooks.analyse() → TraceRazorReport

Finalise and submit the trace. Returns the report.

hooks.assert_passes()

Raise AssertionError if TAS < threshold.

hooks.set_task_value_score(score: float)

Update quality score before calling analyse().

Captured events

SDK hook TraceRazor step type
on_agent_end reasoning (agent output)
on_tool_start / on_tool_end tool_call (success)
on_handoff reasoning (handoff marker)

Multi-agent traces

When your workflow uses multiple agents via handoffs, TraceRazor automatically produces a per-agent breakdown alongside the composite score:

MULTI-AGENT BREAKDOWN
Agent                    Steps   Tokens   Share      TAS  Grade
TriageAgent                  4    1,200   28.6%     82.5  GOOD
SupportAgent                 7    2,600   61.9%     61.2  FAIR
EscalationAgent              2      400    9.5%      N/A  N/A

The composite TAS is weighted by each agent's token consumption.

See Multi-Agent Guide for detailed workflow examples with cost analysis and optimization validation.

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_openai_agents-1.0.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

tracerazor_openai_agents-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for tracerazor_openai_agents-1.0.0.tar.gz
Algorithm Hash digest
SHA256 baec210434d13c7e63a0febd8ed12508420d672b54012fd365d2f88fb9e229d8
MD5 82a9c8a4181950fd4902b60db6c8d911
BLAKE2b-256 16f1c7c52845d86715c36676eeae997b3ead573ace27555d8951a544149877af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tracerazor_openai_agents-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9268efd258d91716026554f546c2354a350a8c12a3f07678a4ee9c2c606ea3e7
MD5 49f919888969360789f10d6e7607612c
BLAKE2b-256 aef7cc58bfd394890bbe0974c5b303964519374e29d3470f6a7a0e35a02633dd

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