An A/B test can be live, traffic can be flowing, and everything can look fine in your application — while the experiment records nothing useful.
The frustrating part is that it often doesn't fail loudly. You don't get a useful error or a stack trace. You find out days later, when the results page is empty and the traffic has already been spent.
Flagsmith's documentation for running experiments lists five reasons this can happen. I took those five failure modes and turned them into build-time checks in a tool I built called Trial. Then I built the rest of the experiment lifecycle around the same idea: validate before creating anything, keep the experiment definition versioned, and don't promote a winner just because one number looks good.
Here's what those failures look like, and what I built to catch them.
First, make the five failures visible
I wrote five intentionally broken examples and ran them through Trial's linter:
✓ 01-unkeyed-variant protocol unkeyed-variant: variant without a key
✓ 02-event-name-mismatch protocol event-name-mismatch: no code emits checkout_started
✓ 03-no-identity no identity before exposure
✓ 04-cloud-events-url self-hosted API but no events URL
✓ 05-no-flush script never flushes buffered events
all five caught, none of them at runtime
That last line is the important one.
Every one of these setups can run without an obvious error. Your application can behave normally while your experiment collects unusable data.
Let's look at why.
The five ways an experiment can silently fail
1. A variation has no key.
Exposures need to be attributed to a specific variation. A variation without a key can still look fine in the dashboard and render in the application, but there's no reliable variation identifier for attribution.
The application works. The experiment doesn't measure what you think it measures.
2. The event name doesn't match the metric.
Event names are case-sensitive.
Checkout_Started and checkout_started are two different events. If the metric expects the second one but the application emits the first, the event won't match. The metric stays at zero, and the experiment has nothing useful to measure.
3. There's no identity before exposure.
Exposures and conversions need to be joined by identity.
Without an identity, the exposure can be skipped, along with the conversions that would have been attributed to it. At first, this can look like a conversion-tracking problem. The actual problem is that the user had no identity when the exposure happened.
4. The events URL still points to Flagsmith Cloud.
The SDK defaults to Flagsmith Cloud.
Say you're self-hosting Flagsmith. You point the flags API at your local instance, but forget to configure the events URL. Flags arrive from your own instance, while events are sent somewhere else.
The application gets its flags. Your self-hosted analytics never sees the events.
5. Buffered events are lost when the process exits.
SDKs batch events instead of sending every event immediately. The default flush window is ten seconds.
A short-lived script can finish its work, exit without flushing, and lose the events still sitting in the buffer. The process exits successfully. The data never arrives.
Four of these are configuration mistakes. The fifth is a lifecycle mistake. None is particularly exotic, which is probably why they're documented in the first place.
The interesting part is that all five can be caught before the experiment starts.
Put the experiment in a file
I didn't want the experiment to live only as a form in a dashboard.
A dashboard form is useful for creating something quickly, but the experiment definition should also be reviewable, versioned, and reproducible. It should be something you can put in a pull request and understand without clicking through a bunch of fields.
So Trial uses a YAML protocol:
apiVersion: trial/v1
name: pricing-billing-default
hypothesis: >
Defaulting the pricing table to annual billing will increase checkout starts
by at least 10% relative to a monthly default, within two weeks, without
increasing the share of visitors who switch away from the default.
flag:
name: pricing_billing_default
control:
value: monthly
variants:
- key: annual_first
value: annual
allocation: 50
metric:
name: checkout_started
event: checkout_started
aggregation: occurrence
direction: up
guardrails:
- name: billing_switched_away
event: billing_switched_away
direction: not_increase
decision:
min_chance_to_win: 0.95
min_exposures_per_arm: 1000
require_guardrails_clear: true
This is a trimmed example of the protocol in the repository.
The file defines the hypothesis, flag, variations, metric, guardrails, and decision requirements. It's the experiment's source of truth.
It can be reviewed in a pull request. Changes show up as normal diffs. And the protocol gets a hash.
That hash matters.
Once traffic starts, changing a variation key or allocation should not silently turn the experiment into a different experiment. Trial ties approval to the exact protocol hash. Change the file, and the existing approval no longer matches. Downstream actions need a fresh review.
The experiment can't quietly change underneath the traffic.
Scan the actual application code
A protocol can say that the metric is checkout_started. That doesn't mean the application actually emits it.
This is where I wanted Trial to do more than validate YAML.
The linter scans application source and checks whether the code really reads the flag and emits the event defined in the protocol.
For example:
$ trial plan experiments/pricing-billing-default.yaml
✖ flag no code reads the flag "pricing_billing_default"
the flag exists but nothing renders it, so nobody is exposed
✖ metric checkout_started no code emits the event "checkout_started"
the metric will stay at zero and the experiment will never conclude
2 errors · 1 warning
plan blocked — fix the errors above
This check takes around 80 milliseconds. The failure it prevents might otherwise take days to discover.
I also found a bug in my own linter while building this.
The first version searched for the event name anywhere in the source file. That included comments.
So a comment like:
// the metric is checkout_started
was enough to satisfy the check, even if the application never emitted the event.
That's a pretty bad property for a tool that's supposed to catch exactly this kind of mistake.
I fixed it by stripping comments before matching.
A check that can be satisfied by prose isn't really a check. I think that's worth remembering when building static analysis tools.
A winning result can still be a reason to refuse
Catching configuration errors is one half of the problem.
The other half is making sure a result doesn't get promoted just because the primary metric looks good.
Here's a guardrail failure:
$ trial promote --check
not promotable pricing-billing-default
· guardrail billing_switched_away rose 3.10% vs 0.00% on control
· win 97.5% lift +31.2%
· evidence running · as of 2026-11-28T19:49:34.617129Z
$ echo $?
1
The experiment has a 97.5% chance to win and a 31.2% lift.
Still refused.
The guardrail moved, so the result isn't promotable.
This is the entire argument for guardrails in one output. You can improve the metric you're watching while making something else worse. Shipping based on the lift alone is an easy way to celebrate the wrong outcome.
--check runs the same decision logic CI uses, but it only makes GET requests. It cannot flip a flag or modify the experiment. It exits with code 1 when the result isn't promotable.
That distinction is important. CI should be able to ask "may we ship this?" without having the ability to ship it.
What happened when I ran the experiment
I also wanted to test the full lifecycle, not just individual checks.
The first conclusive readout came back with a 90.2% chance to win. That was below the configured 95% threshold, so Trial refused to promote it. The gate refused at that stage three times, with 14,000 exposures.
Here's one of those refusal records:
{
"ts": "2026-11-27T10:25:43.568Z",
"actor": "agent",
"action": "readout",
"target": "pricing-billing-default",
"decision": "refused",
"reason": "chance to win 90.2% is below the 95% threshold",
"detail": {
"chanceToWin": 0.9024316147662585,
"lift": 0.10792404930051754,
"exposures": 14000
}
}
More traffic arrived. The final readout looked like this:
enrolled 24,001 control 12,001 annual_first 12,000
role metric control variant lift 95% CI win
goal checkout_started 4.36% 5.23% +20.1% 6.5 … 33.7% 99.8%
guard billing_switched_away 0.00% 0.15% — — clear
SRM p=0.995 — split looks healthy · computed from exposure counts
SHIP annual_first beats control
chance to win 99.8% · lift +20.1%
95% CI 6.5% … 33.7%
Two things worth being very clear about here.
First, the traffic was synthetic.
I drove 24,000 generated identities through the real SDK against a real Flagsmith instance, plus one manual visit. The ground truth was set to an 18% lift by construction.
Trial recovered a 20.1% lift, with a confidence interval that contains the planted 18%.
That's useful evidence that the pipeline can measure a known effect end to end. It is not evidence that defaulting a real pricing table to annual billing will increase checkout starts by 20.1%. I haven't tested that with real customers.
Second, the result does not establish a lift of at least 10%.
The point estimate is +20.1%, against a hypothesis targeting at least 10%.
But the lower bound of the 95% confidence interval is +6.5%.
So if the question is "have we shown that the lift is at least 10%?", the answer is no.
The configured decision rule requires a 95% chance to win. It does not require the lower confidence bound to exceed 10%. That's why the experiment can return SHIP while the evidence still doesn't establish the full hypothesis.
I wanted to call this out because reporting the point estimate as proof of a 10% minimum effect would be exactly the kind of overclaim that a tool like Trial should help prevent.
There's another detail I cared about: the readout doesn't just trust the numbers returned by the statistics engine.
Trial recomputes sample-ratio mismatch from the raw exposure counts. The engine also returns per-variant n, sum, and sum_squares alongside its inference, so lift can be independently recomputed.
Being able to check the statistics engine instead of just believing it is a property worth asking for.
Why an agent shouldn't be trusted to make the decision
I built Trial with agent-driven operation in mind.
An agent that can create an experiment can also create a broken one. And it can sound equally confident either way.
I didn't want the safety of the experiment to depend on whether an agent remembered every rule or interpreted a prompt correctly.
So the protocol and the tool enforce the boundaries:
- The protocol is validated against application source before resources are created.
- Its hash binds approval to the exact experiment definition.
- The decision is computed from warehouse evidence, not asserted in prose.
- Writes require explicit
y/Nconfirmation. - Refusals are recorded in an append-only audit log with the reason.
Reads are free. Writes are gated.
The agent can't retry a refusal by lowering the threshold or deleting a guardrail. That's explicitly forbidden by the skill's contract.
Locks are also scoped per environment, so an operation against Development cannot accidentally touch Production.
The agent's job is to operate the tool. It isn't asked to be trusted for the statistics.
What I wish the API made easier
While building against Flagsmith's experimentation endpoints, I ran into a few sharp edges. These are things I encountered during implementation:
-
PATCH .../mv-options/<id>/returned 500 withKeyError: 'feature'. A partial update effectively required a fullPUT. - Hitting an environment path without the
/api/v1prefix returned the SPA's HTML instead of a 404. To a program, that can look like a successful response containing data. - An environment addressed by numeric ID returned 403, even with a credential that was admin with the environment key.
- Finishing an experiment required
rollout_decisionandrollout_variant. Butrollout_decisionwas a read-only choice field with no choices listed. Values such ascontrol,variant, anddisablewere only discoverable in the source. - Results refresh was capped at once every five minutes.
A few things I'd like to see improved:
An experiments command group in the CLI (create, get, results, complete --rollout winner) would remove the need to drop to raw HTTP for common operations.
Variation keys should be required at creation time. And a --json validation mode should identify the broken variation, metric, or event binding before any traffic moves.
These aren't reasons not to use the platform. They're the things I ran into while trying to make the workflow reliable.
Five rules worth stealing
The useful parts of this project aren't specific to Flagsmith.
If you're building experiments on another feature-flag platform, the same principles apply:
- Validate metric names against application code, not just config. And strip comments first. A regex over prose will lie to you.
- Hash the experiment protocol. Approval should be tied to a document, not just to a moment in time.
- Separate the read-only gate from the write. One command should answer "may we ship?" A different command should actually ship it.
- Record refusals with reasons. "It said no" isn't much evidence. "It said no because the guardrail moved from 0.00% to 3.10%" is.
- Put the caveat next to the result. If the lower confidence bound doesn't clear the target, that is part of the finding, not a footnote.
That's what I wanted Trial to demonstrate: an experiment should be something you can inspect, validate, reproduce, and refuse to ship.
Try it
Trial is MIT-licensed and runs against self-hosted Flagsmith using Docker Compose.
The setup uses the open-source Flagsmith image with:
EXPERIMENTATION_ENABLED=true
USE_POSTGRES_FOR_ANALYTICS=true
Along with a task processor and Postgres.
Putting events in Flagsmith's own database made local experimentation a roughly three-minute setup for me, rather than a ClickHouse afternoon.
Repository: github.com/shreepalgoyal/trial-flagsmith-experimentation
Demo: Watch the Trial demo — the workflow is built and demonstrated entirely in code, not through a screen recording.
There are 109 tests in the project, all passing at the time of writing.
The experiment discussed here is in the repository, protocol and all. The synthetic traffic, the refusals, and the final readout are there too.
I'd rather have someone inspect the protocol and reproduce the numbers than take my word for them.
Top comments (0)