Three AI Agents, One Android Phone, and a Clock A developer built Corral, an open-source lease-based coordination system (v0.1.8) that lets multiple AI coding agents share a single Android device without colliding over adb. Instead of a lock file, Corral uses a SQLite lease table with a 30-minute default deadline, heartbeat renewal, and a FIFO queue, plus an identity chain (CORRAL_OWNER, /proc ancestry, then $USER) so the daemon can distinguish agents running under the same Unix user. The developer reports the hard part was handling agents that die while holding a device, which the expiring lease releases automatically. Three coding agents sharing one Android phone is not an AI problem. It is a 1980s problem wearing a new hat. This is the devlog of the lease-based fix, including the parts that turned out to be harder than the interesting part. Originally published at https://hackernoon.com/three-ai-agents-one-android-phone-and-a-clock https://hackernoon.com/three-ai-agents-one-android-phone-and-a-clock Three coding agents were working in my repo at 3 a.m. Two were running instrumentation tests, one was taking screenshots. They all had adb on their PATH, and they all picked the same device, because of course they did. The tests installed over each other. A screenshot captured a login screen from the wrong build. One agent force-stopped a process another was waiting on, then helpfully reported that the app had crashed. None of this is an AI problem. It is a 1980s problem wearing a new hat: a machine that is fine with one user and hostile to two . A debug bridge, a serial port, a printer queue — anything with a single "current state" and no locking eventually meets a second caller. This is the devlog of the thing I built to fix it, and of everything that turned out to be harder than the interesting part. The code is at github.com/ciszkin/corral https://github.com/ciszkin/corral : a daemon, a CLI, a Gradle gate and a Compose Desktop console around one SQLite lease table, with v0.1.8 published. An Android device is a singleton with no notion of ownership. adb will happily install, uninstall, force-stop, screenshot or shell into whatever is attached, from whoever asked. There is no lock, no queue, and no identity — the only thing standing between two agents and one phone is luck. What made it worse in my case was that the agents were not doing anything wrong. They were doing what I told them: run the tests, take a screenshot, iterate. The collision was structural. Add a second agent and you have a race that reproduces maybe one time in five, which is the worst rate possible: frequent enough to waste an afternoon, rare enough to look like a flaky test. So the question was not "how do I stop agents from being careless". It was "how do I give a singleton a queue, an owner and a deadline". The obvious fix is a lock file. It is also the wrong one, because a lock has no answer to the only question that matters: The failure mode you must design for is not two agents at once . It is one agent, gone . An agent that hits a token limit, crashes, or is simply killed by its harness leaves a lock file behind and no one to release it. The lock is held by a process that no longer exists, and every other agent waits forever on a dead owner. So the primitive is a lease : a claim with a deadline. Default 30 minutes, renewed by a heartbeat, floored at 10 seconds so the heartbeat can keep up, capped at a day. When the holder stops renewing, the lease sweeps back into the pool and the queue moves on. A dead agent cannot hold a device, because the clock releases it. Two details made that work in practice: corral claim --model Pixel --os 14 means "any that matches", and the FIFO is over Everything else in the product is downstream of that one choice. Every agent on my machine runs as vitali . Without a better idea, the daemon cannot tell Claude from Codex from a human typing adb , and my first design used $USER — which meant two agents could both "prove" they held the same lease. The fix is an identity chain, resolved in this order: CORRAL OWNER if the harness sets it agent tiers flow in this way ; /proc for comm:pid:starttime of the first non-shell ancestor; user:$USER as the floor. That chain is why "the holder" survives bash -c , make , and Gradle forking a worker. It is also why the same identity appears in three places — the CLI, the adb wrapper, and an MCP server — and why they must agree byte for byte. They still disagree on a host without /proc , so the wrapper delegates to corral owner there and the JVM does the same walk. One reader, two front doors. Here is the uncomfortable part. My agents are cooperative. They use the CLI. But nothing stops an agent from typing adb -s emulator-5554 install app.apk , and on the day one does, a polite error message is worth nothing. So the daemon installs gates in the places calls actually come from: adb — a two-line shim that asks the daemon before exec'ing the real binary. platform-tools/adb , daemon-healed if something overwrites it, because plenty of tooling calls adb by absolute path. init.d gate That third one is the non-obvious layer, and it is the only one that can block an installDebug started from an IDE. The honest count matters, so it is documented as what it is: a POSIX install has three layers; a Windows install has two , because the SDK shim is not installed there. An absolute-path call into platform-tools\adb.exe is outside the gate on Windows, and the docs say so. None of this is a security boundary. It is a guardrail for well-behaved machines with badly-behaved schedules. Saying that out loud, in the README and in SECURITY.md , saved me from a whole class of bug report where a "bypass" was really a misunderstanding. This one still makes me smile. On Windows the daemon runs as a Scheduled Task, so install and uninstall have to answer a polite question: is the task on this machine ours, someone else's, or absent? Get it wrong in one direction and you hijack another user's task. Get it wrong in the other and you leave an orphan pointing at a launcher you just deleted. So the rule is conservative: read the task's XML, find