Mobile Application Development

Building Autonomous In-App Agentic Workflows in Android with Cloud-Hosted AI Architectures and Dynamic UIs

Mobile application development is undergoing a fundamental paradigm shift, moving away from rigid, pre-compiled user interfaces toward fluid, agent-driven experiences. As artificial intelligence models evolve from conversational text generators into autonomous digital assistants capable of executing complex multi-step workflows, the architectural requirements for mobile apps are changing. Complex tasks—such as orchestrating comprehensive travel itineraries, coordinating multi-modal logistics, or executing financial transactions—often exceed the computational bounds, battery constraints, and session stability of a single mobile device session. To address these engineering challenges, Google’s Android Developer Relations team, through Senior Developer Relations Engineer Jolanda Verhoef, has released a comprehensive technical blueprint detailing how developers can build autonomous in-app agentic workflows running in the cloud while natively rendering dynamic interfaces via Jetpack Compose.

This advancement is part of the ongoing blog series titled Build Intelligent Android apps, which demonstrates how to transform basic mobile applications into personalized, intelligent, and agentic experiences. Building upon previous installations that explored on-device inference using Gemini Nano, cloud-hybrid reasoning, and system integrations via AppFunctions, the latest installment introduces the Agent Development Kit (ADK), alongside the Agent-User Interaction (AG-UI) protocol and the Agent-to-User Interface (A2UI) protocol. Together, these technologies establish a robust framework for decoupling cloud-orchestrated reasoning from client-side UI rendering.

The Engineering Challenge of Long-Running Mobile Workflows

Historically, executing multi-step tasks natively on mobile operating systems presented severe architectural limitations. When a user initiates a complex sequence—such as booking an itinerary that encompasses flight coordination, hotel selection, museum reservations, and restaurant bookings—the process requires continuous network calls, secure API credential management, and persistent session state maintenance. If a user accidentally closes the application, switches context to another memory-intensive app, or experiences a transient network drop, mobile operating systems frequently terminate background processes to conserve battery and memory. This often results in a lost session, corrupted transaction states, and a frustrating user experience.

Build intelligent Android apps: In-app agentic workflows

Furthermore, managing complex API credentials securely on a client device introduces security vulnerabilities. Storing proprietary enterprise tokens or user authentication keys locally exposes them to potential extraction via reverse engineering. Moving the orchestration layer to a secure, custom self-hosted backend mitigates these risks. In this hybrid architecture, the backend executes specialized booking agents in the background, while the Android application merely connects to the active session to visualize real-time progress and prompt the user for confirmation only when explicit authorization is required.

Orchestrating Multi-Agent Systems with the Agent Development Kit (ADK)

To simplify the complexity of orchestrating multi-agent systems without manually writing custom REST endpoints or managing fragile web socket connections, developers can leverage the Agent Development Kit (ADK). The ADK empowers developers to define specialized software agents equipped with functional tools capable of querying remote databases and executing transactional business logic.

Within the reference application known as Jetpacker—an open-source sample architecture provided by the Android development team—a specialized Booking Assistant coordinates flights, lodgings, cultural events, and dining reservations. The architecture utilizes a coordinator agent that analyzes incoming user intent and dynamically determines which subagents to trigger. For example, a flight booking subagent can be instantiated using lightweight model variants, such as Gemini-3.1-flash-lite, paired with registered function tools that interface with external APIs or mock databases.

from google.adk import Agent
from google.adk.runners import InMemoryRunner
from google.adk.tools import FunctionTool

def search_flights(destination: str, date: str) -> list[str]:
    return ["10:00 AM", "2:00 PM"]

def reserve_flight(flight_time: str) -> str:
    return "Reserved flight at " + flight_time

flight_agent = Agent(
    name="Flight Booker",
    model="gemini-3.1-flash-lite",
    instruction="Help the user search for flights and book a reservation.",
    tools=[
        FunctionTool(search_flights),
        FunctionTool(reserve_flight, require_confirmation=True)
    ]
)

runner = InMemoryRunner(flight_agent)

By utilizing the ADK runtime, developers are relieved from manually writing boilerplate code to track conversation contexts, route messages between the user and the neural model, or handle tool-calling loops. The framework automatically manages these execution steps, allowing engineers to focus entirely on procedural business logic while background orchestration handles the heavy lifting.

Build intelligent Android apps: In-app agentic workflows

Standardizing Communication Channels via AG-UI

Bridging a cloud-hosted agentic backend with a mobile client requires a standardized, bidirectional transport layer capable of handling real-time data streams, lifecycle events, text messages, tool execution logs, and state synchronization. To solve this interoperability challenge, developers utilize the AG-UI protocol.

AG-UI functions as a standardized message-type protocol designed explicitly for communication between intelligent agents and UI-driven client applications. On the server side, updates are yielded as standard Server-Sent Events (SSE), containing JSON deltas for text generation, tool invocations, and state updates. On the client side, the Android application utilizes a Kotlin SDK that listens to this incoming stream and maps the payloads into strongly-typed client events.

val config = HttpAgentConfig(
    agentId = "booking-assistant",
    threadId = threadId,
    url = "https://<your-backend-url>"
)
val agent = HttpAgent(config, httpClient)

val input = RunAgentInput(
    threadId = threadId,
    runId = runId,
    messages = listOf(UserMessage("Book a flight to Paris"))
)

agent.runAgentObservable(input)
    .collect  event ->
        when (event) 
            is TextMessageStartEvent ->  /* ... */ 
            is TextMessageContentEvent ->  /* ... */ 
            is TextMessageEndEvent ->  /* Handle completion */ 
        
    

This streaming architecture allows applications to move beyond traditional, static chatbot interfaces, offering users real-time visibility into the agent’s internal reasoning and operational milestones.

Decoupling Client and Server Dependencies with A2UI

Build intelligent Android apps: In-app agentic workflows

Traditional conversational AI architectures rely on static text responses or custom JSON payloads that require the client application to parse proprietary data structures and map them to pre-built screens. This creates a tight architectural coupling: every time an engineering team wishes to introduce a new UI component, modify a layout constraint, or support a novel user interaction, they are forced to update both the backend agent and the mobile application simultaneously. Consequently, businesses must publish an application update to app stores and wait for users to install the latest version—a process that introduces significant friction and deployment latency.

To eliminate this dependency, the development team integrated the A2UI protocol. A2UI enables cloud-hosted agents to dynamically describe the user interface components that should be rendered on the client device. Instead of hardcoding layout definitions within the mobile app, the client declares a catalog of supported UI components, while the server transmits structured JSON payloads specifying component hierarchies, layout properties, and active states.


  "version": "v0.9",
  "updateComponents": 
    "surfaceId": "Flight Reservation",
    "components": [
      
        "id": "flight_option_picker",
        "component": "InteractiveOptionPicker",
        "properties": 
          "prompt": "Select a flight time:",
          "options": ["10:00 AM", "2:00 PM"],
          "selectedIdx": null,
          "confirmBtnText": "Confirm Flight"
        
      
    ]
  

By decoupling the client’s visual implementation details from the agent’s workflow state, product teams can update workflows, introduce new interactive elements, and refine user experiences entirely on the server side without requiring client-side binary updates.

Grounded Prompt Engineering with A2UI Schema Management

For an autonomous language model to reliably generate valid A2UI JSON payloads that match the client’s rendering capabilities, it must possess precise contextual awareness of the available component catalog. The ADK A2UI integration solves this by automating schema injection directly into the system prompt.

Build intelligent Android apps: In-app agentic workflows

Utilizing the A2uiSchemaManager, developers can compile JSON schemas and layout instructions directly from their defined component catalogs. This ensures that the underlying large language model learns the exact structural formatting rules, validation constraints, and property types required to generate compliant A2UI payloads.

from a2ui.schema.manager import A2uiSchemaManager
from a2ui.schema.constants import VERSION_0_9
from a2ui.schema.catalog import CatalogConfig
from a2ui.basic_catalog.provider import BasicCatalog

schema_manager = A2uiSchemaManager(
    version=VERSION_0_9,
    catalogs=[
        BasicCatalog.get_config(version=VERSION_0_9),
        CatalogConfig.from_path(
            name="https://example.com/catalogs/booking_assistant/v1/catalog.json",
            catalog_path="booking_catalog.json"
        )
    ]
)

A2UI_SYSTEM_INSTRUCTION = schema_manager.generate_system_prompt(
    role_description="You are a helpful travel booking assistant.",
    ui_description="Use InteractiveOptionPicker for choices...",
    include_schema=True,
    include_examples=True,
    allowed_components=["InteractiveOptionPicker", "SeatSelectionPicker", "BookingStatus"]
)

Natively Rendering Dynamic Surfaces via Jetpack Compose

To transform these cloud-generated JSON definitions into fluid, native Android views, developers utilize the newly introduced Jetpack Compose A2UI Renderer library. By incorporating the core runtime and Material 3 integration packages into the application’s Gradle configuration, engineers can map remote component classes directly to native Jetpack Compose composable functions.

dependencies 
    implementation("androidx.a2ui:a2ui-model:1.0.0-alpha01")
    implementation("androidx.a2ui.compose:compose-runtime:1.0.0-alpha01")
    implementation("androidx.a2ui.compose:compose-ui:1.0.0-alpha01")
    implementation("androidx.compose.material3:material3-a2ui:1.0.0-alpha01")

Custom components—such as InteractiveOptionPicker, SeatSelectionPicker, and BookingStatus—are registered within a centralized catalog that mirrors the backend definition. Furthermore, for standard UI patterns, the material3-a2ui library provides ready-to-use Material 3 implementations for basic elements including text blocks, cards, buttons, checkboxes, and date-time pickers, minimizing the need for custom layout boilerplate.

Inside the application’s ViewModel, incoming A2UI messages are processed via the A2uiMessageProcessor, exposing active surfaces as reactive state flows to the UI layer:

Build intelligent Android apps: In-app agentic workflows
class BookingAssistantViewModel : ViewModel() 
    private val messageProcessor = A2uiMessageProcessor(
        catalogs = listOf(bookingAssistantCatalog())
    )
    val activeSurfaces: StateFlow<List<A2uiSurfaceModel>> = messageProcessor.activeSurfaces

    init 
        viewModelScope.launch(Dispatchers.Default)  
            messageProcessor.collectMessages() 
        
    

Finally, within the Jetpack Compose screen, these active surfaces are collected and rendered using the official A2uiSurface composable. The framework automatically manages reactive state observation, Material 3 loading indicators, error fallbacks, and animated transitions between updates.

@Composable
fun BookingAssistantScreen(
    viewModel: BookingAssistantViewModel,
    modifier: Modifier = Modifier
) 
    val activeSurfaces by viewModel.activeSurfaces.collectAsState()
    LazyColumn(
        modifier = modifier.fillMaxWidth(),
        verticalArrangement = Arrangement.spacedBy(16.dp)
    ) 
        items(activeSurfaces)  surfaceModel ->
            Card(modifier = Modifier.fillMaxWidth()) 
                A2uiSurface(
                    surfaceModel = surfaceModel,
                    modifier = Modifier.fillMaxWidth().wrapContentHeight()
                )
            
        
    

Implications and Industry Outlook

The convergence of cloud-hosted agentic backends, standardized transport protocols like AG-UI, and dynamic UI rendering frameworks such as A2UI represents a major maturation point for intelligent mobile applications. By separating business logic orchestration from device-level presentation, developers can build resilient, long-running assistant workflows that withstand network interruptions and device state resets.

Industry analysts observe that this architectural pattern significantly reduces time-to-market for AI-driven feature deployments. Because cloud agents dictate interface composition dynamically, enterprises can iterate on user experience flows, introduce transactional capabilities, and optimize booking pipelines in real time without forcing end-users through continuous client-side update cycles.

Developers seeking to examine the complete reference architecture can access the open-source Jetpacker repository on GitHub. As mobile operating systems continue to embrace agentic architectures, the implementation of cloud-hybrid reasoning and dynamic protocol-driven rendering will likely become an industry standard for enterprise-grade mobile engineering.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Lock It Soft
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.