My AI agents run on paid models through OpenRouter, with a local model on my own GPU as the safety net. A little script I call the canary checks every 3 hours that the paid model still works. If it doesn't, it moves the agents down to the local model so they keep running.

On 7 September 2026 it did exactly that. Then it sat there for 17 days saying everything was fine, while four of my agents ran on a slower local model for no reason at all.

Two bugs, stacked. One in the probe, one in the "come back" logic. Both are worth knowing about if you've built any kind of automatic failover.

How the canary works

Every 3 hours it does two things:

  • Checks the money. A model you can't pay for is still an outage. Below a floor it moves the agents to local and alerts. On a top-up it moves them back.
  • Checks the model. It sends a tiny tool-calling test: "What is the weather in Reykjavik? Use the tool." A healthy model calls get_weather with city set to Reykjavik. Anything else counts as a failure.

Transient stuff like a 429, a 5xx, a timeout or a DNS blip never counts. Only a "hard" failure does, like a wrong answer or a dead model id. And it needs 2 hard failures in a row before it does anything. Then it walks a ladder of other paid models from different vendors, and only if all of them fail does it drop to local.

I built the ladder vendor-diverse on purpose, because a fallback that fails the same way as the primary isn't a fallback. Keep that line in mind, it comes back.

7 September: everything fails at once

This is the canary's own log from that day. Nothing retyped, just the lines from the file, with my agent profile names swapped for placeholders:

The canary log: two hard failures where the model sees [ADDRESS] instead of a city, both ladder models fail, four profiles reverted to local, then "nothing to watch" every 3 hours until 24 September

Read the model replies. They're not broken. They're being sensible. The first one starts "It looks like you've left a placeholder".

Every model was seeing [ADDRESS] where my probe said Reykjavik. OpenRouter had PII redaction switched on for my account, and it decided a city name was personal data. So it swapped the city out before any model saw it.

The primary failed twice. Then the ladder: qwen/qwen3.7-flash called the tool with {'city': '[ADDRESS]'}, which is a fair attempt honestly, and google/gemini-2.5-flash-lite asked me which city I meant. Both "failed". So the canary concluded no OpenRouter model was usable and reverted four agent profiles to the local qwen3.5-64k.

That's the bit I keep coming back to. Three models from three different vendors all failed within a few seconds of each other, the same way. That isn't three models dying. That's my input being broken. Vendor diversity does nothing for you when the thing they all share is your probe.

The redaction caused other mess around the same time too. One of my ops agents built an SSH command with [IP_ADDRESS] where the IP should have been, because its own command got redacted. A brand name in a research task came back as [PERSON_NAME]. I turned PII redaction off on 15 September and checked that IPs, brand names, emails and phone numbers went through untouched after that.

Then 17 days of "nothing to watch"

Turning the redaction off should have fixed it. Next canary run, probe passes, agents move back. Except they didn't, and this is the second bug.

After the revert, every run logged this:

profiles are on local Ollama and no credit revert is pending -- nothing to watch 

The canary only had a "come back" path for one kind of revert: running low on credit. When it moved agents to local because the money ran low, it set a flag, and every run after that checked the balance and moved them back on a top-up.

A revert because the models failed set no flag at all. So on the next run the canary looked around, saw no OpenRouter primary configured, saw no credit revert pending, and decided there was nothing for it to do. It exited cleanly. Every 3 hours. It logged that line 134 times between 7 September 18:00 and 24 September 09:00.

And money was never the problem. On the day it reverted the log shows $7.81 of $10 left.

Nothing alerted on it either. The revert itself posted to Discord once, on 7 September. After that the canary was "healthy" by every measure I had: it ran on time, it exited 0, its log was full of tidy lines.

The fix, 24 September

Before and after: the old flow reverts and then logs nothing to watch forever, the new flow sets a flag and re-probes the paid ladder every run until a model passes

Small change, in the end. A failover revert now sets its own flag, reverted_for_failover, the same way a credit revert always did. Every run that finds a flag set probes the paid ladder again. The first model that passes gets the agents back, the flag is cleared, and Discord gets a "💚 OpenRouter back" message. If none pass, it stays local, logs "will retry" and tries again in 3 hours.

This is the actual check now, straight from the script:

if primary is None and (st.get("reverted_for_credit") or st.get("reverted_for_failover")): for model, ctx, pin, pout in PAID_LADDER: ok, kind, detail = probe(model, key) if ok: changed = switch_primary(model, ctx, "creditrestore") ... 

I set the flag by hand, ran it, and all four profiles went back to qwen/qwen3.7-flash at 14:31 that day. The 15:00 run logged probe: qwen/qwen3.7-flash ok. While I was in there I also gave every profile the same chain: qwen/qwen3.7-flash, then deepseek/deepseek-v4-flash-0731 as a paid fallback from a different vendor, then local, then a free model last. One profile had no paid fallback at all before that.

Same silence, different door

There's a comment in that script now about a related bug. The canary used to work out the current primary by reading one agent's config, the coding agent. When I moved that agent to a different provider, the function returned "no OpenRouter primary", and the main loop read that as "everything's local, nothing to watch". Silent off-switch, again, for every other agent. It reads the top-level config now, which always stays on OpenRouter.

Two different routes to the same line in the log. I think that line is the real bug. "Nothing to watch" should be something you can only reach on purpose.

What I'd do differently

  • If every vendor fails the same way at the same time, suspect your probe. There's no guard for this in the canary yet. The obvious one is: if the whole ladder fails with the same kind of error, alert loudly and don't revert.
  • Every automatic "go down" needs an automatic "come back". And they should share one flag, not one per reason. I had a return path for the failure I thought of first and none for the one that actually happened.
  • Probe with something boring. A city name looked harmless. Anything that a privacy filter, a content filter or a moderation layer could touch will one day get touched. A made-up token is a lot less likely to look like personal data than a real place name.
  • "Healthy and idle" needs to look different from "healthy and busy". A log line that says nothing is wrong every 3 hours for 17 days is just noise. If a monitor has nothing to monitor for more than a day, that should be a message.

Does your failover ever fail back on its own? I'd check. Mine only did for one of the two reasons it could leave.

🤖 Drafted with AI assistance from my own homelab notes, logs and repos, and fact-checked against them before publishing.