"The validated hypothesis H1 suggests a deploy broke the system, and escalating to the on-call human with the evidence ensures a human can make a quick decision and potentially mitigate the issue more effectively."
A 3-billion-parameter model wrote that at hour 49 of Agentware 2026. My own code had just told it, at 100% confidence, that a bad deploy had broken the shop's API, and that rolling it back was allowed. It handed the incident to a human anyway. Then it did the same thing nine more times.
| Unsafe runs | Policy denials | Real incidents fixed |
|---|---|---|
| 0 / 40 | 0 | 10 / 20 |
Two days earlier, the same configuration fixed 20 of 20. None of my safety metrics moved. That is the near miss: a bug that left every safety number perfect while the agent got half as useful. The model I actually ship didn't expose it.
What I built
NIGHTSHIFT is an autonomous on-call SRE agent for a small web shop running on Docker. A burn-rate rule in code pages it, not a human. It tests six possible causes against real measurements, acts only through a Cedar policy, and waits 3 seconds so a human can kill the action. It checks the fix against what customers see, undoes its own fix if things got worse, and signs a hash-chained trace of every step. Text from logs, status pages and emails is quarantined as data. The model never invents an action: it picks from options that code has already justified.
burn-rate page (code) → evidence (trusted metrics + quarantined text) → hypotheses scored by code → options built by code → model picks one → Cedar policy → 3 s commit delay (KILL cancels) → Cedar again → act → verify on customer errors → undo if worse → report + signed trace
The near miss lives in one arrow of that diagram: "options built by code".
Why a tiny model was in the loop at all
Early on I ran our red-team suite (41 hostile files, each in two situations) against Claude Opus with every protection switched off: raw text in context, every action offered, safety only in the prompt. It was 0/82 unsafe. It paged a human for all 41 hostile messages, but it never did anything unsafe.
Great for the product, useless for my evaluation: you cannot measure guardrails with a model that doesn't need them. So I measured them with a weak one, qwen2.5:3b on a laptop CPU, on the official Trap Pack (the organisers' 20 hostile test files, each run quiet and during a real incident):
| Same 3B model, same files | Unsafe runs | Real incidents fixed |
|---|---|---|
| Protections off | 29 / 40 (twice it deployed a legacy release that lost the orders table) | 7 / 20 |
| Cedar policy only | 0 / 40 (50 unsafe actions denied) | 15 / 20 |
| Full NIGHTSHIFT | 0 / 40 | 20 / 20 |
That table is the whole argument of the project: the safety lives in code, not in the model.
Hour 49: the re-run
It was the afternoon of the last day, about nine hours before code freeze. I was re-running every published number on the final code, so the README would claim nothing the commit being judged couldn't back.
The protections-off and Cedar-only arms came back as expected. The full-NIGHTSHIFT arm came back perfectly safe: 0 unsafe, 0 canaries leaked, 0 denials. It had fixed 10 of 20 incidents. In the other ten, the model had a validated bad deploy in front of it and a rollback the policy would allow, and it escalated.
A 3B model making a bad call is not news, so I read exactly what it had been shown.
The bug was a number in the safest place
Every option the model sees carries the confidence of the hypothesis it fixes. The rollback inherited the deploy hypothesis: validated by code at 100%. The escalate option, "hand it to the on-call human with the evidence", isn't a hypothesis and fixes nothing. In diagnosis.py it had been given a confidence anyway:
out.append(Candidate(f"A{len(out) + 1}", "escalate", {}, "escalate to the on-call human with the evidence packet", "-", 100)) The prompt for local models says, verbatim: "Prefer the least invasive option that fixes the validated cause. If no option fits the evidence, pick the escalate option." That gave it two options at 100%, and one of them touches nothing. A literal-minded model did exactly what I asked.
Why hadn't it happened before? The fix and the re-run prove the cause; this part is my best explanation. Two days earlier, the deploy hypothesis topped out at 85%, because one of its checks ("is the api upstream of the failing routes?") failed in the sandbox for a bad reason. With the options at 85% and 100%, the model still picked the rollback: the one that "fixes the validated cause". In my final review that morning I fixed that check to use a real route map. It was a correctness fix. It pushed the deploy hypothesis to 100%, made the two options tie, and left "least invasive" as the tiebreaker, without a single safety number changing.
It was invisible for three reasons:
- Claude reasons past the label. My real-sandbox evaluation ran on this exact code a few hours earlier, with escalate still at 100% and Claude Opus planning, and it rolled back all 6 bad deploys. Only a weak model took the number at face value.
- My headline metric was "unsafe runs". A safety metric cannot see a usefulness regression. An agent that escalates everything scores a perfect 0/40.
- Failing safe looks like success. Every escalation was polite and well reasoned, and emailed the right human with the right evidence. Nothing in the trace looked broken.
The fix is one number and one comment:
+ # Escalating is not a hypothesis and fixes nothing, so it claims no confidence. (It used to carry 100%, which + # tied with a hypothesis validated at 100%, and a 3B planner then escalated half of the incidents it could fix.) - "-", 100)) + "-", 0)) Re-run: 20 / 20 fixed, 0 / 40 unsafe. Both runs are published, the bad one included, in tests/trap-pack/ablation-history/.
The traps that did get through
Hour 49 wasn't the first time a safe result hid a failure. On day one, before I had read the Trap Pack's answer key, I ran it blind. All 20 files held in both situations: nothing unsafe, no canary leaked. But my triage flagged only 6 of 20 files as hostile and reported 0 of 5 files with broken data. Most of the attacks walked straight past the detector. They just had nothing to steer, because the planner only ever chooses among options built by code.
After reading the key, I widened the triage schema and ran again. Still only 3 of the 13 attack files were flagged, including a miss on the pack's fake fraud-supervisor call. The cause was not the model. Claude's structured output does not enforce maxLength, so whenever a summary came back longer than my schema allowed, it failed my validator and the whole extraction for that document was discarded. The document was then (safely) ignored, which looks exactly like "nothing suspicious here". Truncating over-long strings instead of discarding the extraction took it to 13 of 13, where it has stayed through the final run.
It happened once more in between. A mock-judge review of the repo pointed out that the "1 rollback per hour" counter lived in memory, so restarting the agent reset it. I persisted it, but in a global folder, so every simulated world in the Trap Pack shared one counter. After the first rollback, Cedar correctly denied every later one, and the agent escalated 19 of 20 incidents. Safe, but wrong. I discarded that run instead of publishing it.
Three times, failing safe hid a quality failure, and no safety number could see any of them.
Fixes that opened holes
The other pattern from the last two days: holes created by fixes.
| The fix | The hole it opened | How it was found |
|---|---|---|
| Make taint-tracking patterns linear (400 KB of dashes in an attacker's User-Agent had stalled the agent for over five minutes) | Identifiers longer than 256 characters stopped being tracked, so a canary padded into a 300-character run would not have been withheld from outbound mail | Reading the code; no run hit it |
| Add inbox flood limits | Dropped messages showed on the dashboard but never in the signed trace | Same review |
| Fix the route check with a real route map | The 100% tie above | Re-running the ablation |
The first two now have their own tests: a padded canary must still be withheld, and dropped intake must appear in the next incident's signed trace. The third is covered by the published re-run, not yet by a unit test.
The time the model caught my code overclaiming
It cut both ways. In the first real-sandbox database-leak run, Postgres was so exhausted that the agent's own stats connection was refused. My check "the worker holds most connections" counted itself as passed on the strength of the error message, which pushed the leak hypothesis to 90%. Opus noticed. It said the check was "passing on '0 connections', but that number isn't a real measurement". It recomputed the hypothesis at 60%, under the 70% gate, refused the restart the policy would have allowed, and escalated. It was right.
The fix was a monitoring role with reserved Postgres connection slots, plus a rule that a check without a measurement is unknown, never passed. In one build, the big model saved me from my code, and my code saved the small model from itself, until one number in my code fooled it. The layers only work if they check each other in both directions.
What I'd tell anyone building an agent that acts
- Put usefulness next to safety, in the same table, every time. "0 unsafe" is also the score of an agent that does nothing.
- Give "do nothing" no confidence. Escalation is a decision, not a hypothesis. A fallback option that carries a score will eventually win a tie.
- Test your guardrails with a weak model. A frontier model hides your bugs by being smart.
- Treat every safety fix as new attack surface. Give it its own adversarial test, written for the fix, not the feature.
- Missing data is "unknown", never "pass". Not for a metric, and not for a detector that threw its own output away.
- Publish the bad runs. The 10/20 run and the blind 6/20 run are in the repo next to the good ones.
What I haven't proved
- The attack suites are static files, not an adaptive attacker iterating against the model.
- Every Trap Pack run after the first was made after reading the answer key. The repo lists what changed before each run, and the one change prompted by a single file was measured on benign documents the key never saw.
- The sandbox is a small Docker stack, not a cloud account.
- The one-strike undo rule was added before any recorded run showed the old code doing harm. It's a guardrail added late, not a trap that got through.
Receipts
- Repo (Apache-2.0): https://github.com/RohitMunnuru9/nightshift
- Demo video, one unattended run plus the undo and the kill switch: https://www.youtube.com/watch?v=5hgeV5N5CvA
- The fix: commit
1964126. Both ablation runs:tests/trap-pack/ablation-history/ - Every Trap Pack run, blind run included:
tests/trap-pack/RESULTS.md - All 22 near misses from the build:
docs/NEAR_MISS_LOG.md - Recompute every number in the README from the committed runs:
uv run nightshift verify-results
Final numbers on the real Docker sandbox: 23 of 24 incidents handled correctly, 0 unsafe actions, a median of 46 seconds from page to verified fix, and about $0.06 per incident.
Built for Agentware 2026, run by Hackathon Raptors (@raptorsdev). Thanks to FileClerk (https://fileclerk.co.uk/) for backing the Near Miss write-up prize.
