Skip to main content

Drift//Monitor

Real-time behavioral drift detection for AI systems.

License: MIT Python 3.11+ Tests


The Problem

LLM outputs degrade over long sessions. Tone shifts. Goals wander. Instructions erode. Content diverges from source material. This happens silently -- no existing tool monitors for it in real time.

Drift//Monitor is the andon cord for language models. It sits as a transparent proxy between your application and the LLM API, measuring output deviation from an established baseline using embedding distance and statistical process control.

Quick Start

pip install driftmonitor
import anthropic
from driftmonitor import DriftAwareClient, SessionConfig

# Wrap your existing Anthropic client -- zero code changes needed
base = anthropic.Anthropic()
client = DriftAwareClient(base, config=SessionConfig(name="My Session"))

# Use exactly like the base client
response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
# Response passes through unchanged. Drift scores logged to SQLite.

# Check drift
print(client.latest_score)        # DriftScore(persona=5.2, goal=3.1, ...)
print(client.latest_severity)     # Severity.NOMINAL
print(client.composite_history)   # [2.1, 3.4, 5.2, ...]

How It Works

Three-Layer Architecture

Layer Function Technology
Capture Intercept every LLM input/output via proxy SDK Drop-in Python client wrapper
Score Embed + measure statistical deviation from anchor sentence-transformers, SPC control charts
Act Alert, correct, gate, and log drift events FastAPI, SQLite, React dashboard

Four Drift Axes

Axis Measures Example Signal
Persona / Tone Voice, formality, character consistency Technical writer starts editorializing
Goal Alignment Adherence to original objective Code agent starts refactoring instead of fixing
Instruction Follow Respect for earlier constraints Agent told not to delete files begins deleting
Semantic Fidelity Alignment with source material Summary contradicts source document

Severity Scale (SPC-based)

Level Threshold Response
NOMINAL < mean + 1σ Log only
LOW ≥ mean + 1σ Dashboard flag
ELEVATED ≥ mean + 2σ Operator notification, correction generated
CRITICAL ≥ mean + 3σ Andon cord -- gate or halt

Operational Modes

from driftmonitor import DriftAwareClient, SessionConfig

# OBSERVE -- log everything, no intervention (default)
client = DriftAwareClient(base, config=SessionConfig(mode="observe"))

# ALERT -- notify operator on threshold breach
client = DriftAwareClient(base, config=SessionConfig(mode="alert"))

# GATE -- hold response until operator approves
client = DriftAwareClient(base, config=SessionConfig(mode="gate"))
response = client.messages.create(...)
if client.is_gated:
    client.gate_approve(operator="admin", reason="Acceptable drift")
    # or: client.gate_reject(operator="admin", reason="Too much drift")

REST API

# Install server dependencies
pip install driftmonitor[server]

# Launch the API
driftmonitor serve --port 8000

# Or with a custom database
driftmonitor serve --db /path/to/drift.db

Endpoints

Method Path Description
GET /health Service status
GET /sessions List all sessions
GET /sessions/{id} Session details
DELETE /sessions/{id} Delete session
GET /sessions/{id}/events Drift events (filterable)
GET /sessions/{id}/latest Most recent event
GET /sessions/{id}/summary Aggregate statistics
GET /audit Audit log entries
GET /audit/export/json Export audit as JSON
GET /audit/export/csv Export audit as CSV
WS /ws/{session_id} Live score streaming

CLI

# List sessions
driftmonitor sessions --db drift.db

# View scores for a session
driftmonitor scores <session-id> --limit 20

# Session summary
driftmonitor summary <session-id>

# Launch API server
driftmonitor serve --port 8000

# Version
driftmonitor version

Audit Log

Every drift event, mode change, gate decision, and correction is recorded in an immutable audit log with timestamps and operator attribution.

# Export for compliance
audit_json = client.audit.export_json(session_id="sess-001")
audit_csv = client.audit.export_csv(session_id="sess-001")

# Query entries
entries = client.audit.get_entries(action="gate_released", limit=50)

Custom Anchor

By default, the first assistant response becomes the drift baseline. You can provide a reference document instead:

client.set_anchor("Your reference text or system prompt here.")

Architecture

Your App
    |
    v
DriftAwareClient  ───>  EmbeddingEngine  ───>  SPCEngine
    |                    (sentence-transformers)  (control limits)
    |                         |                       |
    v                         v                       v
Anthropic API            DriftStore              DriftExplainer
    |                    (SQLite WAL)            (Claude Haiku)
    v                         |                       |
Response                      v                       v
(unchanged)              Audit Log              Corrections

Competitive Landscape

Category Tools Gap
LLM Observability LangSmith, Helicone, Arize Log tokens and latency. No behavioral drift scoring.
AI Testing PromptFoo, Braintrust Snapshot evaluation. Not live longitudinal monitoring.
AI Guardrails Guardrails AI, NeMo Input/output filters. Not drift detection over time.
AI Governance Various No operator-controlled correction with audit trail.

Development

# Clone and install
git clone https://github.com/AreteDriver/drift-monitor.git
cd drift-monitor
python -m venv .venv && source .venv/bin/activate
pip install -e ".[server,dev]"

# Run tests
pytest tests/ -v

# Lint
ruff check src/ tests/
ruff format src/ tests/

License

MIT


Built by AreteDriver -- standard work for AI behavior.

Metadata

Release files for driftmonitor-ai 0.1.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 driftmonitor-ai 0.1.0
File Size Uploaded Provenance Actions
driftmonitor_ai-0.1.0.tar.gz 157.3 kB With provenance Details for driftmonitor_ai-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for driftmonitor-ai 0.1.0
File Interpreter ABI Platform Actions
driftmonitor_ai-0.1.0-py3-none-any.whl Python 3 none any Details for driftmonitor_ai-0.1.0-py3-none-any.whl

Total release size: 190.2 kB

Release files / driftmonitor_ai-0.1.0.tar.gz

Download URL driftmonitor_ai-0.1.0.tar.gz
Size 157.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3ec9ded517759d26a13874437c27d5641cfd5ef2d004b8e1a67fdcd476d9add3
BLAKE2b-256 checksum
How to use checksums
51aac23ab3a6cd3445fb13c220a0883f726d390498a98429bcae6836c08ac3d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Apr 4, 2026.

Transparency log

Release files / driftmonitor_ai-0.1.0-py3-none-any.whl

Download URL driftmonitor_ai-0.1.0-py3-none-any.whl
Size 32.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
72c19bdbe3fc9aecf8691f2dab29c4d72c14a2df631a476b8e928e65e21bce68
BLAKE2b-256 checksum
How to use checksums
c4f275b295ad7f096780392ce82f85ba112528c71d188593df5f33b0c3de0df5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Apr 4, 2026.

Transparency log

Security for driftmonitor-ai 0.1.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 driftmonitor_ai-0.1.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 Apr 4, 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.1.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