Skip to main content

detra

LLM/agent observability for behavior deviations, guardrails, and telemetry.

detra traces LLM and agent steps, compares outputs against configured behavior expectations, flags deviations, and ships metrics/events to your telemetry backend. Deterministic checks run first; LLM judges are optional and should be sampled or used with compact evidence.

Install

pip install detra                    # core only (6 deps)
pip install "detra[litellm]"         # + any-model judge
pip install "detra[otel]"            # + OpenTelemetry backend
pip install "detra[datadog]"         # + Datadog backend
pip install "detra[all]"             # everything

Quick Start

import detra

vg = detra.init("detra.yaml")

@vg.trace("refund_policy_agent")
async def answer_refund_question(message: str):
    result = await agent.run(message)
    return result

# Tracing + deviation checks happen automatically
result = await answer_refund_question("Can I get a refund after 90 days?")

Define Behaviors in YAML

app_name: my-llm-app

judge_config:
  provider: none        # or: litellm, gemini
  model: gpt-4o-mini

sampling:
  rate: 0.1

nodes:
  refund_policy_agent:
    expected_behaviors:
      - "Must answer with either eligible, ineligible, or needs_review"
      - "Must mention the policy window when denying a refund"
      - "Must route to needs_review for missing order dates"
    unexpected_behaviors:
      - "Approves refunds outside the policy window"
      - "Invents policy exceptions"
      - "Asks for payment details"
    adherence_threshold: 0.90
    security_checks:
      - pii_detection
      - prompt_injection

Pluggable Architecture

Backends -- where telemetry goes:

Backend Install Use case
Console included Local dev, CI
OpenTelemetry detra[otel] Prometheus, Jaeger, OTLP
Datadog detra[datadog] Datadog LLM Observability
Custom included Implement the protocol

Judges -- optional reviewers for sampled or ambiguous behavior checks:

Judge Install Models
LiteLLM detra[litellm] GPT-4o, Claude, Gemini, Llama, 100+
Gemini detra[gemini] Google Gemini models
None included Rules-only mode

Evaluation Pipeline

  1. Rule checks (fast): empty output, JSON validity, length
  2. Security scans: PII, prompt injection, sensitive content
  3. Behavior/deviation checks: expected/unexpected behaviors from YAML spec
  4. Optional sampled judge: for ambiguous cases or compact evidence
  5. Flag + alert: when score < threshold or security issues found

Decorator Types

@vg.trace("node")          # generic
@vg.workflow("pipeline")   # workflow
@vg.llm("model_call")     # LLM call
@vg.task("processing")    # task
@vg.agent("step")         # agent

Works on sync and async functions. Safe inside running event loops (FastAPI, etc.).

Links

License

MIT

Metadata

Release files for detra 0.2.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 detra 0.2.0
File Size Uploaded Provenance
detra-0.2.0.tar.gz 172.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for detra 0.2.0
File Interpreter ABI Platform
detra-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 284.4 kB

Release files / detra-0.2.0.tar.gz

Download URL detra-0.2.0.tar.gz
Size 172.4 kB
Tags Source
SHA-256 checksum
How to use checksums
91511ebb1cbca6fbfad5ea5aae8aa26ff929c5cbc6a48829e634d86f45317198
BLAKE2b-256 checksum
How to use checksums
c5f5d71c0b4faf71b67c31c663a63c52d123bc696177776bf856689a22e367e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 1, 2026.

Transparency log

Release files / detra-0.2.0-py3-none-any.whl

Download URL detra-0.2.0-py3-none-any.whl
Size 112.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d18bff9f5eae7a6e00167eff22bb338b03dee243cb690cb1761d6ae86413bdd
BLAKE2b-256 checksum
How to use checksums
a4bf32ecd68327f89dd08a40421211f41010e8c66bcfe4a7e0994081b9ea1d50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 1, 2026.

Transparency log

Security for detra 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for detra-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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