Dev.to AI 🤖 Ai 👁 0 📖 3 min read

The 5 prompt failures that killed my on-device Android agent (and the patterns that fixed them)

My on-device Android agent aced every demo I threw at it. Short tasks? Flawless. Two, three, four steps? No problem. Then I gave it a real 14-step flow — the kind a person actually does on their phone — and it died at

My on-device Android agent aced every demo I threw at it.

Short tasks? Flawless. Two, three, four steps? No problem.

Then I gave it a real 14-step flow — the kind a person actually does on their phone — and it died at step 13 of 14. On a cookie popup.

That failure taught me more than all the demos combined. Demos lie. Long, real flows are where prompts go to die. Here are the five failures that kept killing it, and the prompt patterns that fixed each one.

Failure 1: Planner loops

The agent would replan. And replan. And replan — generating a fresh, beautiful plan at every step and executing none of it.

The fix: a hard step budget plus a forced-commit rule.

If a plan step is executable, execute it. Replan only on a failed observation — never because a "better" plan occurred to you.

Planning is cheap for a model and feels like progress. It isn't. Cap the replans, and make acting the default.

Failure 2: Destructive taps

To a small model, a "Delete" confirmation dialog looks like any other button. My agent tapped through irreversible dialogs with the same cheerful confidence it used for "Next."

The fix: a two-phase fence around anything irreversible.

Irreversible actions (delete, send, pay, confirm) require an explicit CONFIRM token that restates exactly what will be destroyed or sent — before the tap, not after.

If the agent can't state what it's about to destroy, it doesn't get to destroy it.

Failure 3: Interstitials

Cookie banners. Permission dialogs. "What's new" update prompts. Real Android flows are full of interruptions that arrive mid-task, and a prompt written for the clean path has no idea what to do with them — so it improvises, badly.

The fix: an interstitial handler block, checked at every step boundary.

Before resuming the task at each step, check: is something on screen that isn't part of the task? Dismiss or resolve it by its own rules first, then resume.

Don't bolt this on as an afterthought. In real flows, interstitials are the flow.

Failure 4: The 2,000-word system prompt

I wrote a magnificent system prompt. Comprehensive. Thorough. Two thousand words.

The on-device model quietly ignored most of it.

The fix: a short imperative core — under ~150 words — that the model will actually follow, plus per-task-type reference cards loaded only when that task type is active.

Small models don't need more instructions. They need fewer, sharper ones, delivered at the moment they're relevant.

Failure 5: Accessibility-tree token blowout

Every screen, my agent ingested the full accessibility tree. Three screens in, the context was full of off-screen, non-actionable nodes — and the actual task had been pushed out.

The fix: prune before you prompt.

Keep visible + actionable nodes only. Cap tree depth. Summarize off-screen content in one line instead of dumping it.

Context is the scarcest resource an on-device agent has. Spend it on what the agent can act on.

The pre-flight checklist (steal this)

Before any long real-world run, check:

  1. Step budget set? Replans capped, forced-commit rule in place.
  2. Irreversible actions fenced? CONFIRM token restating the consequence, required before the tap.
  3. Interstitial handler active? Checked at every step boundary, before the task prompt resumes.
  4. System prompt under ~150 words? Reference cards loaded per task type, not all at once.
  5. Trees pruned? Visible + actionable only, depth capped, off-screen summarized.

Five checks. Every one of them earned by a real failure — most memorably, an agent that did 13 steps perfectly and was defeated by a cookie popup.

Disclosure: these patterns grew into a 32-prompt pack I sell — the Android AI Agent Prompt Pack, with the planner-loop, destructive-tap, and interstitial patterns worked out in full: https://hustlecity0.gumroad.com/l/iltwu?utm_source=devto&utm_medium=launch&utm_campaign=androidpack — the checklist above stands on its own whether you ever look at it or not.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.