Instagram Direct Rebuilds Its Android UI for an AI-Native Architecture with Jetpack Compose
Public- 01 Oct, 2026

Instagram Direct is one of Instagram's most integral surfaces, handling billions of messages every day. For years, the team squeezed micro-optimizations out of the legacy Android View system, until it ran into a problem: keeping a heavily optimized but legacy surface maintained and expanded was becoming ever more costly, with growing technical debt and engineering overhead, especially as declarative UI and AI coding assistants became the norm. Rather than treat Compose adoption as just another UI modernization, Meta set a more ambitious goal: redesigning the codebase and its architecture to be AI-native by design, thereby multiplying AI's impact far beyond what simply retrofitting existing code could deliver.
The results were measured precisely. Jetpack Compose allowed Instagram Direct to reduce the total amount of UI code by 50%, speed up AI-agent task execution by 35%, cut engineer-agent exchanges by 32%, and lower token cost per agent session by 33%. Compose's declarative nature is central to this: code becomes concise, predictable, and structurally easier for AI models to reason about, with fewer side effects, less implicit state, and clearer component boundaries. Those are the properties that let AI produce higher-quality output, and less code to generate directly translates into lower token cost per task.
The team learned hard lessons about what happens when AI is pointed at mixed code. In a RecyclerView-heavy codebase, the tempting shortcut is embedding Compose components inside the existing View hierarchy. As a short-term migration step that is valid, but over the long run AI tools take the path of least resistance: when declarative and imperative code are blended, AI tends to merge them incorrectly, introducing subtle bugs, tech debt, and performance regressions. Concrete examples include a feature flag read in imperative code and then captured inside a Compose lambda, or a mutable field living on an item class rather than in its UI state, so it survives RecyclerView re-binding and recycling across rows, producing bugs that are painful to reproduce. Guardrails and skills help but are not enough, because AI hitting friction will route around them.

The fix is a pair of practical rules. A list item can keep its own abstraction, but all Compose code must live in the constructor as content, with constructor arguments as its only source of data and no access to class members or mutable state, making it equivalent to a plain @Composable function while conforming to existing architecture. Migration was staged in two steps per screen: identify common patterns and edge cases, then apply them systematically, letting one engineer settle architecture and tricky cases up front while others handled production readiness. Multiple engineers ran their own AI agents against a shared knowledge base of reusable skills and conventions, keeping workflows and best practices in sync across the team and slashing redundant rediscovery of decisions.
The scale was enormous. Individual UI components can render in over 160 distinct state permutations, and a single conversation screen handles more than 200 distinct message types. The team gradually migrated several hundred list items to Compose within the existing RecyclerView architecture, rolling them out in small independent groups under A/B tests with zero visible disruption to the messaging experience. Performance remained the number-one goal: metrics were tracked at runtime in production, letting the team run A/B tests comparing migrated Compose UI against legacy UI.

Internal analysis compared AI-agent sessions working on Compose UI against the same tasks using Android Views, using a risk score that evaluates code quality and the likelihood of a change causing production incidents. When a file's accumulated risk score doubles, Android Views reduced agent resource efficiency (measured as token consumption, execution time, and engineer-agent interactions) by 30% per landed character, while Compose UI fell only 9%. As a natural next step, the team is replacing the RecyclerView-based core with LazyColumn, keeping Compose components abstracted from their enclosing framework and switchable at runtime via feature flags to preserve A/B testing and an uninterrupted composition tree.