MikhbarMIKHBAR
Artificial Intelligence

Instagram Direct Builds AI-Native UI with Jetpack Compose

Engineers on the Instagram Direct team have modernized their core Android messaging architecture by transitioning to Jetpack Compose, creating an AI-native UI design that substantially improves developer efficiency and performance.

Instagram Direct Builds AI-Native UI with Jetpack Compose

Modernizing a Core Android Surface

Instagram Direct handles billions of user messages every single day, making it one of the most critical surfaces within the platform. Over years of active iteration, the engineering team squeezed every possible micro-optimization out of the legacy Android View system. However, maintaining and expanding a heavily optimized legacy architecture creates considerable technical debt and engineering overhead, particularly as development teams increasingly adopt declarative UI frameworks and AI coding assistants.

In a close partnership with Google, engineers from Meta adopted Jetpack Compose while maintaining a rigorous performance standard. This collaborative effort improved Compose not only for the specific needs of Instagram, but also for the broader Android developer ecosystem. Rather than just applying a typical UI modernization, the team went a step further to redesign the codebase architecture specifically for AI compatibility.

Instagram Direct Builds AI-Native UI with Jetpack Compose
Image related to the report from Android Developers · Source: Android Developers

Designing an AI-Native Architecture

Artificial intelligence has rapidly evolved into a daily companion for software engineers across the tech industry, yielding real productivity gains on large-scale codebases. The Instagram Direct team set a more ambitious goal rather than simply pointing AI tools at existing legacy code: they redesigned the architecture to be AI-native by design. This approach multiplied the impact of AI tools far beyond what code retrofitting alone could achieve.

The team chose Jetpack Compose as a foundational component for this AI-native UI architecture. Its declarative nature ensures that code remains concise, predictable, and structurally easier for AI models to reason about. By reducing side effects, minimizing implicit state, and establishing clearer component boundaries, the codebase naturally guides AI tools toward producing cleaner and more accurate code.

Instagram Direct Builds AI-Native UI with Jetpack Compose
Image related to the report from Android Developers · Source: Android Developers

Addressing the Scale of Instagram Direct

Migrating a codebase of this magnitude required meticulous planning. Because hundreds of millions of people send messages on Instagram every single day, the migration had to be gradual and smooth with zero disruption to the user experience. The scale of the challenge is reflected in the numbers: individual UI components can render in over 160 distinct state permutations, and a single conversation screen handles more than 200 distinct message types.

When migrating large codebases to Compose, developers often face the temptation to embed Compose UI components directly inside existing View hierarchies as an incremental step. However, the Meta team noted that mixing declarative and imperative UI code can lead AI assistants to blend paradigms incorrectly, introducing subtle bugs, technical debt, and performance regressions over time.

Instagram Direct Builds AI-Native UI with Jetpack Compose
Image related to the report from Android Developers · Source: Android Developers

Practical Rules for AI-Friendly Codebases

To keep the codebase genuinely AI-friendly, the Instagram Direct engineering team adhered to two practical operational rules. First, they minimized dependency on custom context, ensuring the AI agent required as little bespoke, codebase-specific knowledge as possible. Second, they enforced architectural boundaries directly within the design, making the path of least resistance lead to correct and high-quality code rather than poor design choices.

Multiple engineers ran individual AI agents against a shared knowledge base of reusable skills and conventions developed throughout the migration. This strategy maintained synchronized workflows and best practices across the entire team, preventing individual engineers from having to repeatedly rediscover solutions to the same structural challenges.

Instagram Direct Builds AI-Native UI with Jetpack Compose
Image related to the report from Android Developers · Source: Android Developers

Measurable Performance and Efficiency Gains

The results of the migration validated the team's architectural approach. For the migrated Instagram Direct surfaces, Jetpack Compose allowed the engineering group to reduce the total amount of UI code by 50 percent. A smaller codebase for AI to generate directly correlates with higher-quality output and lower token consumption per task.

An internal data analysis comparing AI agent sessions working on Compose UI against identical tasks using Android Views highlighted clear efficiency improvements. The new architecture achieved a 35 percent reduction in AI agent execution time, 32 percent fewer engineer-agent exchanges per character of landed code, and a 33 percent overall reduction in token cost per agent session.

Sources

  • Android DevelopersHow Instagram Direct engineers built AI-native UI architecture with Jetpack Compose and reduced token cost per agent session by 33%

Continue chronologically

Related entity coverage