Skip to main content

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

Project description

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

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

detra-0.2.0.tar.gz (172.4 kB view details)

Uploaded Source

Built Distribution

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

detra-0.2.0-py3-none-any.whl (112.0 kB view details)

Uploaded Python 3

File details

Details for the file detra-0.2.0.tar.gz.

File metadata

  • Download URL: detra-0.2.0.tar.gz
  • Upload date:
  • Size: 172.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for detra-0.2.0.tar.gz
Algorithm Hash digest
SHA256 91511ebb1cbca6fbfad5ea5aae8aa26ff929c5cbc6a48829e634d86f45317198
MD5 7da8616b5155da612d2d2e68d2b730c7
BLAKE2b-256 c5f5d71c0b4faf71b67c31c663a63c52d123bc696177776bf856689a22e367e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for detra-0.2.0.tar.gz:

Publisher: publish-pypi.yml on adc77/detra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file detra-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: detra-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 112.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for detra-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d18bff9f5eae7a6e00167eff22bb338b03dee243cb690cb1761d6ae86413bdd
MD5 c893758b312d499a1a5cc2763dcd5983
BLAKE2b-256 a4bf32ecd68327f89dd08a40421211f41010e8c66bcfe4a7e0994081b9ea1d50

See more details on using hashes here.

Provenance

The following attestation bundles were made for detra-0.2.0-py3-none-any.whl:

Publisher: publish-pypi.yml on adc77/detra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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