You ship an autonomous agent. The dashboards are green. Throughput is stable. Everyone moves on.
Three weeks later, the outputs are subtly worse — narrower, more repetitive, slightly off — and nobody caught it, because nothing "broke." The agent never threw an error. It just drifted.
This is the most expensive failure mode in production agent ops, because it hides inside success.
The problem: drift has no alarm
Traditional monitoring watches for crashes, latency spikes, and error rates. None of those catch behavioral drift — when the agent is still "working" but has quietly collapsed its strategy space. A common early signal is tool diversity collapse: the agent stops reaching for the full range of tools it used to use, and falls into a narrow loop.
If you only measure "did it finish," you'll miss it until a human complains.
What I built: a drift detector
The core idea is cheap and works without any fancy infrastructure. Sample the agent's tool-call distribution over a rolling window, compare it to a baseline window, and flag when diversity drops below a threshold.
Here's a minimal version in Python:
from collections import Counter
import math
def shannon_entropy(call_counts: dict[str, int]) -> float:
total = sum(call_counts.values())
if total == 0:
return 0.0
return -sum(
(c / total) * math.log2(c / total)
for c in call_counts.values()
)
def drift_score(baseline: dict[str, int], current: dict[str, int]) -> float:
"""Returns 0.0 (no drift) to 1.0 (total collapse)."""
eb = shannon_entropy(baseline)
ec = shannon_entropy(current)
if eb == 0:
return 0.0
return max(0.0, (eb - ec) / eb)
# Example: agent used to spread calls across 6 tools
baseline = {"search": 40, "read": 30, "write": 20, "calc": 15, "http": 10, "shell": 5}
# Now it only does 2 things
current = {"search": 80, "read": 70, "write": 0, "calc": 0, "http": 0, "shell": 0}
print(f"drift: {drift_score(baseline, current):.2f}")
# -> drift: 0.55 (tool diversity collapsed by ~55%)
Run this on a schedule against your agent's recent call logs. When drift_score crosses ~0.3, page someone or auto-roll back the last prompt/version change. The whole thing is ~20 lines and needs no new dependencies.
Why a threshold beats a dashboard
A human glancing at a green "tasks completed" graph sees nothing wrong. An entropy delta doesn't lie about strategy narrowing. The moment you measure diversity of behavior instead of volume of output, drift becomes visible weeks earlier — while it's still cheap to fix.
Where to go next
Full catalog of my AI agent tools — drift detectors, accountability trackers, signal half-life monitors, and more — at https://thebookmaster.zo.space/bolt/market
Top comments (0)