Chapter 19. Shadow Evaluation and Canary Deployment
Passing offline gates tells a team that a candidate met its criteria on the cases tested, not how it will behave on current traffic. Shadow evaluation offers a way to inspect that behavior without giving the candidate control over consequential actions. A bounded canary can then expose eligible users once the candidate is ready for that additional risk.
19.1 Shadow traffic
Shadow evaluation asks what the candidate would do on current inputs without allowing it to control the response or change consequential state. The candidate sees eligible live inputs or privacy-reviewed copies, allowing the team to compare its outputs, planned tool actions, latency, cost, and evaluator signals with the incumbent. For stateful agents, block writes or use an isolated replica. A shadow run that can mutate production is not safe.
Shadow traffic shows how a candidate behaves on current inputs. The incumbent response is not ground truth: users may act differently because of what they saw, leaving the candidate’s counterfactual outcome unobserved. Review disagreements against adjudicated evidence, track which requests were eligible and captured, protect sensitive content, and do not treat shadow agreement as proof of correctness or causal benefit.
19.2 Canaries
A canary sends a small, bounded share of eligible traffic to a candidate while a known-good control remains available. Its first purpose is to limit exposure while the team checks operational behavior, not to promise a causal estimate. Before launch, specify the exposure unit, duration, minimum evidence, stop conditions, and owner; during the rollout, monitor guardrails and keep rollback ready. A canary is not automatically a powered experiment.
19.3 Walk through a bounded synthetic rollout
Run python code\workflow\lab_workflow.py from the repository root. The shadow stage applies the same candidate and synthetic cases used offline to fresh in-memory state. It records eligible and captured counts and flags unauthorized proposed actions. No production service or tool is connected: the reported production_writes: 0 describes this isolated fixture, not a proof that a real shadow deployment blocks writes. Set refund_without_authority=True in the candidate configuration and verify that the shadow report flags the unsafe plan.
The canary example supplies 200 eligible users, 20 exposed users, a minimum of 30 exposures for routine review, and one observed safety event. It returns stop_and_rollback immediately, before the minimum is reached. Without an event or operational alert, fewer than 30 exposures yields continue; at least 30 yields review, not automatic expansion. The function validates counts but does not route traffic, enforce an exposure cap, detect events, perform rollback, check release identities, or estimate causal effects.
Before adapting this exercise, define the eligible population and denominator, privacy-reviewed inputs, bounded routing and permissions, state isolation, monitoring, stop thresholds, fallback, rollback owner and evidence retention. Exercise the stop path under failure, and mitigate serious incidents immediately rather than waiting for the next evaluation cycle.
Exercises
- Make the candidate propose an unauthorized refund in shadow and explain why the simulated detection does not prove a real deployment prevents writes.
- Compare the canary decision with one safety event against the decision with no events and the same exposure count. What other operational alert would require an immediate stop?