Skip to main content

Quickstart

1. Install

pip install driftguard-ai
python -m spacy download en_core_web_sm

2. Record a mistake

from driftguard import DriftGuard

guard = DriftGuard()

guard.record(
action="increase salt",
feedback="too salty",
outcome="dish ruined",
)

3. Review before acting

review = guard.before_step("add more salt")

if review.warnings:
print(review.warnings[0].risk)
# → "too salty"
print(review.confidence)
# → 0.82

DriftGuard matched "add more salt" semantically to "increase salt" and surfaced the stored warning.

4. Check graph stats

print(guard.stats())
# → {'nodes': 3, 'edges': 2}

5. Prune stale memories

guard.prune()

6. Run the MCP server

driftguard-mcp

What just happened

  • record() stored the causal chain action → feedback → outcome into the in-memory semantic graph and persisted it to disk.
  • before_step() embedded the query, retrieved similar action nodes, walked their causal chains, and returned ranked warnings.
  • The graph persists across restarts — DriftGuard remembers between sessions.

Next steps