Skip to main content

Behavioral drift monitoring for AI agents.

Project description

Driftbase

Behavioral drift detection for AI agents.

Fingerprint your agent's behavior in production. Diff two versions. Get a statistically grounded drift score, financial impact analysis, and plain-English verdict — before your users notice something changed.

PyPI version License: Apache 2.0 Python 3.9+


What it does

Most observability tools tell you your agent ran. They don't tell you it behaved differently than last week.

Driftbase records behavioral signals from each run — tool call sequences, latency percentiles, token cost bloat, and decision outcomes — and computes a drift score when you compare two versions. Every deploy gets a verdict: ship, monitor, review, or block.

  • One decorator, zero config — wraps your existing agent entry point.
  • Financial impact — translates token bloat directly into Euro (€) cost deltas.
  • Data never leaves your machine — local SQLite, zero egress architecture.
  • Edge PII Scrubbing — built-in regex engine strips emails, IBANs, and IPs before hashing.
  • Plain-English verdicts — tells you exactly what changed and what to do next.

The 60-Second Quickstart

See the drift engine in action right now without writing any code.

1. Install

For production tracking (decorator only):

pip install driftbase

For local analysis (CLI + diff engine):

pip install 'driftbase[analyze]'

The base install provides the @track() decorator with minimal dependencies (pydantic, httpx). The [analyze] profile adds numpy, scipy, and rich for statistical drift computation and terminal UI.

2. Run the synthetic demo

This command instantly populates your local database with 50 baseline runs (v1.0) and 50 regressed runs (v2.0 with higher token usage and hallucinated tool calls).

driftbase demo

Note: Run driftbase demo only once on a fresh database. Multiple runs will accumulate additional synthetic data. To start fresh, delete ~/.driftbase/runs.db before running demo again.

3. Diff the versions

driftbase diff v1.0 v2.0

You will immediately see a rich terminal UI detailing the financial impact, tool sequence changes, and a root-cause hypothesis:

────────────────────────────────────────────────
  DRIFTBASE  v1.0 → v2.0  ·  50 vs 50 runs
────────────────────────────────────────────────

  Overall drift      0.28  [0.24–0.31, 95% CI]

  Decisions          0.39  · MODERATE
    └─ escalation rate jumped from 5% → 17%
  Latency            0.34  · MODERATE
    └─ p95 increased 4970ms → 6684ms
  Errors             0.03  ✓ STABLE

╭──────────────── Financial Impact ─────────────────╮
│ Cost increased by 223.6%. This change will cost   │
│ an additional €10.46 per 10,000 runs.             │
╰────────────────────────────────────────────────────╯

╭──────────────── VERDICT  ⚠ REVIEW ────────────────╮
│ Most likely cause:                                 │
│   → Tool 'search_knowledge_base' dropped from      │
│     baseline — no longer being called              │
╰────────────────────────────────────────────────────╯

4. Inspect the failure

Grab a run ID from the synthetic data and see exactly what happened. This proves your raw text is safely hashed at the edge:

driftbase inspect <RUN_ID>

Instrument Your Code

Once you see the value, drop Driftbase into your actual application. It auto-detects LangChain, LangGraph, LlamaIndex, and raw OpenAI clients.

In your production container (requires only pip install driftbase):

from driftbase import track
import openai

@track(version="v1.0")
def run_agent(prompt: str):
    client = openai.Client()
    return client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": prompt}],
        tools=[{"type": "function", "function": {"name": "query_db"}}]
    )

# Run your code normally. Telemetry is silently captured in ~/.driftbase/runs.db
run_agent("What's the revenue for Q4?")

On your laptop or in CI (requires pip install 'driftbase[analyze]'), let the data decide:

driftbase diff v1.0 v2.0 --format md > pr_comment.md

The @track decorator has zero production overhead (pydantic + httpx only). Statistical analysis runs locally with numpy/scipy.


EU Compliance & Data Sovereignty

Driftbase is engineered specifically for European teams with strict compliance obligations (GDPR, EU AI Act, DORA).

  • Zero-Egress: The free tier runs entirely on your machine. Data never goes to US servers.
  • Structural Hashing: We analyze the structure of the behavior, not the sensitive context.
  • Edge PII Scrubbing: Enable the scrubber to redact personal data before it even hits your local disk.
# Enable PII redaction
export DRIFTBASE_SCRUB_PII=true

# Configure your custom enterprise rates for accurate cost deltas
export DRIFTBASE_RATE_PROMPT_1M=2.50
export DRIFTBASE_RATE_COMPLETION_1M=10.00

Driftbase Pro (Team Sync)

Local SQLite is perfect for individual feature branches. But when Engineer A and Engineer B need to compare baselines, or when you deploy to production, you need a shared source of truth.

To sync your local runs to a secure, EU-hosted centralized dashboard:

export DRIFTBASE_API_KEY="your_pro_key"
driftbase push

Learn more about Driftbase Pro


CLI Reference

Command Description
driftbase demo Inject synthetic runs to test the engine
driftbase diff <v1> <v2> Compare two versions (use --format md for CI/CD)
driftbase inspect <id> Deep-dive into a specific run's execution path
driftbase watch -a <v1> Live terminal dashboard monitoring incoming runs
driftbase runs -v <v1> List all local runs for a version
driftbase config View your current local configuration and DB path
driftbase push Sync local database to the Driftbase Pro cloud

License

Apache License 2.0. See LICENSE for details.

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

driftbase-0.2.4.tar.gz (70.8 kB view details)

Uploaded Source

Built Distribution

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

driftbase-0.2.4-py3-none-any.whl (77.3 kB view details)

Uploaded Python 3

File details

Details for the file driftbase-0.2.4.tar.gz.

File metadata

  • Download URL: driftbase-0.2.4.tar.gz
  • Upload date:
  • Size: 70.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for driftbase-0.2.4.tar.gz
Algorithm Hash digest
SHA256 40ee3131d41b99325a2235d3d5893097aac385b357f0b5b53f0823f9d0c10bb6
MD5 049fec5001259fb9c104b99119f04b5a
BLAKE2b-256 cbf15c8c99a711f31bc5ba9eebd7a58f71b8335ed7c73f1d20f33e7b79bbb74b

See more details on using hashes here.

File details

Details for the file driftbase-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: driftbase-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 77.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for driftbase-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 64ae1d3cb132d35d4612058339972b9f64a10d89df0c8fe81b1e2b7512244862
MD5 de74e30a0d98aa1f8c6a876f74071d62
BLAKE2b-256 c247854cd7ea05b854e7195c42ae80e11954ace141e3f28d810f8cf47f8c15dc

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