Testing AI features across different user segments

An AI feature that looks successful in your aggregate metrics can be quietly failing a specific group of users at the same time.
This happens because AI models produce outputs based on statistical patterns learned from training data — and those patterns don't match every user equally. A summarization model trained mostly on English text will produce worse results for Spanish speakers. A coding assistant tuned for experts will confuse beginners. Your overall numbers can look fine while a real cohort has a genuinely bad experience.
This article is for engineers, PMs, and data teams who are building or shipping AI features and want to test them more honestly. If you've ever wondered why your AI feature seems to work well overall but gets complaints from specific users, AI feature segmentation is the practice that helps you find and fix that gap. Here's what you'll learn:
- Why AI performance varies by user type, language, plan tier, and intent — and why aggregate metrics hide those differences
- How to choose the right user segments to test before your experiment launches
- How to structure A/B tests that actually surface segment-level performance gaps
- How to pick the right success metrics for each segment, including guardrail metrics that catch harm early
- How to build a repeatable workflow using feature flags and targeted rollouts so every AI release is segment-aware by default
The article moves in order from the "why" to the "how." It starts with the mechanics of why AI outputs differ across user groups, then walks through segment selection, experiment design, metric choice, and finally the operational workflow that makes this sustainable over time.
Why AI features don't perform the same way for every user
If you've shipped an AI feature and declared it successful based on aggregate metrics, there's a reasonable chance you've missed something important. Not because your measurement was sloppy, but because the nature of AI systems makes aggregate measurement structurally insufficient for detecting certain classes of failure.
Understanding why requires a short detour into how these models actually work — and why that's fundamentally different from how traditional software fails.
AI outputs are probabilistic, not deterministic
A conventional software function is deterministic: given the same input, it returns the same output. If it breaks, it breaks consistently and visibly. AI models don't work this way. They generate outputs shaped by statistical patterns learned from training data, and the quality of those outputs is a direct function of how closely a given user's input resembles the distribution the model was trained on.
The same prompt, submitted by two different users with different linguistic backgrounds or domain expertise, can produce outputs of meaningfully different quality — not because of a bug, but because of how the model learned.
This is the core operating characteristic of probabilistic systems, and it has a direct consequence for product teams: you cannot test an AI feature once, observe a positive result, and ship with confidence. The result you observed reflects the aggregate of your test population, which may or may not represent the full range of users who will encounter the feature in production.
The dimensions along which AI performance diverges
The axes of variance are predictable once you understand the training distribution mechanism. Language and locale are among the most significant: a summarization model trained predominantly on English-language text will produce degraded output for Spanish-speaking users, not because the model is broken, but because Spanish-language text was underrepresented in its training data.
MIT researchers documented this pattern directly in a medical context, finding that a model trained mostly on data from male patients made incorrect predictions for female patients when deployed in a hospital — a subgroup failure that was invisible in aggregate accuracy metrics.
User expertise level introduces a different kind of divergence. A recommendation engine that surfaces advanced configuration options may delight power users who know what they're looking for, while overwhelming new users who lack the context to evaluate those recommendations. The model is behaving consistently; the user populations are interpreting and benefiting from its outputs differently.
Plan tier and behavioral intent introduce similar dynamics: enterprise users tend to bring more complex, domain-specific tasks, while free-tier users may be exploring capabilities with less defined goals. A single model configuration rarely serves all of these populations equally well.
Why aggregate metrics hide segment-level failures
This is where the problem becomes operationally dangerous. A global A/B test computes an average treatment effect across all users. If an AI feature meaningfully improves outcomes for 70% of your user base while degrading them for 30%, the aggregate result can still register as neutral or positive lift — and you'll ship a feature that's actively harming a cohort you never examined.
This is qualitatively different from traditional software testing. A broken UI component fails for everyone. An AI feature that underperforms for a specific segment fails silently, masked by the majority's positive response.
The technical term for this is heterogeneous treatment effects — the same feature variant produces meaningfully different outcomes across user populations — and it's the expected default behavior of any model deployed against a non-uniform user base, not an edge case.
The risk is highest for high-value or structurally underserved cohorts: non-English speakers, new users still forming habits, enterprise accounts with specialized workflows. These are often the users whose failures are most costly and least visible in aggregate dashboards.
What "working" actually means depends on who you ask
Consider a text summarization feature built on a model trained predominantly on English-language business documents. For English-speaking enterprise users, it performs well — outputs are coherent, accurate, and useful. For Spanish-speaking users, quality degrades because the model's training distribution underrepresents Spanish-language text.
Aggregate metrics show the feature is "working" because the English-speaking majority dominates the average. The Spanish-speaking cohort's degraded experience is statistically diluted into invisibility.
The same mechanism plays out with expertise divergence. A coding assistant that generates advanced, idiomatic solutions may accelerate experienced engineers while producing outputs that junior developers can't evaluate or safely use. Both cohorts are using the same feature. The aggregate engagement metric looks fine. The junior developer cohort is quietly accumulating technical debt or abandoning the feature entirely.
As Landon Smith, Head of Post-Training at Character.AI, put it: the only way to determine which model behavior actually serves users is to compare modeling techniques "from the perspective of our users" — not from the perspective of offline evals or aggregate product metrics.
That framing captures the problem precisely. AI performance is not a property of a model in isolation. It's a property of a model in contact with a specific user population, and that population is never uniform.
Segment selection happens before the experiment, not after the results disappoint you
Most teams reach for the easiest segments first — plan tier, geography, device type — because those attributes are already in the database and require no additional instrumentation. The problem is that "easy to query" and "likely to correlate with model performance" are not the same thing.
Choosing segmentation dimensions that don't actually map to how your AI feature behaves produces one of two bad outcomes: underpowered tests that return no signal, or neutral aggregate results that give you false confidence while a specific user cohort quietly has a terrible experience. The segment selection decision has to happen before the experiment launches, not as a post-hoc analysis after you're already puzzling over flat results.
Which dimensions actually correlate with AI model performance
The right way to evaluate a potential segmentation dimension is to ask whether it plausibly changes either the input distribution the model receives or the evaluation criteria the user applies to the output. If neither is true, the dimension probably won't reveal anything meaningful about AI performance differences.
Five dimensions tend to pass this test for most AI features: user expertise level, language and locale, plan tier, device type, and use-case intent. Expertise level changes input distribution directly — a power user submitting a detailed, well-structured prompt to an AI writing assistant will receive systematically different output quality than a novice submitting a vague one-sentence request.
Language and locale change both input distribution and the model's ability to process it, particularly for models trained predominantly on English-language data. Plan tier often correlates with use-case maturity and data volume, especially in B2B contexts. Device type affects how outputs are rendered and consumed, which matters for multimodal or long-form AI features.
Use-case intent — what the user is actually trying to accomplish — is frequently the highest-signal dimension of all, and the one most often overlooked.
Research from marketing analytics contexts suggests that behavior-based segments are substantially more predictive of outcomes than demographic segments. While that finding comes from a different domain, the underlying logic applies directly to AI feature testing: what users do with a feature, and why they're using it, tells you more about how a model will serve them than where they live or what they pay.
User expertise and use-case intent as high-signal dimensions
Expertise level and behavioral intent deserve particular attention because they're the dimensions most likely to be skipped in favor of attributes that are easier to pull from a user table. A concrete illustration: a SaaS product team that clustered users by feature usage patterns discovered three distinct activation paths.
Users who engaged with reporting features first retained at roughly twice the rate of users who started with setup flows. The segment that mattered wasn't demographic — it was behavioral intent at the moment of onboarding.
For AI features, this pattern is even more pronounced. Two users on identical plan tiers, in the same country, using the same device, can have radically different experiences with the same AI feature if one is an experienced practitioner who knows how to structure inputs and evaluate outputs, and the other is encountering the feature for the first time.
Aggregate metrics blend these experiences into a result that looks acceptable while neither cohort is being served well.
Language, locale, and plan tier — operationalizing them in practice
Language and locale are worth separating from generic geography because the performance gap is usually at the model level, not the UI level. A summarization model that performs well on English-language content may degrade significantly for Spanish or Mandarin inputs, and that degradation won't appear in aggregate satisfaction scores if English speakers are the majority of your test population.
Plan tier matters most in B2B contexts where the feature's value proposition differs meaningfully across customer segments. An AI feature that synthesizes large volumes of historical data may be genuinely useful for enterprise accounts with years of accumulated records and actively harmful — or simply irrelevant — for a startup account with three months of data.
Experiment targeting rules can handle these multi-dimensional definitions through AND/OR attribute logic, which lets you construct conditions like locale = es-MX AND plan_tier = free AND feature_usage_count < 5 without custom engineering work. Reusable saved group definitions mean that when the same segment — say, non-English enterprise users — needs to be tested across multiple AI feature releases over time, you're not rebuilding the audience logic from scratch each time.
For B2B products specifically, organization-level targeting is relevant when AI performance differences exist at the account level rather than the individual user level. Teams can also pass custom user attributes — including model-specific signals like prompt complexity scores or session depth — as targeting dimensions, which opens up AI feature segmentation approaches that go well beyond standard demographic fields.
For data teams who need to derive segment membership from historical usage patterns rather than live user properties, warehouse-native experiment platforms typically support two segment types: SQL-defined segments built from arbitrary warehouse queries, and fact-table-defined segments built from structured event data. This matters when expertise level or behavioral intent has to be inferred from past behavior rather than read from a user profile field.
The cost of getting segmentation wrong
When teams choose dimensions that don't correlate with model performance, the experiment doesn't just fail to find a signal — it actively misleads. A test that shows a neutral aggregate result on an AI feature may be hiding a significant negative effect on a specific cohort that simply isn't large enough to move the overall metric. That's not a statistical problem you can solve after the fact; it's a design problem that compounds with every experiment cycle you run on the wrong dimensions.
Two practitioner failure modes are worth naming explicitly. The first is running segmentation without a clear hypothesis about why that dimension should matter for model performance — treating segmentation as a mechanical step rather than a reasoning exercise.
The second is accepting segments that are statistically valid but not actionable: a segment that exists in your data but can't be targeted in your feature flag system, or that can't be connected to a metric your team actually controls. Both failures waste experiment cycles and erode confidence in the testing process itself. Defining the right segments before you test is how you avoid spending those cycles on questions that were never going to produce useful answers.
A single global A/B test is structurally incomplete for AI features
Running a single global A/B test on an AI feature is a structurally incomplete experiment design. It will frequently return a neutral or mildly positive aggregate result while concealing significant degradation for specific user subgroups. For traditional software, aggregate metrics are a reasonable proxy for quality — a bug either fires or it doesn't, and its effect tends to be uniform.
AI features don't work that way. Their outputs are probabilistic and context-dependent, which means a model that performs well for your majority population can simultaneously be producing poor outputs for a minority segment. The majority's positive signal averages out the harm, and the experiment reads as a ship decision when it should be a rollout decision at best.
This isn't a statistical edge case. It's the default failure mode for AI feature experiments that aren't designed to look for it.
The aggregate-masking problem
The mechanism here matters. Traditional software bugs tend to produce discrete, observable failures — a broken function throws an error, a misconfigured UI renders incorrectly for everyone. AI quality degradation works differently: it's continuous and subjective.
A recommendation engine that performs well for users with dense interaction histories may produce near-random suggestions for users with sparse ones, and that degradation won't surface as an error rate or a latency spike. It shows up as lower engagement, higher abandonment, and reduced return sessions within that cohort — signals that are easy to miss when you're looking at aggregate dashboards.
Aggregate metrics have no way to distinguish "feature works well for everyone" from "feature works well for most people and poorly for a few."
Pre-specifying segment hypotheses before the experiment runs
The corrective is not post-hoc slicing of results. Slicing after the fact inflates false positive rates through multiple comparisons, and it tends to surface spurious patterns rather than real differential effects. The discipline is pre-specification: before the experiment launches, document which segments you hypothesize will show differential treatment effects and articulate why.
That "why" is the important part. If you're testing a new language model on a summarization feature, you should be able to state mechanistically why Spanish-locale users might respond differently — because the model's training data skews English, because your evaluation set didn't include Spanish-language content, because the prompt template wasn't localized. That reasoning forces better experiment design and gives you a falsifiable hypothesis rather than a fishing expedition.
Practically, this means defining your segment filters before analysis begins, configuring dimension-level breakdowns to capture treatment effects across those dimensions within a single experiment, and treating guardrail metrics for high-risk segments as first-class experiment outputs — not afterthoughts.
In GrowthBook, guardrail metrics are a distinct schema object from primary goals and secondary metrics, which means they can be configured to surface harm signals even when aggregate primary metrics look positive.
Feature flag gating by user attribute
Feature flag gating by user attribute is the mechanism that makes segment-aware AI experiments operationally tractable. Rather than exposing all users to a new AI variant and hoping your analysis catches segment-level problems after the fact, you can gate the variant to specific segments using targeting rules on user attributes — locale, plan tier, expertise level, organization ID for B2B contexts, or any custom attribute your application tracks. GrowthBook supports attribute-based targeting rules with AND/OR logic, Saved Groups for reusable audience segments, and organization-level targeting for B2B use cases.
GrowthBook's experiment override rules support AND/OR attribute logic, saved group targeting, and B2B organization-level targeting, giving teams enough precision to isolate exposure to the exact cohort they're testing. The assignment algorithm uses deterministic hashing — the experiment seed and the configured hash attribute are hashed together to produce a stable value between 0 and 1, meaning the same user always receives the same variant assignment.
That consistency matters for AI experiments specifically: variant-switching mid-experiment would corrupt any behavioral signal you're trying to measure.
When running multiple segment-specific AI experiments simultaneously — say, one for Spanish-locale users and a separate one for free-tier users — namespaces prevent users who fall into both segments from being enrolled in conflicting experiments, which would otherwise introduce noise into both results.
Warehouse-native analysis and interpreting heterogeneous treatment effects
Segment-level analysis requires joining experiment assignment data with the full user attribute table. For sensitive segment identifiers — locale, health status, plan tier, organization ID — that join needs to happen in an environment where PII doesn't leave your control.
GrowthBook's warehouse-native architecture keeps analysis inside the customer's own data warehouse (Snowflake, BigQuery, Redshift, Postgres), which means the experiment infrastructure never requires access to the sensitive attributes that define your segments.
When interpreting results, the signal to look for is not just whether the overall treatment effect is statistically significant — it's whether the treatment effect direction or magnitude differs across segments. A positive aggregate effect paired with a negative segment-level effect is not a minor footnote. It's a fundamentally different rollout decision.
For smaller segment populations where sample sizes constrain statistical power, variance reduction techniques and continuous monitoring methods — both covered in detail in the metrics section below — are configurable at the experiment level, giving teams tools to detect real effects in cohorts that would otherwise require impractically long run times.
Character.AI's Head of Post-Training, Landon Smith, described using GrowthBook to "compare different modeling techniques from the perspective of our users — guiding our research in the direction that best serves our product." That framing captures the intent precisely: segment-aware experiment design isn't about finding statistical significance in aggregate. It's about understanding which users a model actually serves well, and making deployment decisions accordingly.
Choosing the right success metrics for each user segment in AI experiments
Running a well-structured AI feature experiment with carefully defined segments still fails if you're measuring the wrong thing for each group. Metric selection isn't a one-time decision you make at the experiment level — it's a decision you need to make for each segment independently, before you launch.
The right primary metric for a power user is often structurally irrelevant for a casual one, and applying a single measurement framework across all cohorts is how teams end up declaring a successful experiment that quietly damaged a high-value user group.
Aligning metrics to segment behavior, not segment demographics
The instinct is to define segments by who users are — their plan tier, their geography, their company size — and then apply the same success metric to all of them. The problem is that users in the same demographic cohort can have entirely different behavioral goals within the same AI feature.
A power user invoking an AI writing assistant to produce a first draft has a different success signal than a casual user who opened the same feature out of curiosity. For the power user, task completion rate and output accuracy are meaningful. For the casual user, feature abandonment rate and session engagement tell you far more about whether the experience is working.
This distinction matters because AI outputs are evaluated differently depending on what the user was trying to accomplish. Aggregate metrics flatten those differences. A neutral overall result on "time to task completion" might reflect genuine improvement for one behavioral cohort and genuine degradation for another — the two effects cancel each other out in the aggregate, and you ship a feature that harms a segment you care about.
Guardrail metrics as early warning systems for high-value cohorts
The most costly version of this failure mode involves high-value cohorts — enterprise accounts, power users, non-English speakers — where harm is invisible in aggregate results but significant within the segment. This is precisely where guardrail metrics earn their place in the experiment design.
A guardrail metric isn't a primary success metric. It's a metric you're not actively trying to move, but whose degradation would be a serious problem. GrowthBook's experimentation framework makes this concrete: guardrail results appear beneath the main goal and secondary metrics with full statistics, and the frequentist engine uses color-coded thresholds to communicate severity.
Yellow indicates the metric is moving in the wrong direction regardless of statistical significance. Red indicates it's moving in the wrong direction with a p-value below 0.05. When guardrail metrics reach significance, the documented guidance is to consider ending the experiment — it functions as a kill-switch trigger.
Applied at the segment level, this means defining a guardrail metric specifically for your highest-risk cohort before launch. If you're testing an AI summarization feature, your aggregate goal metric might be user satisfaction score. Your guardrail for enterprise accounts might be retention rate or feature usage frequency — metrics that would show harm even if the overall satisfaction numbers look fine.
Handling small per-segment sample sizes
Filtering an experiment to a specific segment reduces your sample size, which reduces statistical power and increases the risk of both false positives and false negatives. This is the practical constraint that makes segment-level metric analysis harder than it looks.
Two statistical methods address this directly. CUPED (Controlled-experiment Using Pre-Experiment Data) reduces metric variance by controlling for pre-experiment user behavior, which effectively increases the sensitivity of your analysis without requiring more users. Sequential testing allows you to monitor results continuously and make decisions as data accumulates, rather than waiting for a fixed sample size that a small segment may never reach. Both methods are available in mature experiment platforms and represent the current standard for handling underpowered segment analyses.
Minimum data thresholds per metric are a practical safeguard that prevents teams from drawing conclusions when segment sample sizes are genuinely too small to be meaningful. The instructive example: a result based on 5 versus 2 conversions should not be treated as signal, and experiment tooling can be configured to enforce that.
Pre-specifying metrics before you launch
The false positive risk compounds when you analyze many metrics across many dimensions after the fact. The more metrics and dimensions you examine, the more likely you are to encounter a spurious result. The corrective is pre-specification — deciding, before the experiment runs, which metric is primary for each segment, which metric serves as the guardrail, and what sample size that segment is realistically going to generate.
That last question constrains your options. If a segment will produce only a few hundred observations over your experiment window, a metric with low baseline conversion rate may never reach detectable effect sizes. Choosing a higher-frequency behavioral metric — one that fires more often per user — may be the only viable path to a valid result. Pre-specifying forces that conversation before launch, when you can still change the design.
Turning segment testing from a one-off project into a default release practice
Design principles don't ship products — workflows do. The preceding sections of this article establish why AI performance diverges across user segments and how to structure experiments that surface those differences. This section is the operational payoff: a repeatable cycle that turns segment testing from a one-time project into a durable practice.
The goal isn't to run one good experiment. It's to build the infrastructure that makes every AI feature release segment-aware by default.
The repeatable workflow: define, gate, monitor, decide per cohort
The fundamental shift in AI feature segmentation is that the decision unit changes. You're no longer asking "should we ship this feature?" You're asking "should we ship this feature to this cohort?" That reframe has direct operational consequences.
The cycle has four steps, each building on the last. Segment definition comes first: identify the user attributes that correlate with model performance differences — locale, expertise level, plan tier, organization, behavioral intent. From there, gate AI variants using feature flags with targeting rules that map to those attributes. As the rollout progresses, monitor segment-level metrics in your data warehouse rather than waiting for a final readout.
The last step is making per-cohort decisions — expand to 100%, modify the variant, or roll back without touching a deployment — then repeat this cycle for the next AI feature release.
The key discipline is resisting the pull toward a single global decision. A new summarization model might be a clear win for English-speaking power users and a measurable regression for Spanish-speaking casual users in the same experiment. A global ship decision harms one cohort while rewarding another. The workflow above forces the decision to happen at the cohort level, where the signal actually lives.
Feature flag architecture for AI variants
Feature flags serve as the control plane for AI variant delivery, and their architecture matters for experiment integrity. Deterministic hashing — where the same user ID always resolves to the same variant — is non-negotiable for AI segment tests. Without it, a user might see different model outputs across sessions, contaminating both the user experience and the exposure data.
GrowthBook uses MurmurHash3-based deterministic hashing, ensuring consistent bucketing across the full experiment window.
The targeting layer needs to be expressive enough to encode the segment dimensions that matter for AI. AND/OR attribute rules, saved groups for reusable cohort definitions, and B2B organization-level targeting all let you gate AI variants against the exact user populations you've pre-specified as hypotheses.
When a flag is evaluated locally from a cached JSON payload — rather than via a synchronous third-party call — it's also safe to use in AI inference paths where latency is a constraint. GrowthBook SDKs download flag rules as a locally cached JSON payload and evaluate every flag check in-process with zero network latency, so flag checks resolve in sub-millisecond time and your application continues to function correctly even if GrowthBook's servers are temporarily unavailable.
Feature evaluation diagnostics close the operational loop on the engineering side. When a flag behaves unexpectedly — a user receiving the wrong AI variant, a targeting rule firing incorrectly — developers need visibility into which rules evaluated and what outcome they produced. GrowthBook's developer tools expose exactly this: which features are active, how the rules were evaluated, and the ability to manually switch variations for debugging.
Continuous monitoring and the kill-switch mechanic
AI degradation doesn't trigger error alerts. A model producing degraded outputs for users with complex, high-volume inputs won't throw a 500 error or spike your latency dashboard — it will quietly show up as lower task completion rates, higher abandonment, or reduced return sessions within that cohort. That's why continuous behavioral monitoring at the segment level is the detection mechanism, not infrastructure alerting.
The monitoring architecture that supports this keeps segment-level metrics in your own data warehouse. GrowthBook queries experiment exposure data against your existing event tracking — no PII leaves your environment — and surfaces segment-level results as the rollout accumulates data.
Sequential testing enables teams to monitor those results continuously without inflating false positive rates, which means you can make an earlier kill decision when a specific segment is being harmed rather than waiting for a pre-determined sample size to complete.
The kill-switch capability is what makes this operationally viable. GrowthBook can instantly deactivate an underperforming AI feature for a specific segment without a code deployment. That's the "Confident AI Releases" model in practice: you're not choosing between shipping and not shipping — you're choosing which cohorts receive which variant, and you can change that decision in real time.
Who owns each step, and why that division prevents the workflow from collapsing
Sustainable segment testing requires clarity on who owns each step of the cycle. Role-based access lets PMs monitor segment-level experiment results and flag anomalies without requiring engineering support for every query. Data scientists can define the metrics and statistical methods. Engineers own flag configuration and the targeting rule architecture.
A cross-functional experiment platform — where product, engineering, and data science operate from shared infrastructure rather than siloed tooling — is what makes this division of ownership durable rather than theoretical.
Flag and experiment creation directly from the IDE, using plain English prompts, removes the context-switching overhead that causes teams to skip the flagging step under deadline pressure. Launch checklists, validation hooks, and prerequisite flags make segment review a required checkpoint in the release process — not an optional step that gets skipped under deadline pressure.
The specific review cadence will vary by team and release velocity. What matters more than the interval is that the cadence exists and is tied to the rollout stages: flag creation at build time, segment monitoring during gradual rollout, cohort-level ship/modify/kill decisions at defined percentage thresholds.
Character.AI's Landon Smith described the operational intent directly: "compare different modeling techniques from the perspective of our users — guiding our research in the direction that best serves our product." That's what the workflow above is designed to produce: model decisions guided by segment-level user evidence, not aggregate intuition.
Where to start when your last AI experiment didn't break out segment results
The through-line of this article is simple: AI performance is not a property of a model. It's a property of a model in contact with a specific user population. That reframe changes what "testing" means. You're not validating that a feature works — you're validating that it works for each cohort that will encounter it, and that the cohorts most likely to be harmed are the ones you've looked at most carefully.
The minimum viable segment testing stack: what you need to get started
You don't need a sophisticated data platform to start. You need three things: a way to target feature variants by user attribute, a way to define segment membership before the experiment runs, and a metric that fires frequently enough to detect an effect within a realistic sample size.
If you have feature flags with attribute-based targeting, a data warehouse you can query, and a behavioral metric that isn't conversion-rate-shaped, you have enough to run your first segment-aware AI experiment.
Prioritizing which AI features and segments to test first
Start with the AI feature that has the largest gap between aggregate satisfaction and qualitative complaints. That gap is usually where a segment-level failure is hiding. Then pick the one segment dimension most likely to correlate with model performance for that feature — language and locale if your model's training data skews English, expertise level if your feature's value proposition assumes domain knowledge.
One feature, one segment hypothesis, one guardrail metric for your highest-risk cohort. That's a complete first experiment.
From one-off experiment to continuous AI quality program
The operational shift that makes this sustainable is changing the decision unit from "should we ship this feature?" to "should we ship this feature to this cohort?" Once that question is the default, segment review becomes part of the release process rather than a separate project.
Saved segment definitions and warehouse-native analysis make that operationally tractable — you're reusing segment definitions across experiments and keeping sensitive attribute joins inside your own environment, not rebuilding the infrastructure each time.
The honest thing to say is that this takes a few experiment cycles to feel natural. The first time you run a segment-aware experiment and find a negative effect in a cohort that your aggregate result missed, the workflow will feel worth it. That's the moment the practice becomes a habit.
This article is meant to give you enough of the reasoning — not just the mechanics — to make that first experiment a good one, and to build from there.
What to do next: Pull the last AI feature experiment your team shipped and look at whether you broke out results by language, expertise level, or plan tier. If you didn't, that's your starting point — not a new experiment, but a reanalysis of an existing one. If you have the segment data in your warehouse, run the breakdown now. If the segment-level result differs from your aggregate, you've just identified the first hypothesis for your next experiment. If you don't have the segment data, that's the instrumentation gap to close before the next AI feature ships.
Related insights
- 8 Best Open-Source Feature Flagging Tools Compared
- A/B testing in the age of AI: evolution or revolution?
- How an AI startup ran 541 A/B tests in 1 year
Related Articles
A magazine's home page shows two recent issues. The design team wants subscribers to try a shelf with four. All four covers are public, and changing editions while the page is open should update the shelf immediately. That gives you a small React feature with a useful acceptance test. Click from guest to subscriber and back, and count the covers each time.
We'll put the display limit in a typed local flag, evaluate it inside a React component, and leave the choice of edition with the app. The example runs in a client-rendered React app without a GrowthBook account, an SDK key, or a request for flag rules. For the wider workflow, free feature flags for coding agents explains what to ask an agent to implement and how to review the result.
Define what one flag controls
Start with an existing React and TypeScript app, or create a Vite React project for the example. Install both GrowthBook packages so the definitions and the hooks resolve against compatible SDK versions.
Create src/flags.ts. Here the feature value is a number, which lets the component use the same rendering code for either edition. A future change from four covers to three is one edit to the rule.
A guest falls through to the default of two. A subscriber matches the rule and gets four. This rule applies to every subscriber, so the ID has no effect on the result here. If you later roll the shelf out to a percentage of subscribers, you already have an identity to use for repeatable assignment.
The type registration release note explains the version requirement for LocalFeatures. The registration connects the definition, the attributes, and the value returned by the hook. For the TypeScript mechanics, see Jeremy Dorn's Register pattern walkthrough.
Put the current reader above the shelf
Replace src/App.tsx with the component below. The edition switch is a local fixture so anyone reviewing the change can reproduce both states. In an existing app, take those two values from the active reader in your session layer.
The provider receives an instance initialized with the current reader and the checked-in rules. React can render the correct shelf on the first pass for that reader. If the app is still loading a session, decide what should occupy the shelf in the meantime. For this public list a two-cover guest view is reasonable. On a page where a switch would interrupt the reader, wait for the session before mounting the shelf.
Give your agent the React setup
Use the local flags guide to ask for a typed definition, a provider with the current reader, and a test that changes the edition.
Open the Agent GuideThe useMemo dependencies include the ID and the edition. If a reader subscribes while signed in, their ID can stay the same while their edition changes. Depending only on the ID would leave the old SDK instance in place. Passing a fresh object as the dependency on every render would create unnecessary instances. The example uses the two primitive values the rule setup actually needs.
Read the numeric flag where React renders the list
Create src/IssueShelf.tsx. Keep one stable ID per issue and let the component use the resolved value to select how many items to render.
Keep the hook at the top of the component, inside the provider's subtree. The React SDK supplies the flag value through that provider. Calling a hook inside a click handler or inside the list loop would break the Rules of Hooks. Use the returned number in ordinary render logic.
There are two places you can see the number two in this implementation. The definition's defaultValue is what an ordinary guest gets through evaluation. The 2 passed to the hook is a fallback for a value the SDK can't supply. Giving them the same value makes the basic shelf a sensible fallback, but checking only the guest case would let a broken provider arrangement or missing definition go unnoticed. The subscriber case proves that the component actually received the rule.
The list keys identify magazine issues. Keep those keys independent of the flag. Switching from two covers to four should preserve the identity of the first two rows. There's also no need to remount the whole app with an edition-specific key. React preserves state according to component position and keys. For example, a search input outside the shelf shouldn't lose its text because someone subscribed.
Check the transition in both directions
Use the template's build script to type-check and bundle the app. Once that passes, start the dev server and open the local address it prints.
On first load, the page says guest and lists November and October. Click Switch edition. The same page should say subscriber and add September and August. Click again. The list should return to the original two issues, in order. This last check catches code that appends more results on upgrade and never removes them on downgrade.
For a compile-time check, temporarily replace the numeric fallback with the string "2". Run the build again and inspect the error on the hook call. Then restore 2 and rebuild. If the string compiles, check that src/flags.ts belongs to the same TypeScript project as the component and that the package manager resolved compatible core and React versions.
Look for the core package used by your app and by the wrapper. If the app has several incompatible installations, align the versions before diagnosing the JSX. A team using an existing build script should also confirm it actually runs the TypeScript checker.
Hand off a React change someone can review
Give your coding agent the one-shot local feature flags guide and a short description of the observable behavior. For this shelf, the request can be as specific as the test.
The shelf controls how many public titles to display. If your actual feature unlocks paid articles, enforce access when the server serves an article. A client-rendered flag only decides what to show in that browser. Whenever a change to the display limit can wait for a deployment, the small local file keeps the decision reviewable alongside the component. When an editor needs to change it between issues without an engineering release, compare the free GrowthBook options for managing flag rules.
Manage the shelf in GrowthBook
Start a GrowthBook workspace when your magazine team is ready to manage shelf rules between deployments.
Get Started with GrowthBookTwo customers download the same weekly report. One has agreed to preview a new CSV column. The other feeds the old two-column format into an importer. Both requests can land on the same Node.js process, and each needs the right file even if the other request arrives while the report is loading.
This tutorial builds that endpoint with one checked-in feature flag. The process loads the rules once. Each request supplies its own workspace attributes and receives its own evaluation. You can run the whole example on your machine without an account, a client key, or a flag server. The free feature flags for coding agents walkthrough introduces the local approach. Here we'll give the agent a server-specific test to pass.
Set up a small TypeScript service
Use Node.js 22 or newer for this example. In an empty directory, create an npm project that uses ES modules, install the core SDK, and add the TypeScript tools.
Create tsconfig.json at the project root. The sample runs TypeScript directly with tsx and checks types in a separate step. Type checking with tsx explains why the two commands serve different purposes.
The following files all live next to that configuration. The server imports ./flags.js even though the source file is flags.ts. That spelling follows TypeScript's Node.js module resolution for ESM and works with this runner.
Define the report contract in one flag
Create flags.ts. The public format has two columns. The sample preview workspace gets one additional column. The only targeting attribute the rule needs today is reportPreview. Carry the workspace ID too, so two people downloading a report on behalf of the same workspace can share an assignment if you introduce a percentage rollout later.
The SDK type registration update covers this rule syntax and the 2.2.0 minimum. If you misspell reportPreview in a condition or use a string where the boolean flag expects a value, TypeScript can point at the definition. The Register pattern also makes the same feature name available in other modules without threading a generic type through each handler.
Before you add the endpoint, decide what belongs to the process and what belongs to the request. The feature definitions are identical for both customers. Their identity and preview enrollment can differ. If a handler changes an attribute on a single shared user instance before awaiting a database query, another handler could replace that attribute before the first handler resumes.
Give your agent a server-side task
Use the one-shot guide to add checked-in rules. Ask your agent to keep workspace attributes local to each request and demonstrate both CSV formats.
Open the Local Flags GuideCreate a scope when the request arrives
Create server.ts. The Node.js SDK provides GrowthBookClient for the process and createScopedInstance for the current request. The two fixture paths below stand in for two authenticated workspaces. The server binds to the loopback address so you can exercise it locally.
The HTTP handler looks up a workspace, creates its scope, and holds that scope across an asynchronous operation. The short promise-based timer gives a second request time to arrive. In a real export, that's where the database or storage read would happen. Keep the stable client at module scope and the scoped instance inside the handler. If a formatter needs the decision, pass it the boolean or the scoped instance.
In production, resolve the workspace and its access rights from the authenticated session before reading the report. The two selectable paths here are fixtures for public sample data. A caller's choice of a header, query string, or workspace slug can't establish permission to read another customer's report. The endpoint also prevents shared response caching. If you cache real exports, the cache needs to distinguish the workspace and the report format, along with any other inputs that change the response.
Test two requests that overlap
In the first terminal, type-check the service and start it. A successful type check exits quietly. The next command prints the loopback address and keeps the server running.
Save the following as verify.mjs. In a second terminal, run node verify.mjs. Node's built-in fetch calls the local server. Strict assertions compare the full header and data row, including where each row ends.
You should see the single success line. Testing just the preview workspace proves that the code can add a column. Testing both responses catches the more expensive mistake of silently changing an existing customer's export. Keeping the old format assertion around is especially valuable when the downstream importer belongs to someone outside your team.
To check the compile-time boundary, temporarily change gb.isOn("includeUniqueReaders") to gb.isOn("includeUniqueReader") and rerun npx tsc --noEmit. The diagnostic should identify the misspelled key. Restore it before running the server again. A coding agent can include the before-and-after type check and the two CSV headers in its pull request.
Decide when to expand the report
When one preview customer is ready, leave everyone else on the default. If the next step is to enroll a fraction of workspaces, choose an attribute that matches the promise you're making. Hashing a workspace ID lets colleagues downloading the same report share a format. Hashing each user's ID could give two analysts in the same company different column sets. The one-shot guide shows how to express a percentage and hash attribute in a local rule.
A new rule in flags.ts reaches a process through your deployment. During a rolling deploy, the same workspace might hit old and new processes. If customers need a durable choice of export schema, keep supporting the agreed format in the API itself. When the operational requirement is to change targeting between deploys, you can keep the scoped evaluation in the handler and change how the process receives its rules. The free GrowthBook offerings overview covers Cloud Starter and self-hosting for teams that want to manage those rules.
Manage report targeting in Cloud
Create a GrowthBook workspace when the team supporting exports needs to expand the preview independently of a server release.
Get Started with GrowthBookYour conference agenda has a new “Show room” button. Reviewers should see it on the first page load. Everyone else should get the existing agenda. If a Server Component renders the old agenda and a browser hook independently decides to show the new button, the first HTML and the browser can disagree.
In the Next.js App Router, the server can make this decision once and pass a boolean to the interactive component. We'll define the flag in the repo, select the preview audience with a local test cookie, and verify the actual HTML for both visitors. Clicking the button will still work after hydration. You can follow along without a GrowthBook account or client key. If you're assigning this work to an agent, the free feature flags for coding agents walkthrough gives the background.
Keep the flag definitions on the server
Use a TypeScript App Router project, or create a small one with create-next-app. These paths assume the project has an app directory at its root. If yours uses src/app, put both app and lib under src so the relative imports still match.
Keep the starter's root layout. Create lib/agenda-flags.ts with the following code. The SDK type registration update explains how LocalFeatures checks the flag and its rule against the registered types. This setup requires version 2.2.0 or later.
The module can reuse the client and rules across requests handled by the same process. It only holds the current visitor's audience inside the function call. Two requests can therefore use the same flag file and get different results. The Node.js SDK documents the scoped client used under the App Router here.
This particular rule has no percentage and needs no visitor ID. The two audiences are sufficient. If the team later asks for a rollout to 10% of attendees, add a stable attendee or registration ID and choose which of those units should stay together. Jeremy Dorn's Register pattern article explains how a change to an attribute type reaches the call sites that construct it.
Read the cookie for this request
Create app/agenda/page.tsx. The static heading can render for everyone. The request-specific content sits behind a Suspense boundary, so the fallback can show a neutral loading message until the server has the cookie.
The App Router's cookies function reads the incoming request asynchronously. Read it inside the visitor-specific component. Keeping that read out of shared cached code lets the surrounding page reuse common content without treating one visitor's decision as another's. This placement also accommodates App Router projects using Cache Components.
Give your agent the Next.js setup
Use the local flags guide with a concrete request to evaluate one flag on the server and return the same decision to the browser.
Open the Local Flags GuideThe cookie in this demo is a convenient way to preview a public UI treatment. Anyone with that cookie can see the room label. To target paying attendees or private sessions, obtain the audience from the verified session on the server and authorize the underlying data separately.
Pass one decision to the interactive component
Create app/agenda/Agenda.tsx. It's a Client Component because a visitor can open and close the room details. Its initial branch comes directly from the boolean supplied by the page.
The client boundary takes a serializable prop. The component receives true or false. The SDK instance, targeting rules, and cookie handling stay in the server module. You don't need a React provider for this component because its only browser-side choice is whether the visitor has clicked the button.
Follow one page load through server rendering and hydration. For a preview visitor, the server can send a section with a “Show room” button. React's first client render gets the same showRoom value and starts with open set to false. Hydration attaches the click handler. Opening the room detail then updates component state and doesn't require another flag evaluation.
Verify the HTML and the click separately
Build the production app and start it on port 3100.
In a second terminal, save this as verify-agenda.mjs in the project root and run node verify-agenda.mjs. The test makes two requests to the same route and looks for a marker on the rendered section. A marker in the HTML helps catch an implementation that only adds the intended layout after JavaScript runs.
Now open http://localhost:3100/agenda in a fresh browser profile. You should see the session title without a room button. In that local page's browser console, set the demo cookie and reload.
Click Show room and look for Room 204. Click Hide room and the room should disappear. This second check proves the component became interactive. If the server response test passes but the click fails, inspect the browser console for a hydration error before changing the flag rules.
Remove the fixture and reload once more. The button should disappear and the agenda title should remain.
The reload is deliberate. Editing the cookie in an already open document doesn't rerun its Server Component. In your app, use the normal session-change flow to request a fresh server render when a visitor signs in, signs out, or leaves a preview group.
Choose where the next flag should be evaluated
For a decision needed in the initial HTML, give the agent an observable requirement. Ask it to show the two HTTP responses, then click the interactive control in the preview. The first check catches an incorrect layout. The second catches correct HTML that never becomes interactive.
If a later feature depends on an action entirely within the browser, evaluate whether its flag belongs in the client tree. The one-shot local flags guide covers both placements. This agenda only needs one server decision. Updating its checked-in rule takes a deployment. Keep that tradeoff in view if the event organizer needs to pause a preview while attendees are already arriving. For that case, compare GrowthBook’s free options for changing flags between deploys.
Manage the agenda rollout in Cloud
Create a GrowthBook workspace when the organizer needs to adjust a preview audience while your Next.js app is serving attendees.
Get Started with GrowthBookReady to ship faster?
No credit card required. Start with feature flags, experimentation, and product analytics—free.



