Android
AuraScore 81/100

AICore Multimodal Prompt Orchestration Script Generator

Author robust Kotlin Coroutines and Compose scripts to orchestrate multimodal prompts against on-device Android AICore foundation models.

Use this template when building production Android applications that feed concurrent image tokens, audio clips, and text prompts into on-device generative models like Gemini Nano via Android AICore. It yields an asynchronous, reactive client script.

Template

Role: Lead Android Systems Architect specializing in Google AICore and edge generative foundation models.

Context

  • AICore integration level: {{aicore_client_version}}
  • Supported input stream types: {{multimodal_input_modalities}}
  • Maximum inference context window: {{token_budget_per_turn}}
  • Streaming response timeout: {{stream_timeout_ms}}
  • Fault tolerance policy: {{error_retry_strategy}}
  • UI binding pattern: {{compose_state_architecture}}

Task

Author a production-grade Kotlin script implementing an asynchronous Repository and ViewModel architecture that consumes multimodal prompt inputs (bitmaps, audio descriptors, and text) to orchestrate streaming generative completions through Android AICore, emitting unidirectional UI state.

Method

  1. Configure the AICore model binding and availability checks, ensuring compatibility with {{aicore_client_version}}.
  2. Construct an input preprocessor that validates, scales, and tokenizes {{multimodal_input_modalities}} within {{token_budget_per_turn}} limits.
  3. Build an asynchronous streaming engine using Kotlin Flow<T> that consumes generative token chunks from AICore without blocking.
  4. Implement backpressure handling to ensure streaming UI updates conform to {{compose_state_architecture}}.
  5. Enforce structured concurrency with CoroutineScopes linked to Android ViewModel lifecycles.
  6. Integrate an automated recovery handler executing {{error_retry_strategy}} upon model eviction or timeout.
  7. Wrap the generation lifecycle in an instrumentation layer measuring Time-To-First-Token (TTFT) and token generation velocity.

Constraints

  • Code MUST use Kotlin Flow for streaming generation and avoid standard blocking RPC calls.
  • MUST NOT exceed {{token_budget_per_turn}} under any input truncation path.
  • Sensitive prompt payloads MUST be cleared from memory buffers immediately after dispatch.
  • State management MUST strictly adhere to Unidirectional Data Flow (UDF).

Output format

  1. Dependency Setup: Build configuration specifications.
  2. Domain Models & Contracts: Sealed classes for MultimodalInputs, GenerationState, and Errors.
  3. AICore Repository Script: Complete streaming client with backpressure management.
  4. ViewModel State Engine: Full implementation binding to {{compose_state_architecture}}.

Self-review

  • Verify all Flow emissions are thread-confined and lifecycle-aware.
  • Ensure non-image tokens and image bytebuffers are recycled after model ingestion.
  • Confirm the timeout mechanism fires at {{stream_timeout_ms}} without leaking active coroutines.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-android
image-multimodal-prompting
aicore
jetpack-compose
multimodal