Why staged rollouts are the release gate for agent-written Android and iOS code.
Every build passes one checkpoint before it reaches everyone.
When you halt a staged rollout in Google Play, no new users get that version. Everyone who already installed it keeps it.
That line from the Play Console docs is the part the agentic development diagrams skip. They usually draw the loop as intent, spec, plan, code and tests, review, and finally production signals that can trigger new tasks for the agent. Most add that humans stay in charge of critical releases. What they don't show is where that human decision goes when the release is a mobile binary, and for agent-written mobile code, that's where the risk sits. The practices aren't new. What changes is how much code reaches the release branch without anyone having typed it.
On a web backend, a bad deploy gets reverted, and the loop carries on. On a phone, the build is already installed.
The store is your deployment step, and it has no undo
Google Play's staged rollout guide says it plainly. Halting stops the version from reaching more people, and users who received it "will remain on that version." Play's own tip for a bad bundle is to create and roll out a new release with a fixed one. So the only way back is forward, through another build. Re-shipping the previous code under a higher version code is the rollback mobile teams actually have, and it still waits on review and on people installing the update.
Apple's phased release has the same shape with a fixed schedule. Users with automatic updates get it over 7 days, starting at 1% on day one and moving through 2%, 5%, 10%, 20% and 50% before 100% on day seven. You can pause for up to 30 days in total. The catch is in the same doc, which says anyone can download the update manually from the App Store at any time. That 1% only limits automatic updates.
Apple's phased release schedule, charted from App Store Connect Help.
So when the agentic development loop says production signals feed back into the agent, on mobile that means real people already hit the crash. The signal is useful. It just arrives after the damage, and there's no button that pulls the build back off their phones.
What the gate should actually measure
The gate belongs between "review approved" and "100% of users." Its job is to compare the new build with the previous one while the rollout is still small, which is a different job from checking that the app is healthy in general.
- Crash-free sessions and users per build. Crashlytics calculates crash-free users and crash-free sessions and lets you filter them by build. If you link Firebase with Google Play, you can also filter crash reports by Play track. These metrics only count fatal events, so they won't show an ANR spike.
- New crash signatures. Crashlytics can alert on new fatal issues, meaning crashes or ANRs it hasn't seen before, and on regressed issues you had marked closed. Regressed and trending alerts are on by default. New fatal, ANR and increasing-velocity alerts are not, so turn them on before you need them.
- User-perceived ANR rate per version code. The Play Developer Reporting API returns
userPerceivedAnrRatesliced byversionCode, with hourly aggregation in UTC. The crash rate metric set works the same way. - The user count behind each rate. Both metric sets return
distinctUsers. At 1% rollout, a rate built on a few hundred users can swing wildly, so the gate should refuse to decide until there's enough data.
The gate sits between a small staged rollout and everyone else.
Android vitals also publishes bad behavior thresholds. They're 1.09% for user-perceived crash rate and 0.47% for user-perceived ANR rate overall, with 8% for both on any single phone model, and Play judges them on a 28-day average. My opinion is that you shouldn't use these numbers as your gate. They decide store visibility, and by the time a 28-day average crosses 0.47%, the bad build has reached most of your users. Compare against your previous build instead.
The halt button has an API
Halting doesn't have to wait for someone to open Play Console. In the Play Developer API, a track release has a status of inProgress, halted or completed, plus a userFraction for the staged percentage. The docs describe a halted release as one whose APKs "will no longer be served to users," while users who already have them are unaffected.
Here's a halt check in Python. It reads the newest hour of vitals data for each version code and halts the release only when the new build looks worse than the previous one.
from datetime import datetime, timedelta, timezone PACKAGE = "com.example.app" NEW, PREV = 4210, 4200 # version codes being compared MIN_USERS = 2000 # tune from your own data MAX_RATIO = 1.2 # tune from your own release history def to_utc(d): # google.type.DateTime to datetime return datetime(d["year"], d["month"], d["day"], d.get("hours", 0), tzinfo=timezone.utc) def to_api(t): # datetime to google.type.DateTime, hour aligned return {"year": t.year, "month": t.month, "day": t.day, "hours": t.hour, "timeZone": {"id": "UTC"}} def latest_hour_anr(reporting): """{versionCode: (userPerceivedAnrRate, distinctUsers)} for the newest hour.""" metric_set = f"apps/{PACKAGE}/anrRateMetricSet" info = reporting.vitals().anrrate().get(name=metric_set).execute() end = next(to_utc(f["latestEndTime"]) for f in info["freshnessInfo"]["freshnesses"] if f["aggregationPeriod"] == "HOURLY") resp = reporting.vitals().anrrate().query( name=metric_set, body={ "timelineSpec": {"aggregationPeriod": "HOURLY", "startTime": to_api(end - timedelta(hours=1)), "endTime": to_api(end)}, "dimensions": ["versionCode"], "metrics": ["userPerceivedAnrRate", "distinctUsers"], }, ).execute() stats = {} for row in resp.get("rows", []): code = int(row["dimensions"][0]["int64Value"]) m = {v["metric"]: float(v["decimalValue"]["value"]) for v in row["metrics"] if "decimalValue" in v} stats[code] = (m.get("userPerceivedAnrRate", 0.0), m.get("distinctUsers", 0.0)) return stats def decide(stats, new_fatal_issue): # new_fatal_issue comes from your Crashlytics new fatal issue alert if new_fatal_issue: return "halt" if NEW not in stats or PREV not in stats or stats[NEW][1] < MIN_USERS: return "wait" if stats[NEW][0] > stats[PREV][0] * MAX_RATIO: return "halt" return "continue" def halt(publisher): edit = publisher.edits().insert(packageName=PACKAGE, body={}).execute() ids = {"packageName": PACKAGE, "editId": edit["id"], "track": "production"} track = publisher.edits().tracks().get(**ids).execute() halted = False for release in track.get("releases", []): if (str(NEW) in release.get("versionCodes", []) and release.get("status") == "inProgress"): release["status"] = "halted" # userFraction stays as it was halted = True if not halted: publisher.edits().delete(packageName=PACKAGE, editId=edit["id"]).execute() return False publisher.edits().tracks().update(body=track, **ids).execute() publisher.edits().commit(packageName=PACKAGE, editId=edit["id"]).execute() return True Set MAX_RATIO and MIN_USERS from your own release history. The check reads a single hour because the API docs warn that adding up distinctUsers across periods can count users more than once, and it edits the release already on the track instead of replacing the whole track. Also note that the edits model discards an open edit if someone changes the app in Play Console at the same time, so keep one owner for rollout changes.
The line I draw is the rollout percentage, and plenty of teams will disagree. A coding agent can open the release PR and even run this check. It shouldn't be the thing that raises userFraction. A script that halts automatically is cheap insurance. A script that expands automatically puts the agent's judgment in front of every user at once.
Wrap agent-written changes in remote flags
A halt only protects people who haven't updated yet. For everyone who already has, you need a flag.
A remote flag can switch off a code path on phones that already updated.
Firebase Remote Config changes app behavior without a new release, but the default minimum fetch interval is 12 hours. A kill switch that waits for a normal fetch can take hours to reach a phone. Real-time Remote Config pushes new values to the app as soon as they're published, so it's the version worth using for this.
This follows the listener pattern from the Firebase Android guide. The flag lives in Compose state, so a screen that's already open switches paths as soon as the new value is activated.
import android.util.Log import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import com.google.firebase.Firebase import com.google.firebase.remoteconfig.ConfigUpdate import com.google.firebase.remoteconfig.ConfigUpdateListener import com.google.firebase.remoteconfig.FirebaseRemoteConfigException import com.google.firebase.remoteconfig.remoteConfig object Flags { private const val CHECKOUT_V2 = "checkout_v2_enabled" private val remoteConfig = Firebase.remoteConfig // Compose state, so screens that read it recompose when the flag flips. var checkoutV2 by mutableStateOf(false) private set fun start() { // call once, for example from Application.onCreate() // The in-app default is OFF, so a device that never fetches keeps the old path. remoteConfig.setDefaultsAsync(mapOf(CHECKOUT_V2 to false)) remoteConfig.fetchAndActivate().addOnCompleteListener { refresh() } remoteConfig.addOnConfigUpdateListener(object : ConfigUpdateListener { override fun onUpdate(configUpdate: ConfigUpdate) { if (CHECKOUT_V2 in configUpdate.updatedKeys) { remoteConfig.activate().addOnCompleteListener { refresh() } } } override fun onError(error: FirebaseRemoteConfigException) { Log.w("Flags", "Config update error: ${error.code}", error) } }) } private fun refresh() { checkoutV2 = remoteConfig.getBoolean(CHECKOUT_V2) } } @Composable fun CheckoutEntry() { if (Flags.checkoutV2) CheckoutV2() else CheckoutV1() } The default matters more than the listener. If the agent-written path is on by default, a device that never fetches config runs it anyway.
Remote Config rollouts add a second, smaller staged release inside the binary. You choose the parameter and the share of devices that get the new value, and Firebase keeps an equal-sized control group so Crashlytics can compare the two. Because of that control group, the enabled percentage has to be 50% or less unless you change the setup. If the enabled group crashes more, you roll the flag back for everyone or for a segment, with no store review involved.
Flags have hard limits, though. They only cover code you wrapped. A crash in Application.onCreate() before config is read can't be switched off remotely. Neither can a Room migration that already ran, a new permission in the manifest, or a class R8 stripped at build time. When an agent touches that kind of code, the flag gives you nothing and the staged rollout is the only gate left.
When the fix has to be a new build
Then you ship forward and push people onto the fix. Play's in-app updates support an immediate flow, a full-screen flow the user has to accept before carrying on. The app reads updatePriority(), which comes from the inAppUpdatePriority value (0 to 5) set on the release. The Kotlin guide notes that priority can only be set when you roll out a release and can't be changed later, so decide it before the fix goes out. For iOS, or for blocking builds that can't talk to your backend anymore, Firebase documents a minimum app version pattern with Remote Config.
A release gate for agent-written code
Set it up in this order if you're starting from nothing.
- Turn on the Crashlytics alerts that are off by default, at least new fatal issues and increasing velocity.
- Put every agent-written feature behind a Remote Config flag that defaults to off in the app, and use the real-time listener.
- Start Play rollouts small and Apple releases in phased mode. Never send agent-written changes straight to 100%.
- Run a halt check per version code against the previous build, with a minimum user count before it decides.
- Let automation halt. Keep expanding the rollout as a human decision.
- Decide the in-app update priority of a fix before you roll it out.
- Give the code no flag can reach the slowest rollout. That means startup code, database migrations, manifest changes and R8 keep rules.
If your pipeline already halts automatically, what metric triggers it, and has it ever fired on a false alarm?
Sources and further reading
- Release app updates with staged rollouts (Play Console Help)
- Release a version update in phases (App Store Connect Help)
- Android vitals overview and bad behavior thresholds
- Play Developer Reporting API, vitals.anrrate.query
- Play Developer Reporting API, crash rate metric set
- Play Developer API, edits.tracks and Edits
- Understand crash-free metrics (Crashlytics)
- Crashlytics alerts
- Link Crashlytics with Google Play
- Get started with Remote Config on Android and Real-time Remote Config
- Get started with Remote Config rollouts
- Enforce a minimum app version with Remote Config
- In-app updates and Support in-app updates (Kotlin or Java)



