Skip to main content

Client Prompt Extensions

Each mobile platform appends its own prompt extension to the base system prompt. These extensions provide dynamic context that the server doesn't have access to.

iOS Extension

Source: one-app-ios-chat/Chat/Sources/Chat/Services/SystemPromptBuilder.swift

The iOS extension includes:

Dynamic context

  • Store division — Grocery or Clothing
  • Sign-in status — Whether the user is authenticated
  • Current cart — All items with names, quantities, prices, and entry GUIDs

UI display rules (critical)

The iOS extension contains mandatory instructions for using the show_products and show_cart display tools. These ensure the LLM always renders rich UI components instead of describing products in text.

Key rules:

  • After every search_products, get_product_details, or get_alternatives call, must call show_products
  • After get_cart, must call show_cart for visual display
  • Never list product names, prices, or details in text — the UI handles it
  • Search for multiple items separately, calling show_products for each

Workflow rules

  • Add to cart: search → show_products → add_to_cart
  • Remove/update: use entry_guid from cart context
  • Reorder: get_order_history → reorder_items
  • Never fabricate product codes, entry GUIDs, or order codes

Android Extension

Source: chat-pnp-android/client/src/main/java/pnp/app/chat/viewmodel/ChatViewModel.kt (buildSystemPrompt)

Architectural Note

Android currently sends the full system prompt rather than an extension. This means the base prompt's security guardrails may not be applied. Migration to the extension model is recommended.

The Android prompt includes:

Dynamic context

  • Division — Grocery or Clothing
  • Sign-in status
  • Cart context — Items with names, quantities, prices, and GUIDs
  • Order context — Recent orders with codes, totals, and dates

UI display rules (critical)

Android now has the show_products display tool, and the prompt makes its use mandatory — the app renders rich UI components, so the user cannot see raw text lists.

Key rules:

  • After every search_products (or detail lookup), must call show_products so results render as cards
  • Search for multiple items separately, calling show_products for each — each call creates its own carousel
  • Always pass a title to label each carousel, and search_query (the exact query used) to enable the "see all results" chevron to the full search page (PLP)
  • Always call search_products with limit: 20
  • Never list product names, prices, or details in text — the UI handles it
  • show_cart is not available on Android (planned); cart is described from the injected cart context

Workflow rules

  • Add to cart (explicit request): search → add_to_cart with the exact product_code
  • Add to cart (browse): search → show_products → user adds from the carousel
  • Use exact quantities from search results (especially for variable-weight items)
  • If add_to_cart fails, don't retry — report the failure
  • Only respond to the latest user message — don't re-search or aggregate earlier turns
  • For "usual items" / reorder: get_order_details → add_to_cart for each (no show_products needed)

Key differences from iOS

AspectiOSAndroid
Prompt deliveryExtension (appended to base)Full replacement
Display toolsshow_products + show_cartshow_products only (show_cart planned)
Cart context formatList with guid: prefixList with [guid:] suffix
Order contextNot includedIncluded with recent orders