Trace · Concept
Canary baselines
A canary baseline is a learned distribution of one family's readings for an agent or account on one model, that lets you trip on what is unusual for that agent instead of on one fixed threshold.
When to use it
Use a baseline when a fixed threshold doesn't fit every agent. A fraud-review agent reads deception all day, while a support agent never should; a baseline per agent lets each trip on its own outliers.
How it works
- You start learning a baseline for a model, optionally for one agent.
- Every traced inference and sidecar reading in its scope updates a running mean, variance and a 100-bin histogram per family. Readings that already tripped are left out and counted in
excluded, so an attack during learning doesn't become normal. - When
nreachesmin_samples, the baseline isreadyand frozen. A policy or a Trace rule then compares each new reading with it as a z-score or a percentile.
- Readingstraced inferences, sidecar
- Baselinemean, sigma, histogram
- Relative checkz-score or percentile
Key fields
scopestringagentfor one registered agent, oraccountfor every reading on the account.statusstringlearning,ready,stale(the agent moved to another model, or the baseline is over 30 days old), orsupersededby a newer version.ninteger- Readings learned so far. The baseline is ready at
min_samples(default 200). meannumber- Mean reading.
sigmanumber- Sample standard deviation. Relative scores use at least
sigma_floor(0.01), so a very steady agent doesn't trip on noise. histograminteger[]- Reading counts in 100 bins over 0 to 1, used for percentiles.
For a reading score, the z-score is (score − mean) / max(sigma, 0.01). The percentile is the share of readings below the score's bin plus half of those in it.
Start learning
Create a baseline with POST /. Leave out agent_id for an account-wide baseline, and families for every family on the model.
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s $PROVENANCE_API/v1/trace/baselines \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "model_version": "qwen2.5-0.5b-instruct@7ae55760", "families": ["prompt_injection"], "min_samples": 20 }' | tee baselines.json
import { Provenance } from "@provenanceauth/sdk";
const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const [baseline] = await prov.trace.baselines.create({ modelVersion: "qwen2.5-0.5b-instruct@7ae55760", families: ["prompt_injection"], minSamples: 20 });
import os
from provenanceauth import Provenance
prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
baseline = prov.trace.baselines.create(model_version="qwen2.5-0.5b-instruct@7ae55760", families=["prompt_injection"], min_samples=20)[0]
{
"object": "list",
"data": [
{
"id": "cbl_01M5Q0FNNNMQT3Z2WXDTG9EHH1",
"object": "trace_canary_baseline",
"agent_id": null,
"scope": "account",
"model_version": "qwen2.5-0.5b-instruct@7ae55760",
"family": "prompt_injection",
"version": 1,
"status": "learning",
"min_samples": 20,
"n": 0,
"excluded": 0,
"mean": 0,
"sigma": 0,
"sigma_floor": 0.01,
"histogram": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"started_at": "2026-10-24T13:09:29.909Z",
"ready_at": null,
"stale_at": null,
"updated_at": "2026-10-24T13:09:29.909Z"
}
],
"has_more": false,
"next_cursor": null
}
To refresh a ready baseline, re-learn it with POST /: the new version learns while the current one keeps serving. To remove one, delete it:
export BASELINE_ID=$(jq -r '.data[0].id' baselines.json)
curl -X DELETE $PROVENANCE_API/v1/trace/baselines/$BASELINE_ID \
-H "Authorization: Bearer $PROVENANCE_KEY"
await prov.trace.baselines.delete(baseline.id);
prov.trace.baselines.delete(baseline["id"])
{ "id": "cbl_01M5Q0FNNNMQT3Z2WXDTG9EHH1", "object": "trace_canary_baseline", "deleted": true }
Use it in a policy or a Trace rule
In a canary policy, use op: "z_gt" (0 to 10) or op: "pct_gt" (50 to 99.9). baseline: "agent", the default, uses the agent's own baseline and falls back to the account's.
{
"id": "unusual-injection",
"when": [{ "fact": "canary", "set": "prompt_injection", "op": "z_gt", "value": 3 }],
"require": { "deny": true }
}
The same condition works in a Trace rule on model output ("phase": "completion"), where it is also the family's trip threshold; a request can send a relative trip_thresholds too: { "prompt_injection": { "z": 3 } }. The response's rules.baselines names what each family was judged against.
With no ready baseline, a strict policy condition denies canary_baseline_unavailable, and a relative trip threshold leaves the reading at its published threshold and lists the family in rules.baseline_unavailable.
Limitations: a ready baseline is frozen; re-learn it after the agent's normal traffic changes. The number of baselines an account keeps depends on its plan.