Skip to main content

DriftGuard

Observability for LLM applications and AI agents: catch drift, find the tool that's blocking your agent, and count the tokens it's wasting.

When an agent keeps retrying a failing tool, you pay for every attempt and the task never finishes. DriftGuard receives one event per tool call and names the blocking tool. It totals the wasted tokens and alerts you, for example: "The terminal tool failed 3 times in a row on task fix-tests; 6,600 tokens were spent on failed or redundant attempts." It also scores ordinary LLM traffic for drift: prompt and context bloat, falling retrieval relevance, and falling response quality.

  • Agent diagnosis. Per-task status (blocked, failing, recovered, healthy), the blocking tool, repeated and redundant attempts, wasted tokens, and advice based on the error.
  • Activity logs. A searchable, live history of every tool call, model call, prompt and session, with CSV/JSON export. Inputs and outputs are stored only if you opt in per project.
  • Drift scoring. Four normalized metrics are checked against per-project thresholds and turned into a severity, a root cause, and a recommended mitigation. The Overview also compares each window with the period before it, and says so when there are too few events to judge.
  • Alerts that manage themselves. Critical drift and blocked tasks raise alerts. Agent alerts resolve themselves when the task recovers. Alerts are pushed live to the dashboard, Slack, or any webhook.
  • Any agent, no code. An driftguard-mcp-proxy gateway records any MCP client's tool calls from the middle of the stdio stream.
  • Framework adapters. LangChain/LangGraph callbacks, the OpenAI Agents SDK, and the Claude Agent SDK, each one or two lines to wire in.
  • Drop-in adapters. A @driftguard_tool decorator, MCP session instrumentation, token extraction from OpenAI, Anthropic, and Gemini responses, and a no-code Claude Code hook.
  • Fast to operate. A status plate and a track diagram tell you what is blocked first. Keyboard shortcuts, links that carry your filters, bulk resolve, and a Policy page that shows what each threshold would flag.
  • Self-hostable. A FastAPI server, a React dashboard, and SQLite or PostgreSQL, with Redis when you scale out. One docker compose up.

DriftGuard observes what your code reports, and it recommends actions rather than taking them. It doesn't intercept closed agents such as GitHub Copilot, and it never changes prompts or providers. See what it can't observe.

Start here

I want to… Do this
Set it up on a teammate's laptop Follow SETUP.md
See it running in two minutes (Windows) Double-click demo.bat. Sign in as demo@driftguard.local / driftguard-demo.
Run it from this repo pip install -e ".[server]", cd frontend && npm ci && npm run build, then driftguard-server. Details in Getting started.
Fill the dashboard with sample data python examples/seed_showcase.py --api-key dg_live_... --project-id showcase
Watch my own Claude Code sessions Claude Code hook
Watch any MCP client's tools (no code) driftguard-mcp-proxy (MCP gateway)
Understand how it works How DriftGuard works, then Architecture
Send retrieval and quality scores Measuring retrieval score and response quality

Every view is described in the dashboard guide. The architecture diagram and dashboard screenshots are in the docs.

Quickstart (SDK)

pip install "driftguard-tokepi[server]"   # PyPI name is driftguard-tokepi; you still import driftguard
driftguard-server                    # dashboard and API at http://127.0.0.1:8000

Create an account and a project in the dashboard, and copy the project API key. Then, in your app:

from driftguard import DriftGuardClient
from driftguard.adapters import AgentContext, driftguard_tool

client = DriftGuardClient(api_key="dg_live_...", project_id="coding-agent",
                          base_url="http://127.0.0.1:8000")

# LLM telemetry
client.capture_metrics(prompt_tokens=5200, context_length=6100,
                       retrieval_score=0.31, response_quality=0.62)
client.check_drift()   # {'severity': 'critical', 'risk_score': 1.0, 'actions': [...], ...}
client.sync_metrics()

# Agent tool calls
@driftguard_tool("terminal")
def run(cmd): ...

with AgentContext(client, task_id="fix-tests", auto_sync=True) as ctx:
    ctx.record_llm_usage(llm_response)   # attach model tokens to the next tool call
    run("pytest -x")

client.fetch_agent_diagnosis()["diagnosis"]

The SDK itself (pip install driftguard-tokepi) depends only on httpx. The full walkthrough, including Docker, is in docs/quickstart.md.

Documentation

Getting started Three ways to run it, five ways to send data, troubleshooting
How DriftGuard works Plain-language concepts, scoring and diagnosis with worked examples
Giving a demo A five-minute live demo, a presentation outline, talking points
What the package offers What pip install driftguard-tokepi provides (SDK, adapters, gateway)
Using the package Install it and wire the SDK, adapters and gateway into your project
Using the dashboard Open, navigate and operate the web UI
Agent integration Decorator, MCP, raw events, and what can't be observed
Dashboard guide Every view, card and column, with screenshots
Measuring scores How to calculate retrieval score and response quality, choosing floors, and what the numbers can't tell you
API reference Every endpoint, with real request and response bodies
Architecture Diagrams, components, request flows, algorithms, data model, security
Configuration Environment variables and policy settings
Deployment Docker Compose, TLS, scaling, backups, upgrading from 0.3
Development Repo layout, tests on SQLite/Postgres/Redis, CI, releasing
Design system The dashboard's look, in plain language (DESIGN.md has the tokens)
Product context Who it is for, what it does, and the constraints work must keep
Research A simulation study of floors against the baseline comparison, plus the Phase 1 prototypes
Progress report What is done, what changed, and what is next
Roadmap What's done and what's next
Changelog Release history

Repository layout

driftguard/     the Python package: SDK, adapters, and driftguard.server
frontend/       dashboard source (React + Vite); builds into driftguard/server/static
research/       the baseline study (simulation) and the Phase 1 drift prototypes
integrations/   no-code integrations, starting with Claude Code hooks
tests/          SDK and server test suite
examples/       runnable scripts, including the live demo (demo.bat runs it on Windows)
docs/           documentation, including PRODUCT.md and the screenshots in docs/images
DESIGN.md       the dashboard's design tokens and components

Development

pip install -e ".[dev]"
pytest                                   # SQLite; see docs/development.md for Postgres/Redis
ruff check . && ruff format --check .
cd frontend && npm install && npm run dev

License

MIT. See LICENSE.

Metadata

Release files for driftguard-tokepi 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for driftguard-tokepi 0.5.1
File Size Uploaded Provenance Actions
driftguard_tokepi-0.5.1.tar.gz 319.7 kB With provenance Details for driftguard_tokepi-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for driftguard-tokepi 0.5.1
File Interpreter ABI Platform Actions
driftguard_tokepi-0.5.1-py3-none-any.whl Python 3 none any Details for driftguard_tokepi-0.5.1-py3-none-any.whl

Total release size: 637.7 kB

Release files / driftguard_tokepi-0.5.1.tar.gz

Download URL driftguard_tokepi-0.5.1.tar.gz
Size 319.7 kB
Tags Source
SHA-256 checksum
How to use checksums
422e96335ef994c7271a0c5a81cec5e79ecf053fbf3d55153488bf73d1ee43ea
BLAKE2b-256 checksum
How to use checksums
06f3a3a5fb637baed4fecbd28871cd101411409b8c8881db26db21a1d36d736b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / driftguard_tokepi-0.5.1-py3-none-any.whl

Download URL driftguard_tokepi-0.5.1-py3-none-any.whl
Size 318.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fae136a6a7ace624b0a910a757ca69b0bbe9b57894b3419810ba551c9459510a
BLAKE2b-256 checksum
How to use checksums
edcd8b933f35511e82096f401116aa46b7da4c93ec22a03492905e7ab635a1c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Security for driftguard-tokepi 0.5.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for driftguard_tokepi-0.5.1.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 Nov 11, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.1 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