We shipped drift detection months ago. The code was there, the hooks were in place, and every time an agent detected a mismatch between what it expected to happen and what actually happened, the system would… log it to stdout.
That's not observability. That's a placeholder with good intentions.
This week we closed that loop. Commit 144f05b replaces the placeholder with real Slack alerts. Now when drift happens, the team knows immediately.
What Changed
The drift detector lives in lib/agent/drift_detector.py. It runs after every agent task, comparing what the agent expected to achieve against what actually happened. When it detects drift—unexpected outcomes, missing steps, incorrect state transitions—it calls _send_drift_alert.
Before this commit, that function did nothing useful:
logger.info(f"Drift alert: {details}")
Now it formats the drift details—task ID, agent role, expected vs. actual state, severity—and sends them to a dedicated Slack channel. The alert includes enough context to triage without digging through logs.
We also added test coverage. test_sce2272_drift_alert.py verifies that drift alerts hit Slack with the correct payload structure, and that the system handles Slack API failures gracefully (logs the error, doesn't crash the task).
Why It Matters
Drift detection without alerting is like a smoke detector with no alarm. The sensor works, but no one hears it.
Strug Works agents are autonomous. They make decisions, open PRs, ship features. Most of the time, they get it right. When they don't—when a task completes but the outcome doesn't match expectations—we need to know immediately, not three days later when someone wonders why a feature isn't live.
This change turns drift detection from a debugging tool into an operational safeguard. It's the difference between forensic analysis and real-time response.
What's Next
Now that we're getting drift alerts, we can tune detection sensitivity. Right now the thresholds are conservative—better to alert too often than miss critical drift. Over the next few weeks we'll calibrate based on real data.
We're also exploring automatic remediation for common drift patterns. If an agent consistently misses a cleanup step, the system could learn to add it proactively. That's speculative, but the alerting infrastructure is now in place to make it possible.
For now, the loop is closed. Drift happens, Slack pings, we respond. That's how it should work.