Catching Skill Drift in Your AI Agent with a Baseline and a Simple Threshold Check
Catching Skill Drift in Your AI Agent with a Baseline and a Simple Threshold Check
An AI agent rarely breaks all at once. More often it gets a little worse each week: a support bot starts misreading a new product name, an order lookup tool slows down, or a routing classifier sends angry customers to the wrong queue. Nobody notices until users complain.
This article walks through one complete technique you can apply to any task-oriented agent: define its skills, capture a baseline, log every interaction in a consistent shape, and run a statistical comparison against thresholds that trigger alerts. You can build the core of it in an afternoon.
Why agents drift
Skill drift usually comes from one of three sources:
- Input drift. The distribution of user queries changes. New slang, new product lines, or a new user segment can push queries into areas the agent handles poorly.
- Model drift. If you use a hosted model, the provider may update it. If you fine-tune, your training distribution may no longer match production.
- Knowledge drift. Prompts, FAQ lists, and retrieval corpora go stale. A return policy changes, and the agent keeps quoting the old one with full confidence.
You cannot prevent all of these, but you can detect them early if you measure the right things.
Step 1: Define skills as measurable capabilities
A skill is a discrete task the agent performs, with a success metric you can compute from logs. Avoid vague goals like "be helpful." Instead, write something like this:
| Skill | What it does | Success metric | Target |
|---|---|---|---|
| FAQ answering | Answers common support questions | Answer judged correct | >= 95% |
| Order status lookup | Retrieves status from the database | Correct record returned | >= 99% |
| Sentiment routing | Sends negative messages to a human | Correct routing decision | >= 90% |
Each skill needs a metric that a script or a reviewer can score. For FAQ answers, that might be a labelled sample reviewed weekly. For order lookups, it can be checked automatically against the database.
Keep the list short, roughly five to ten skills. Assign each a priority so you know which alerts wake someone up and which go into a weekly report.
Step 2: Capture a baseline
Drift is a change relative to something, so record a snapshot while the agent is working well. Store it as a small, dated file:
# Baseline snapshot: 2024-10-01 skill: faq_answering total_queries: 12000 correct_responses: 11400 accuracy: 0.950 avg_latency_s: 0.8 skill: order_status_lookup total_queries: 3500 correct_responses: 3485 accuracy: 0.996 avg_latency_s: 0.9 Re-baseline deliberately, for example after a planned model change, and keep old snapshots so you can compare across versions.
Step 3: Log every interaction in one shape
Detection is only as good as your logs. Each interaction should produce one record with the same fields:
{ "timestamp": "2024-10-01T14:23:07Z", "session_id": "S987654", "skill": "faq_answering", "query": "What is your return policy?", "response": "You can return any item within 30 days of purchase.", "intent_confidence": 0.92, "latency_s": 0.7, "graded_correct": null, "feedback_rating": 5 } The graded_correct field is the important one. It starts as null and gets filled in by an automated check or a reviewer. Without it you can measure latency and volume, but not accuracy, and accuracy is usually the signal you care about.
Store records in whatever you already have: a CSV, a database table, or a log index. What matters is that you can query by skill and by time window.
Step 4: Compare current performance to the baseline
Once you have graded records for a recent window, you can compare the distribution of per-batch accuracy against the baseline. Splitting the graded log into daily batches gives you a sample of accuracy values to compare.
import pandas as pd from scipy.stats import ks_2samp baseline = pd.read_csv("baseline_faq_daily.csv") # column: accuracy current = pd.read_csv("current_faq_daily.csv") # column: accuracy ks_stat, p_value = ks_2samp(baseline["accuracy"], current["accuracy"]) print(f"KS statistic: {ks_stat:.3f}, p-value: {p_value:.3f}") if p_value < 0.05: print("Distribution shift detected in FAQ accuracy.") A few notes on using this well:
- Use at least 20 to 30 batches per side. With fewer samples, the test has little power and you will miss real drift.
- A significant result means the distribution changed, not that it got worse. Check the means before deciding it is a regression.
- Watch for multiple comparisons. If you test ten skills every day, some false alarms are expected. Tighten the threshold or require two consecutive days of signal.
Step 5: Add absolute thresholds
Statistical tests catch change; thresholds catch unacceptable levels. Keep both. A simple config file makes the targets explicit and reviewable:
# drift_thresholds.yml skills: - name: faq_answering min_accuracy: 0.90 - name: order_status_lookup min_accuracy: 0.98 - name: sentiment_routing min_accuracy: 0.85 import yaml with open("drift_thresholds.yml") as f: config = yaml.safe_load(f) for cfg in config["skills"]: current = get_recent_accuracy(cfg["name"], window_days=3) # your function if current < cfg["min_accuracy"]: print(f"ALERT: {cfg['name']} at {current:.1%}, below {cfg['min_accuracy']:.0%}") Set thresholds a little below the baseline, not at it. If a skill normally sits at 95%, a floor of 90% gives room for normal variation while still catching a real slide.
Step 6: Respond with a runbook, not improvisation
An alert is only useful if someone knows what to do. For each skill, write three short lines:
- Check inputs. Pull a sample of recent queries and see whether the topics have shifted.
- Check the knowledge source. Verify that the FAQ, policy text, or retrieval index is current.
- Check the model. Confirm whether the provider or your fine-tune changed recently, and compare against the last good snapshot.
Most drift turns out to be knowledge drift, which is the cheapest to fix.
Common mistakes
- Measuring only one metric. Accuracy can stay flat while latency doubles. Track at least accuracy, latency, and escalation rate.
- Grading only complaints. Users who complain are a biased sample. Grade a random slice each week.
- Changing the baseline too often. If you re-baseline every time the metric dips, you will never see slow drift.
- Skipping the logs schema. Free-form logs make grading and comparison painful. Fix the shape early.
A minimal starting point
If you do nothing else this week, do three things: write down your skills with a success metric each, start logging the JSON shape above with a graded_correct field, and run a weekly comparison of accuracy against a snapshot you took while the agent was working well. That combination catches most real drift well before users notice it.
The mechanics are simple. What takes discipline is keeping the baseline honest and grading a representative sample of interactions, and those habits are what make the numbers worth trusting.
The full AI Agent Skill Drift Prevention Guide is available at https://heracles-store.pages.dev/p/ai-agent-skill-drift-prevention-guide/ if you want a longer treatment of this topic.
Written with AI assistance and reviewed for accuracy before publishing.