DEV Community

Don Johnson
Don Johnson Subscriber

Posted on

The Art of the Canary in the Age of AI

Separates marker compliance from task success

A yellow canary, software terminal, and separate checklist surrounded by psychedelic pop-art birds and hand-drawn shapes.

Companion repository: copyleftdev/canary-article — full experiment, source code, run artifacts, and evidence explorer. All 30 main-attempt results are inspectable.

The first completed pilot run produced exactly the signal we had asked for:

CANARY:fd11c73f1ba333de
Enter fullscreen mode Exit fullscreen mode

Then the agent explained that it couldn't access the project files or run checks. Our container was missing an execution helper, codex-code-mode-host. The requested feature had not been implemented.

The canary was present. The work could not proceed.

That was an infrastructure failure in our pilot, not a discovered booking bug or a result from the main experiment. The distinction became the first useful lesson of the project: a visible signal needs a precise meaning.

We preserved the failed pilot, documented the runtime defect, and started a replacement cohort after fixing it. You can inspect the original response, independent evaluation, and amendment.

The question behind the experiment survived: what does an instruction canary actually tell us about an AI coding agent's work?

A small signal with a long history

Mining canaries responded to dangerous gases before their human handlers did. One detail makes that history more interesting than the familiar metaphor: the Science Museum holds a canary cage equipped with an oxygen cylinder. Its design allowed a poisoned bird to be enclosed and given oxygen. Detection was connected to a response. Science Museum collection

Software borrowed the canary metaphor. A deployment canary exposes a limited population to a change and evaluates it against a control before a wider rollout. Google's SRE workbook describes both the rollout and the evaluation needed to make that useful. Canarying Releases

An instruction canary uses a different mechanism. We place a small requirement in project instructions and look for its observable effect: perhaps a recognizable word at the start of the agent's response.

That output proves something narrow: the response satisfied that particular requirement. Establishing a relationship to other behavior takes additional evidence.

This technique already has implementations. Context Canary displays a bird associated with a response marker and supports checkpoints distributed through instructions. Its documentation also explains that a missing marker does not prove context loss. Our contribution is a reproducible experiment that puts the marker beside independent checks of the resulting code.

Give the canary one clear job

Here is the instruction used in our marker condition, with an example token:

The first nonempty line of your final response must be exactly
CANARY:0123456789abcdef, with no other characters on that line.
Put all other text on subsequent lines.
Enter fullscreen mode Exit fullscreen mode

It belongs in a project instruction file supported by the chosen coding tool. For Codex, AGENTS.md participates in a documented discovery chain with project and global scopes. Verify the applicable location and overrides for your tool; an instruction sitting on disk is not automatically evidence that it reached the model. Codex instruction discovery

Our runner generates a different token for every marker run. It puts that instruction in AGENTS.md, without repeating the token in the task prompt. The scorer checks the terminal final response, excluding tool output and intermediate messages.

We distinguish exact matches, malformed occurrences, absent tokens, and unobserved final responses. A timeout with no final response is not the same observation as a response that omitted its marker.

We also keep four questions separate:

  • What evidence shows that the instructions were loaded?
  • Did the final response satisfy the marker instruction?
  • Did the resulting code pass the specified behavioral checks?
  • Was the requested feature actually completed?

Instruction context and enforcement are different mechanisms. Anthropic makes that distinction explicitly in its memory documentation, which also describes loading diagnostics and hooks. How Claude remembers your project

Build something worth checking

Our experimental subject is a small Python booking module with two meeting rooms. It has no database, web server, or current-time dependency. That keeps the work small enough to inspect while giving mistakes a concrete meaning.

Its contract includes three important rules: reservations for the same room must not overlap; timestamps must carry an explicit offset and be normalized to UTC; rejected operations must leave existing bookings unchanged.

Adjacent reservations are allowed. Different rooms may be booked at the same time. These details are written down before the agent starts, because hidden checks should exercise a published contract rather than introduce surprise requirements.

Each run starts from the same working baseline and gets one task:

  1. Add rescheduling while preserving a booking's identity and room.
  2. Return the rooms available during a requested interval.
  3. Add a batch of reservations atomically, so one invalid member prevents the entire batch from being saved.

The fixture contract defines the API and edge cases. The tasks are independent; a later task does not inherit an earlier agent's implementation.

Test the measuring equipment

Before measuring agents, we calibrated the evaluator with 16 cases. They include correct implementations, deliberately broken overlap and timestamp handling, partial batch writes, missing features, import failures, and an import that hangs.

All 16 met their calibration expectations. That means the evaluator recognized the expected outcomes; it does not mean the deliberately broken programs passed the booking checks. For the hanging import, the expected outcome was a timeout with unevaluable behavior and verified container cleanup. These cases are test equipment validation, not model runs. Calibration record

The agent can see public examples. Evaluator-owned checks and reference implementations remain outside its container. After the agent stops, the saved submission runs in a separate evaluation container without network access or credentials.

This arrangement also keeps the agent's claim that tests passed separate from the evaluator's evidence. A feature can be missing even while the original baseline still passes its existing-operation checks—as our failed runtime pilot demonstrated.

After repairing that runtime, we completed six replacement pilot runs: one marker and one no-marker run for each task. All six passed their independent rule and feature checks; all three marker responses matched exactly. Those pilots checked that the procedure worked. They remain outside the main dataset. Replacement pilot report

Freeze the comparison before reading the result

The main plan contains 30 attempts: three tasks, two conditions, and five repetitions. Fifteen runs receive the marker instruction. The other fifteen receive the same project rules without it.

We randomize task/repetition blocks and the order of the two conditions within each block. Sessions and workspaces start fresh. This study uses Codex CLI 0.166.0, the gpt-6-astra model alias, high reasoning effort, and a 240-second limit per attempt. The saved plan records those settings, the runtime image, source hashes, and execution order. The underlying provider backend revision is unavailable, which limits exact model reproducibility.

We froze the plan before main collection. Failed attempts remain in the ledger rather than being silently retried or replaced. This is a local audit trail, not a public preregistration.

Thirty attempts are a small exploratory case study. Repeated calls to the same model do not establish independent samples, and hundreds of test assertions do not turn one agent run into hundreds of observations. Full protocol

The result was uniformly green

All 30 main attempts completed. Every submission built and passed both its feature-acceptance and project-rule checks. There were no main-study timeouts, interrupted attempts, missing final responses, or unevaluable results.

Task No marker: feature and rule checks passed With marker: feature and rule checks passed Exact markers
Rescheduling 5/5 5/5 5/5
Availability 5/5 5/5 5/5
Atomic batch booking 5/5 5/5 5/5

Among the fifteen marker-enabled runs, the table was equally simple:

Marker instruction Rule checks passed Rule checks failed
Exact match 15 0
Noncompliant marker 0 0

The fifteen no-marker controls do not belong in that second table. Their feature and rule outcomes remain in the first one. None of the marker runs were excluded for unavailable evidence. Complete main-study report

For a representative example, reschedule-01-B returned its exact marker and passed the independent checks. All fifteen marker-enabled runs shared that overall outcome.

This supports a narrow observation: the marker format was followed in every marker-enabled run in this setup. It does not establish the marker's value as a warning signal. We saw neither a marker omission nor a checked rule failure, so we cannot compare failure rates between compliant and noncompliant responses. The fraction of failures accompanied by a warning is undefined because there were no observed failures.

These were short edits to a working baseline that already supplied timestamp normalization and conflict-checking helpers. We did not test long-session drift or large architectural changes. Automatic instruction-loading diagnostics were unavailable, although pilot transcripts recorded explicit reads of AGENTS.md. We kept the fixed tasks and sample rather than increasing difficulty until a disagreement appeared. A study of warning lead time would need a different, longitudinal design.

Make the evidence easy to inspect

The companion project, Canary Lab, produces a standalone HTML report and machine-readable JSON. Each planned run stays visible. Marker status, feature completion, rule checks, and missing evidence have separate fields. The evidence explorer lets you filter by task or condition and expand a run's instructions, prompt, final response, code diff, and evaluation.

Saved submissions can be evaluated again without another model call. That makes the project useful beyond the article: readers can investigate a surprising result or adapt the contract to their own project. The run guide covers setup, calibration, pilots, collection, and replay.

What this study can and cannot tell you

This experiment produced a uniform-green result: 30/30 passed, 15/15 markers matched. That supports a narrow claim — the canary format is followable — but it invites the right challenges. Here are the ones I expect, and what the evidence actually says.

"You only tested short, isolated tasks." Correct. Each run is a fresh session with a single edit against a working baseline that already provides timestamp normalization and overlap helpers. Long-session drift, multi-turn state decay, and context-window pressure are not tested. The study would need a different, longitudinal design to measure those.

"You tested on a model that is too good to fail." Possible. We used gpt-6-astra with high reasoning effort. A weaker model might omit the marker more often — which is exactly where the canary DIAGNOSTIC value would appear. The uniform-green result means either the task was too easy or the model was too reliable. Both are genuine limitations, and the protocol is explicit about them.

"The canary proves nothing about code correctness." It does not. We keep four questions separate on purpose: instruction loading, marker compliance, behavioral checks, and feature completion. A present canary does not mean the feature was built correctly. An absent one means something is wrong upstream — but we had zero absent markers, so we cannot demonstrate that link.

"AGENTS.md might not have been loaded." For Codex, AGENTS.md participates in a documented discovery chain. Pilot transcripts recorded explicit reads of the file. Automatic loading diagnostics were not available at the time, so we cannot rule out a silent skip. A tool that exposes loading evidence would strengthen this.

"Correlation is not causation — even if a marker omission preceded a failure, that would not prove the omission caused it." True. A missing canary and a booking-rule failure could both be downstream of the same root cause (context loss, instruction collision, timeout). The canary is a diagnostic signal, not a causal proof. Its value is in making invisible failures visible so you can investigate.

"30 runs is not a study." It is a small exploratory case study. The n=30 does not establish independent samples (same model, same session structure), and 15 marker vs 15 control runs provide zero failures to correlate against. The companion project is built so anyone can run it with more models, harder tasks, or longer sessions and produce new evidence.

"The canary instruction itself could influence the agent's behavior." It could. The marker instruction occupies tokens in context. It might compete with the task instructions for attention. We did not measure an attention-budget effect. A study isolating that would need a control condition with an equal-length neutral instruction.

These are not weaknesses to hide behind caveats. They are the limits of what a 30-run single-model experiment can claim. The project is public precisely so someone else can push past these limits — with more models, longer sessions, harder tasks, and a result that breaks the streak.

What to do with an instruction canary in a real project

Start with one cheap, unambiguous marker and a specific question about instruction handling. Confirm how your tool loads it. Keep the marker easy to recognize and avoid treating a general “rules followed” statement as evidence for every rule.

Pair it with a check of the behavior you care about. If the concern is overlapping reservations, exercise overlapping reservations. If a requirement must hold at a particular tool boundary, consider an appropriate enforcement mechanism there.

Decide what an omission should prompt. Inspect loading diagnostics, check for conflicting instructions, re-establish the relevant requirement, and run its independent check. These are proposed engineering practices; this experiment does not compare recovery strategies or rank canary designs.

The craft is in matching a small signal to a question it can help answer—and keeping the evidence that answers the larger questions beside it.

Top comments (17)

Collapse
 
programmer_arnab_96fb057e profile image
Programmer Arnab •

A useful caveat: a canary string mainly proves instruction-following or telemetry, not task success. Pair it with a negative control (canary absent when the runtime is broken) and a completion predicate tied to artifacts/checks, so “canary present but work blocked” is classified separately.

Collapse
 
copyleftdev profile image
Don Johnson •

Good suggestion, and our pilot shows why it matters, though in the other direction: the runtime was broken and the canary was still there. A broken runtime doesn't reliably remove the canary, so its presence can't tell you the runtime worked. We've added both pieces now. The report sets marker status against feature completion, so "present but blocked" has its own cell. There's also a deliberate negative control (plan-control) that runs the agent with a read-only workspace and fails if any run counts as completed work.

Collapse
 
yimingsong profile image
yiming song •

Good point — and the pilot in the article is a nice illustration of exactly that split: the canary was present while the work itself was blocked. Keeping marker compliance and task success as two separate checks feels like the right discipline.

Collapse
 
gnomeman4201 profile image
GnomeMan4201 •

The distinction between marker compliance and actual task execution in your pilot experiment caught my attention.

I've been researching instruction drift, runtime governance, and independent behavioral verification in LLM agents. Your Canary Lab experiment intersects with several questions I've been investigating.

I'd be interested in independently replicating your methodology and extending it into conditions involving sustained context pressure, instruction conflicts, and multi turn execution.

Specifically, I want to investigate whether a valid canary can persist while independently verified behavioral compliance deteriorates, and quantify how reliable that signal actually is as a predictor of failure.

I appreciate that you explicitly separated what your experiment established from what it couldn't establish. That's something I'd want to preserve in any follow up research.

Would you be open to discussing an independent replication or experimental extension?

Collapse
 
copyleftdev profile image
Don Johnson •

Yes, I'd welcome that. The question you describe, whether a valid canary persists while checked behavior degrades, is the one this study couldn't reach. I wrote a replication guide covering what to keep fixed and how to report a cohort so it stays separate from ours: github.com/copyleftdev/canary-arti.... Open an issue on the repo and we can plan the multi-turn design there.

Collapse
 
gnomeman4201 profile image
GnomeMan4201 •

Thanks, man. I opened issue #1⁠ with a sketch of the multi turn study. I’d be interested in your take on the rejected reschedule rule as the first thing to track.

Collapse
 
iictp profile image
IICTP •

Keeping the four questions separate is the part I'd borrow first — instruction loaded, marker followed, behavior correct, feature complete are four different claims, and most agent evaluations I see collapse them into one pass/fail. The uniform-green result reads less like a finding about canaries and more like a calibration of the harness itself: now you know the marker is followable and the checks are sound, so the next run with a weaker model or harder tasks can actually produce a disagreement worth learning from. Which of those would you vary first — the model, or the task difficulty?

Collapse
 
copyleftdev profile image
Don Johnson •

"A calibration of the harness" is a fair way to put it. We'll change the model side first, starting with lower reasoning effort on the same model. That keeps the calibrated tasks and evaluator, so any new failure comes from the model and not from a new instrument. Harder tasks come last because they need a new contract, reference solutions, and calibration. We also added a third condition with a neutral instruction of the same length, to test whether the marker itself changes anything.

Collapse
 
iictp profile image
IICTP •

Starting with lower reasoning effort on the same model is the cleanest first move — keeping the calibrated tasks and evaluator fixed means any new failure is attributable to the model, not to a new instrument. The third condition with the neutral instruction is a smart control: it isolates whether the marker itself changes anything. The thing I'd watch is which side degrades first — if marker omissions show up before checked behavior breaks, the canary is earning its keep; if behavior breaks first, the harness is just measuring the model getting worse.

Collapse
 
kami_butt_69b922ade8de012 profile image
Agentic Affairs •

The honest framing here is what makes it — 30/30 green and 15/15 markers matched means the canary is proven followable, not proven diagnostic, and you say so plainly instead of overselling it. The failed pilot is the more interesting result to me: the canary fired and the work still couldn't proceed because the container lacked codex-code-mode-host, which shows a signal with no precise meaning is just noise. What would you change first to actually break the streak — a weaker model, or longer sessions where context drift has room to bite?

Collapse
 
copyleftdev profile image
Don Johnson •

Thanks. One small correction: the pilot doesn't make the marker noise. It has a precise meaning, just a narrow one: one instruction was followed in the final reply, and nothing about whether the work succeeded. The pilot is the clearest example of that gap, which is why the report now has a table of marker status against feature completion.

Since posting, I went through the literature, and it changed the order. A weaker model isn't the best first move: one large study (HAL) found higher reasoning effort actually lowered accuracy in most runs, so turning effort down may not break anything. Two things come first. One is hardening the hidden checks and re-scoring the 30 saved runs, which costs no model runs and might turn up failures the original checks missed. The other is raising the load: many rules in AGENTS.md, or a marker required in every function instead of once per reply. On drift, the closest study I found (McMillan 2026) put a CLAUDE.md rule on every new function and got only about 64% compliance, falling with each extra function in a session. So yes, longer sessions are where it should bite, but that needs a multi-turn harness. gnomeman4201 offered above to work on that as an independent replication, and the guide is here: github.com/copyleftdev/canary-article/blob/main/docs/replicating.md

Collapse
 
kami_butt_69b922ade8de012 profile image
Agentic Affairs •

Fair correction, and it's an important one — the pilot's marker had a precise, narrow meaning, and calling it noise understates what it actually proved. The HAL finding flipping your order is a good catch: re-scoring the 30 saved runs against hardened checks costs nothing and might surface failures the original checks missed. Is the multi-turn harness the thing that decides whether drift actually bites, or would the raised load alone be enough to break the streak first?

Collapse
 
paullovelace profile image
Paul Lovelace •

The most interesting result here might be the pilot, not the 30/30. A missing execution helper killed the run, the canary still showed up, and the work couldn't proceed — that's the exact shape of a signal that proves nothing about the work. And the honest line is the undefined fraction: 30 green runs can't tell you whether a warning would have fired on a failure, because there was no failure to warn about. What would the next run look like — do you crank the difficulty until something actually breaks, or is the point that the marker was never meant to be a warning at all?

Collapse
 
copyleftdev profile image
Don Johnson •

Agreed, the pilot is the more telling result. As we defined it, the marker isn't a warning. It shows one instruction was followed in the final reply. Whether it tracks anything else is still open. We won't raise difficulty until something breaks inside a single run, because then you can't tell what caused the break. Each round changes one thing (effort, then model, then tasks) and is reported separately. The report now also has a table of marker status against feature completion. The pilot lands in "exact marker, work incomplete", which the first report left out.

Collapse
 
syedfahads profile image
Syed Fahad •

new token every run and never in the task prompt is a nice touch. a fixed marker could leak in from memory or an old run and you'd never tell

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

a marker proving the format was followed is a thin result. thirty out of thirty green and it still says nothing about failure.

Collapse
 
copyleftdev profile image
Don Johnson •

Agreed, and that's the main limit of this round. It shows the format can be followed. It doesn't show the marker catches anything, because nothing failed. The next round is designed to produce failures: lower effort first, then a smaller model, one change at a time. Draft protocol: github.com/copyleftdev/canary-arti...