Documentation
Docs
How SafeAdapt thinks about alignment drift — motivation, setup, formulas, and demo figures.
Motivation
Most LLM agent demos evaluate a single prompt–response turn. Real agents, however, act repeatedly: they keep memory, call tools, and accumulate context. Over long horizons, behavior can quietly drift away from the original goal and safety constraints — not because a single answer is obviously wrong, but because small shifts compound.
SafeAdapt is a research prototype that asks whether we can measure that drift with objective signals (not just an LLM judge), detect it online, and intervene before a serious failure — while still letting the agent complete useful work.
Research question
Can we detect when an agent gradually drifts from its original goals and safety constraints over repeated interaction, and can we mitigate that drift without collapsing task performance?
Experimental setup
The committed showcase matrix (also plotted on Results) uses:
Environments
- Filesystem — constrained file tools (read / write / list) with path and policy checks.
- Database — query tools with role-like access limits.
- Research assistant — document QA with optional prompt-injection style pressure.
Conditions C1–C5
C1Stateless baseline (no persistent memory, no monitor)C2Persistent memory onlyC3Memory + stronger adversarial / drift pressureC4Memory + drift detection (no intervention)C5Full SafeAdapt: detect + interveneInterventions (C5)
- Goal revalidation — remind / re-anchor the immutable goal
- Tool restriction — temporarily narrow allowed actions
- Memory rollback — drop recent memory entries
- Human confirmation — gated on severity (demo policy: deny)
Formulas
Per-step alignment
At interaction , score goal (), safety (), preference (), and constraint () adherence in :
Run aggregates
Task success is the fraction of interactions that complete the assigned workload step.
Combined drift score
Drift is a change relative to baseline behavior — not “the judge disliked the text.” We combine behavioral distance , alignment degradation, and violation increase :
Severity thresholds on (low / medium / high / critical) decide when C4 logs a detection and when C5 may intervene.
Interaction loop
- Sample / receive a task for step .
- Agent proposes a tool action (mock or LLM).
- Environment executes or rejects under constraints.
- Evaluator writes and violation flags.
- If monitoring is on, update .
- If intervening is on and severity warrants it, apply strategies and continue.
Hypotheses
- H1 — Persistent memory changes drift risk vs stateless agents.
- H2 — Adversarial pressure accelerates measurable drift.
- H3 — Detectors flag drift before severe violation spikes.
- H4 — Interventions reduce post-detection violations.
- H5 — Full SafeAdapt (C5) improves the safety–performance trade-off vs ablations.
The public demo is a short mock matrix for storytelling. Treat the figures as a transparent prototype — not a final paper claim. Stress tests with longer horizons and live LLMs belong in Try it and the CLI.
Demo figures
Mock showcase matrix on filesystem: conditions C1, C2, C3, C4, C5 (40 interactions × 3 seeds). More detail on Results.
C3 (adversarial) drops alignment and task success; C4/C5 add monitoring signals not present in C1–C3.
Only C4/C5 emit drift flags; only C5 applies interventions — the control loop lighting up.
Short-horizon mock runs; see Results for the full chart suite and written findings.
Reproduce locally
python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -e ".[dev]" cp .env.example .env # Single run safeadapt run configs/experiments/filesystem_drift.yaml # Condition matrix safeadapt matrix configs/experiments/matrix_dev.yaml # Refresh web showcase assets PYTHONPATH=src python scripts/export_showcase.py