{"id":47733723,"url":"https://github.com/driftbase-labs/driftbase-python","last_synced_at":"2026-04-22T10:00:54.304Z","repository":{"id":342989294,"uuid":"1175852905","full_name":"driftbase-labs/driftbase-python","owner":"driftbase-labs","description":"Local-first behavioral drift monitoring for AI agents. One decorator, SQLite, no cloud.","archived":false,"fork":false,"pushed_at":"2026-04-15T13:13:41.000Z","size":798,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-15T15:13:39.294Z","etag":null,"topics":["ai-agents","behavioral-monitoring","drift-detection","local-first","observability","python","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/driftbase-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-08T09:09:07.000Z","updated_at":"2026-04-15T13:13:50.000Z","dependencies_parsed_at":"2026-04-22T10:00:33.320Z","dependency_job_id":null,"html_url":"https://github.com/driftbase-labs/driftbase-python","commit_stats":null,"previous_names":["driftbase-labs/driftbase-python"],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/driftbase-labs/driftbase-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftbase-labs%2Fdriftbase-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftbase-labs%2Fdriftbase-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftbase-labs%2Fdriftbase-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftbase-labs%2Fdriftbase-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/driftbase-labs","download_url":"https://codeload.github.com/driftbase-labs/driftbase-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftbase-labs%2Fdriftbase-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32130776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T08:34:57.708Z","status":"ssl_error","status_checked_at":"2026-04-22T08:34:55.583Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agents","behavioral-monitoring","drift-detection","local-first","observability","python","sqlite"],"created_at":"2026-04-02T22:06:01.029Z","updated_at":"2026-04-22T10:00:54.298Z","avatar_url":"https://github.com/driftbase-labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Driftbase\n\n**Behavioral drift detection for AI agents using your Langfuse traces.**\n\nAI agents drift. A prompt update, a model swap, a RAG reindex — any of these can shift how your agent makes decisions, without triggering a single test failure.\n\nDriftbase tells you **when** your agent changed, **what** caused it, and whether it got **better or worse** — by analyzing the traces you're already collecting in Langfuse.\n\n```bash\npip install driftbase\n```\n\nConnect your Langfuse instance:\n\n```bash\nexport LANGFUSE_PUBLIC_KEY=pk-lf-...\nexport LANGFUSE_SECRET_KEY=sk-lf-...\n\ndriftbase connect\n```\n\nThen, when something feels off:\n\n```bash\ndriftbase diagnose\n```\n\n```\nDRIFTBASE DIAGNOSTIC\n\n  Behavioral shift detected 11 days ago (2026-03-20)\n  Most likely cause: prompt change in release v2.1\n  Affected:          escalation rate 4% → 19%, latency +1.2s\n\n  Recommendation:    REVIEW before production deploy\n```\n\nNo agent code changes. No instrumentation. Just instant answers from your existing Langfuse data.\n\n[![PyPI version](https://badge.fury.io/py/driftbase.svg)](https://pypi.org/project/driftbase/)\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)\n\n---\n\n## How it works\n\nDriftbase is a **drift detection layer** on top of Langfuse. You already trace your agent with Langfuse — Driftbase reads those traces and detects behavioral drift.\n\n### 1. You're already tracing with Langfuse\n\nYour AI agent is instrumented with Langfuse (via LangChain, LangGraph, OpenAI, or any other framework). Traces flow into Langfuse automatically.\n\n### 2. Connect Driftbase to Langfuse\n\nDriftbase pulls historical traces from Langfuse and stores them locally for analysis:\n\n```bash\ndriftbase connect\n```\n\nThis imports your traces into a local SQLite database (`~/.driftbase/runs.db`). All analysis runs on your machine. No data leaves your environment.\n\n### 3. Detect drift\n\n**When something feels wrong:**\n```bash\ndriftbase diagnose\n```\n\nScans your full trace history, detects behavioral shifts, and correlates them with version changes.\n\n**Compare explicit versions:**\n```bash\ndriftbase diff v1.0 v2.0\n```\n\nProduces a statistical drift score and a deployment verdict (SHIP / MONITOR / REVIEW / BLOCK).\n\n**View behavioral history:**\n```bash\ndriftbase history\n```\n\nShows how your agent's behavior evolved over time — which epochs were stable, which shifted, and what changed at each breakpoint.\n\n---\n\n## Core Value Proposition\n\n| What You Get | Why It Matters |\n|--------------|----------------|\n| **60-second wow moment** | Run `driftbase demo --offline` to see drift detection on synthetic data with zero dependencies |\n| **Zero cold start** | Start detecting drift from day 1 using your existing Langfuse traces — no SDK to add, no baseline to collect |\n| **GitHub Action integration** | Automatic drift checks on every PR with rich, color-coded reports posted as comments |\n| **Self-calibrating drift scores** | Weights and thresholds learn from your labeled deployments — the more you use it, the better it gets |\n| **Root cause pinpointing** | Correlates drift with version changes and surfaces the most likely cause with confidence level |\n| **100% local-first** | All data stays on your machine in SQLite — no cloud required, GDPR-compliant by design |\n| **Framework-agnostic** | Works with any framework already traced in Langfuse or LangSmith — LangChain, OpenAI, CrewAI, custom agents |\n| **Progressive confidence** | Starts working with just 15 runs, full statistical power at 50+ runs per version |\n\n---\n\n## 60-Second Demo (No Dependencies)\n\nWant to see drift detection in action before connecting your own traces?\n\n```bash\npip install driftbase\ndriftbase demo --offline\n```\n\nThis generates synthetic agent runs showing realistic behavioral drift scenarios and walks you through the core commands. **100% offline, zero external dependencies.**\n\n---\n\n## The 5-Minute Quickstart\n\n### 1. Install\n\n```bash\npip install driftbase\n```\n\n### 2. Set Langfuse credentials\n\n```bash\nexport LANGFUSE_PUBLIC_KEY=pk-lf-...\nexport LANGFUSE_SECRET_KEY=sk-lf-...\nexport LANGFUSE_HOST=https://cloud.langfuse.com  # optional\n```\n\nGet your keys from [Langfuse Settings → API Keys](https://cloud.langfuse.com).\n\n### 3. Import traces\n\n```bash\n# Auto-detect and import\ndriftbase connect\n\n# Or specify project explicitly\ndriftbase connect langfuse --project my-agent --limit 1000\n```\n\n### 4. Detect drift\n\n```bash\n# Automatic drift detection\ndriftbase diagnose\n\n# Compare specific versions\ndriftbase diff v1.0 v2.0\n\n# View behavioral history\ndriftbase history\n```\n\n**That's it.** You're detecting drift in 5 minutes using traces you already have.\n\nSee [examples/langfuse-quickstart](examples/langfuse-quickstart/) for a complete walkthrough.\n\n---\n\n## What Driftbase analyzes\n\nDriftbase computes drift across **12 behavioral dimensions**:\n\n1. **Decision drift** — Changes in outcome distribution (resolved/escalated/error)\n2. **Tool sequence** — Pattern changes in tool usage order\n3. **Tool distribution** — Frequency changes in which tools are called\n4. **Latency** — p95 latency shifts\n5. **Error rate** — Proportion of failed runs\n6. **Retry rate** — How often the agent retries operations\n7. **Loop depth** — Changes in iterative reasoning patterns\n8. **Verbosity ratio** — Output length relative to input\n9. **Output length** — Total token count in responses\n10. **Time to first tool** — How quickly the agent starts using tools\n11. **Semantic drift** — Heuristic clustering of output semantics\n12. **Tool transitions** — Changes in tool-to-tool call patterns\n\nEach dimension is weighted based on your agent's inferred use case (e.g., customer support vs. code generation).\n\n---\n\n## CLI Commands\n\n### Core Commands\n\n```bash\n# Connect to Langfuse and import traces\ndriftbase connect\n\n# Detect drift automatically across all versions\ndriftbase diagnose\n\n# Compare two specific versions\ndriftbase diff v1.0 v2.0\n\n# View behavioral history over time\ndriftbase history\n\n# Interactive setup guide\ndriftbase init\n```\n\n### Advanced Commands\n\n```bash\n# Inspect individual runs\ndriftbase inspect \u003crun-id\u003e\n\n# Export drift report as JSON\ndriftbase export --format json --output report.json\n\n# Set up behavioral budgets\ndriftbase budgets set --dimension error_rate --threshold 0.05\n\n# Prune old runs to save space\ndriftbase prune --before 2026-01-01\n\n# Health check\ndriftbase doctor\n```\n\n---\n\n## Use Cases\n\n### 1. Pre-Deploy Drift Gate (GitHub Action)\n\nAdd `.github/workflows/drift-check.yml`:\n\n```yaml\nname: Drift Check\n\non:\n  pull_request:\n    branches: [main]\n\npermissions:\n  pull-requests: write\n  contents: read\n\njobs:\n  drift-check:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: Run Driftbase drift check\n        uses: driftbase-labs/driftbase-python/github-action@v1\n        with:\n          baseline-version: main\n          current-version: ${{ github.head_ref }}\n          fail-on-review: true\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n```\n\nPosts a color-coded drift report as a PR comment with verdict (SHIP/MONITOR/REVIEW/BLOCK) and dimension breakdown.\n\nSee [github-action/README.md](github-action/README.md) for full documentation.\n\n### 2. Post-Deploy Monitoring\n\n```bash\n#!/bin/bash\n# Daily drift check (cron: 0 9 * * *)\n\nexport LANGFUSE_PUBLIC_KEY=...\nexport LANGFUSE_SECRET_KEY=...\n\ndriftbase connect --since $(date -d '1 day ago' +%Y-%m-%d)\ndriftbase diagnose --alert-on-drift\n```\n\n### 3. Incident Response\n\nWhen users report unexpected agent behavior:\n\n```bash\n# Pull latest traces and diagnose\ndriftbase connect --since 2026-03-01\ndriftbase diagnose\n\n# Inspect specific problematic run\ndriftbase inspect \u003crun-id\u003e\n\n# Compare current vs. last known good\ndriftbase diff v2.0-stable v2.1-current\n```\n\n---\n\n## Configuration\n\nDriftbase works out of the box with zero configuration. Optional settings:\n\n```bash\n# Set custom DB path\nexport DRIFTBASE_DB_PATH=/path/to/runs.db\n\n# Set default Langfuse host\nexport LANGFUSE_HOST=https://your-instance.com\n\n# Configure cost tracking\nexport DRIFTBASE_RATE_PROMPT_1M=2.50\nexport DRIFTBASE_RATE_COMPLETION_1M=10.00\n\n# Reproducibility and sampling (Phase 1 correctness features)\nexport DRIFTBASE_SEED=42                    # Random seed for reproducible drift reports (default: 42)\nexport DRIFTBASE_FINGERPRINT_LIMIT=5000     # Max runs per fingerprint (default: 5000)\nexport DRIFTBASE_BOOTSTRAP_ITERS=500        # Bootstrap iterations for confidence intervals (default: 500)\n```\n\nSee [docs/configuration.md](docs/configuration.md) for advanced settings.\n\n---\n\n## Architecture\n\n```\n┌──────────────────────────────────────────────────────────────┐\n│  YOUR AI AGENT                                               │\n│  (instrumented with Langfuse via any framework)              │\n└────────────────┬─────────────────────────────────────────────┘\n                 │\n                 │ traces\n                 ▼\n┌──────────────────────────────────────────────────────────────┐\n│  LANGFUSE                                                    │\n│  (observability platform)                                    │\n└────────────────┬─────────────────────────────────────────────┘\n                 │\n                 │ driftbase connect\n                 ▼\n┌──────────────────────────────────────────────────────────────┐\n│  DRIFTBASE                                                   │\n│  ├─ Local SQLite DB (runs, fingerprints, epochs)            │\n│  ├─ Drift analysis engine (12 dimensions)                   │\n│  ├─ Baseline calibrator (auto-weights + thresholds)         │\n│  ├─ Anomaly detector (multivariate outliers)                │\n│  └─ Verdict engine (SHIP/MONITOR/REVIEW/BLOCK)              │\n└──────────────────────────────────────────────────────────────┘\n```\n\n**Key principle:** Driftbase is NOT a tracing tool. It's a drift detection layer that reads existing traces from Langfuse.\n\n---\n\n## Roadmap\n\n**Completed:**\n- [x] Langfuse connector with incremental sync\n- [x] LangSmith connector\n- [x] 12-dimension drift analysis\n- [x] Progressive weight learning from labeled deployments\n- [x] Statistical confidence tiers (TIER1/TIER2/TIER3)\n- [x] GitHub Action with standalone + cloud modes\n- [x] MCP server for Claude Desktop integration\n- [x] 60-second offline demo\n\n**Deferred (requires Cloud API):**\n- [ ] Privacy-first telemetry\n- [ ] Opt-in data contribution for moat building\n\n**Future:**\n- [ ] Arize connector\n- [ ] Generic OTEL ingestion\n- [ ] Slack/PagerDuty alerting\n- [ ] Web dashboard (Cloud tier)\n\n---\n\n## Development\n\n```bash\n# Clone repo\ngit clone https://github.com/driftbase-labs/driftbase-python\ncd driftbase-python\n\n# Install in editable mode with dev dependencies\npip install -e '.[dev]'\n\n# Run tests\npytest tests/\n\n# Run linter\nruff check .\nruff format .\n```\n\n---\n\n## FAQ\n\n### Do I need to change my agent code?\n\nNo. Driftbase reads existing Langfuse traces. Your agent continues using Langfuse exactly as before.\n\n### Where is my data stored?\n\nAll analysis runs locally. Traces are stored in `~/.driftbase/runs.db` (SQLite). Nothing leaves your machine unless you explicitly push to a remote backend (Pro tier feature).\n\n### What if I don't have Langfuse yet?\n\nSet up Langfuse first: [langfuse.com/docs/get-started](https://langfuse.com/docs/get-started). It takes ~10 minutes to instrument your agent with Langfuse, then you can use Driftbase.\n\n### What if I don't have historical traces?\n\nUse `driftbase testset generate` to create synthetic baseline data, or start collecting traces now and compare future versions.\n\n### How often should I sync?\n\n- **Development**: After every agent change\n- **Production**: Daily or on-deploy via CI/CD\n\n### Does this work with LangSmith?\n\nYes! Driftbase supports both **Langfuse and LangSmith**. Use:\n\n```bash\ndriftbase connect langsmith --project my-agent\n```\n\nArize and generic OTEL support are planned for future releases.\n\n### Is this free?\n\nYes. The OSS SDK is free forever. We'll offer a Pro tier (hosted web dashboard, real-time alerting, team features) in the future, but the local CLI will always be free.\n\n---\n\n## Support\n\n- **Docs**: [driftbase.io/docs](https://driftbase.io/docs)\n- **Issues**: [github.com/driftbase-labs/driftbase-python/issues](https://github.com/driftbase-labs/driftbase-python/issues)\n- **Discord**: [driftbase.io/discord](https://driftbase.io/discord)\n- **Email**: info@driftbase.io\n\n---\n\n## License\n\nApache 2.0. See [LICENSE](LICENSE).\n\n---\n\nBuilt with ❤️ for AI engineers who want to ship with confidence.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdriftbase-labs%2Fdriftbase-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdriftbase-labs%2Fdriftbase-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdriftbase-labs%2Fdriftbase-python/lists"}