Skip to main content

Behavioral observability for AI agents

Project description

Dunetrace SDK

Runtime observability for AI agents. Detects tool loops, context bloat, prompt injection, and 12 other failure patterns in real-time — with a Slack alert while the run is still live.

Zero external dependencies.

Install

pip install dunetrace                    # core SDK
pip install 'dunetrace[langchain]'       # + LangChain / LangGraph
pip install 'dunetrace[otel]'            # + OpenTelemetry exporter

Quickstart

LangChain / LangGraph

from dunetrace import Dunetrace
from dunetrace.integrations.langchain import DunetraceCallbackHandler

dt = Dunetrace()
callback = DunetraceCallbackHandler(dt, agent_id="my-agent")

result = agent.invoke(input, config={"callbacks": [callback]})
dt.shutdown()

Pure Python / custom agent

from dunetrace import Dunetrace

dt = Dunetrace()
dt.init(agent_id="my-agent")   # patches openai, anthropic, httpx, requests globally

@dt.agent(model="gpt-4o")      # agent_id inherited from init()
def run_agent(query: str) -> str:
    return openai_client.chat.completions.create(...).choices[0].message.content

FastAPI / Flask — one line each, see docs/integrations.md.

What it detects

Detector What it catches Severity
TOOL_LOOP Same tool called 3+ times in a 5-call window HIGH
TOOL_THRASHING Agent alternates between exactly two tools HIGH
RETRY_STORM Same tool fails 3+ times in a row HIGH
LLM_TRUNCATION_LOOP finish_reason=length fires 2+ times HIGH
EMPTY_LLM_RESPONSE Zero-length output with finish_reason=stop HIGH
CASCADING_TOOL_FAILURE 3+ consecutive failures across 2+ distinct tools HIGH
SLOW_STEP Tool call >15s or LLM call >30s MEDIUM/HIGH
TOOL_AVOIDANCE Final answer without using available tools MEDIUM
GOAL_ABANDONMENT Tool use stops, then 4+ consecutive LLM calls with no exit MEDIUM
CONTEXT_BLOAT Prompt tokens grow 3× from first to last LLM call MEDIUM
STEP_COUNT_INFLATION Run used >2× the P75 step count for this agent MEDIUM
FIRST_STEP_FAILURE Error or empty output at step ≤2 MEDIUM
REASONING_STALL LLM:tool-call ratio ≥4× — reasoning without acting MEDIUM
RAG_EMPTY_RETRIEVAL Retrieval returned 0 results but agent answered anyway MEDIUM
PROMPT_INJECTION_SIGNAL Input matches known injection / jailbreak patterns CRITICAL

Output modes

Mode How to enable Destination
HTTP ingest (default) endpoint="http://…" Dunetrace backend → detection, alerts, dashboard
Loki NDJSON emit_as_json=True stdout → Promtail / Grafana Alloy
OpenTelemetry otel_exporter=DunetraceOTelExporter(provider) Tempo, Honeycomb, Datadog, Jaeger

Backend

git clone https://github.com/dunetrace/dunetrace
cd dunetrace && cp .env.example .env && docker compose up -d

Dashboard → http://localhost:3000 · Ingest → http://localhost:8001

Tests

python -m unittest discover -s tests -v

52 tests, no network required.

Links

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

dunetrace-0.3.7.tar.gz (48.0 kB view details)

Uploaded Source

Built Distribution

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

dunetrace-0.3.7-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file dunetrace-0.3.7.tar.gz.

File metadata

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

File hashes

Hashes for dunetrace-0.3.7.tar.gz
Algorithm Hash digest
SHA256 28dc6da77d2b5244b4a2fb6166fb3f01ce6d023a2f3f5dbb1219708221074e6f
MD5 2294887bc2934ddc4861fe3c4086c21d
BLAKE2b-256 e1d0117c8c9a5154eceecc19a3235a213fe212721e020565915be0b63d1a72e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dunetrace-0.3.7.tar.gz:

Publisher: publish.yml on dunetrace/dunetrace

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

File details

Details for the file dunetrace-0.3.7-py3-none-any.whl.

File metadata

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

File hashes

Hashes for dunetrace-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d1700a06f192687010b7e03e183d0502aaed314796d5c4f98a3972af62451eec
MD5 1f9d736eb6a43678e743f6ab3820f4ef
BLAKE2b-256 98e81c3dbcde29723fe0939b4d323a0b61e8b40b8da2647c21045f1203bccb9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dunetrace-0.3.7-py3-none-any.whl:

Publisher: publish.yml on dunetrace/dunetrace

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