Building a Hyper-Personalized Food Ordering Agent for E-commerce at Scale
ifood · E-commerce · 2026 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.4 (schema v2)
Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.
Problem
Domain: E-commerce food-ordering agents
iFood needed an agent that could reduce food-ordering decision paralysis for millions of users by interpreting vague intent, personalizing options, and safely taking commerce actions across the app and WhatsApp.
Constraints:
- users are hungry and expect low-latency responses
- food preferences vary by user, time of day, order history, and channel
- Brazilian commerce behavior makes WhatsApp strategically important but security-sensitive
- tool outputs, conversation history, and many tool descriptions can bloat the context window
- production fixes can accumulate as prompt edge cases unless backed by evaluations
Architecture
ISO uses a single-agent architecture with state-dependent behavior. A user message enters the agent, the system prompt changes according to the current flow and tool state, and context is loaded from conversation state plus offline user-profile representations. Food-specific tools handle search, cart, coupons, ordering, payment experiments, UI carousels, and follow-up suggestions. Personalization tools expand user intent into semantic and exact queries, rerank results with user context, and return both agent-visible responses and UI elements. Latency is managed with fast paths, async preprocessing, context compaction, prompt compression, English prompts, smaller models where possible, and scenario-based evaluations.
Diagram confidence: explicit (topology described by the source).
flowchart LR app-and-whatsapp-channels[App and WhatsApp channels] --> iso-agent[ISO agent] app-and-whatsapp-channels --> authentication-flow[Authentication flow] authentication-flow --> iso-agent iso-agent --> state-dependent-system-prompt[State-dependent system prompt] iso-agent --> user-context-builder[User context builder] offline-preference-processing[Offline preference processing] --> user-context-builder user-context-builder --> personalized-search-and-reranking[Personalized search and reranking] state-dependent-system-prompt --> food-tool-workflows[Food tool workflows] iso-agent --> food-tool-workflows personalized-search-and-reranking --> food-tool-workflows food-tool-workflows --> ui-response-layer[UI response layer] personalized-search-and-reranking --> ui-response-layer ui-response-layer --> app-and-whatsapp-channels evaluation-agent[Evaluation agent] --> iso-agent evaluation-agent --> state-dependent-system-prompt evaluation-agent --> ui-response-layer
Components
| Component | Role | Interacts with |
|---|---|---|
App and WhatsApp channels |
User-facing entry points with different interaction styles and authentication requirements. | ISO agent, Authentication flow, UI response layer |
ISO agent |
Single agent whose behavior changes by state and flow while coordinating food tools and user context. | App and WhatsApp channels, State-dependent system prompt, User context builder, Food tool workflows, UI response layer |
State-dependent system prompt |
Flow-specific prompt instructions that alter behavior depending on tool use and conversation state. | ISO agent, Food tool workflows, Evaluation agent |
User context builder |
Combines conversation context, order history, food categories, time of day, location, and offline user-behavior representations. | ISO agent, Offline preference processing, Personalized search and reranking |
Offline preference processing |
Asynchronous processing that prepares user preference representations and moves expensive context work off the synchronous path. | User context builder, Personalized search and reranking |
Personalized search and reranking |
Expands requests into semantic and exact queries, retrieves food options, and reranks options using user context. | User context builder, Food tool workflows, UI response layer |
Food tool workflows |
Food-specific tools and AI workflows for cart management, ordering, coupons, payment experiments, and recommendation flows. | ISO agent, Personalized search and reranking, UI response layer |
UI response layer |
Renders tool outputs as app screens, carousels, buttons, follow-up suggestions, and short response paths. | App and WhatsApp channels, Food tool workflows, Personalized search and reranking |
Evaluation agent |
Runs natural-language scenarios against the ISO endpoint and checks responses, UI, and guardrail behavior. | State-dependent system prompt, ISO agent, UI response layer |
Authentication flow |
Validates WhatsApp users through app/browser authorization when identity is uncertain. | App and WhatsApp channels, ISO agent |
Data flow
The agent receives a user message from the app or WhatsApp, loads user and conversation context, selects behavior through a state-dependent system prompt, and calls food-related tools. For recommendations, offline user behavior is converted into preference representations, combined with current context, expanded into search queries, searched semantically and exactly, reranked, then returned as both UI cards and agent context. Evaluations replay natural-language scenarios against the endpoint and UI to test regressions, guardrails, and prompt changes.
4 supporting quotes
Why this architecture
iFood used a single-agent design to keep orchestration simpler while still allowing state-specific behavior. The architecture pushes personalization into self-contained tools, returns UI elements alongside tool outputs to reduce typing, and reserves complex flows for complex intent while using shortcuts and async work to meet hungry-user latency expectations.
4 supporting quotes
Models used: LLMs for ISO · smaller models for lower-latency flows where possible · LLM judge/evaluation agents
Scale
- iFood handles about 160 million monthly orders.“uh the company so there are 160 million monthly orders that I makes 400,000 delivery drivers 50 55 million monthly users and i food is present in 1500 cities in Brazil and it's not just a food delivery”transcript, stated
- The platform has about 400,000 delivery drivers and 55 million monthly users.“monthly orders that I makes 400,000 delivery drivers 50 55 million monthly users and i food is present in 1500 cities in Brazil and it's not just a food delivery company. So if food is also a Brazilian tech company and again uh you know in”transcript, stated
- iFood operates in 1,500 Brazilian cities.“50 55 million monthly users and i food is present in 1500 cities in Brazil and it's not just a food delivery company. So if food is also a Brazilian tech company and again uh you know in the genai wave it's uh it's much easier”transcript, stated
- The company runs 150 proprietary AI models and 14 billion real-time predictions per month.“numbers. So there are 150 proprietary AI models and a lot of them are known as Genaii models that uh for model for logistics for example that uh so whenever someone makes an order this model connects uh how to assign a driver to that order 14 billion uh real-time”transcript, stated“to that order 14 billion uh real-time predictions are made every month 16 pabytes of data uh in the data lake and so on. So I food is a truly so it's a food delivery company but it's truly a Brazilian tech company.”transcript, stated
- The data lake is described as 16 petabytes.“predictions are made every month 16 pabytes of data uh in the data lake and so on. So I food is a truly so it's a food delivery company but it's truly a Brazilian tech company.”transcript, stated
- ISO latency improved from roughly 30 seconds P95 to 10 seconds P95.“flows to work. So our latency was pretty high. We had around 30 seconds P95 and we decreased that uh up to 10 seconds uh by uh looking at what flows uh we could uh simplify. So we tried to make sure that um we could have a flow to handle complex requests but when things were”transcript, stated
- WhatsApp reach matters because Brazil has more than 150 million active WhatsApp users.“Brazil has one of the biggest WhatsApp active user base. So more than 150 million users are active in WhatsApp”transcript, stated
- Non-English prompts can require up to 50% more tokens.“if you want to write the same information in a language that is not English, uh you're going to have to use more tokens and it can be up to 50% or more tokens.”transcript, stated
Alternatives considered (roads not taken)
Run every request through the full complex agentic flow
Rejected because: Simple food searches and promotion queries did not need the full slow path, so iFood split out shortcuts to reduce P95 latency.
Keep all context processing synchronous
Rejected because: Compacting history and selecting user-behavior information could happen asynchronously, removing tokens from the slowest user-visible flow.
Write system prompts in the local user language
Rejected because: Portuguese and other non-English prompts cost more tokens and latency in the models they used, so the team kept prompts in English.
Patch production edge cases by adding more prompt rules
Rejected because: Prompt edge-case accumulation became a code smell; iFood instead added eval cases, improved tool names, and removed prompt bloat.
Treat WhatsApp as fully standalone from the app immediately
Rejected because: The team keeps app validation in the loop for identity and security while experimenting with more standalone WhatsApp behavior.
Expose all MCP-style tools to the agent
Rejected because: Large tool catalogs bloat context and decision space, so ISO focuses on efficient custom tool grouping.
Patterns
tool-use-orchestration (agent_architecture)
ISO coordinates food-specific tools for search, cart, ordering, coupons, UI generation, and payment experiments, with some tools implemented as independent AI workflows.
agent-memory (agent_architecture)
The agent uses order history, food categories, time of day, city context, and remembered behavior to make recommendations feel personalized.
hybrid-search (knowledge_retrieval)
Food search combines semantic and exact search before reranking results with user context.
query-rewriting (knowledge_retrieval)
Generic requests like 'I'm hungry' are expanded into multiple search queries that represent the user's likely preferences.
context-compaction (context_management)
The team compacts previous-message context and moves context preparation off the synchronous request path to reduce latency.
latency-optimization (operations)
ISO reduced P95 latency by splitting simple flows, moving work asynchronously, compressing prompts, using English prompts, and using smaller models where possible.
eval-driven-development (quality_assurance)
Every prompt edge case is backed by an evaluation scenario, and an evaluation agent exercises the endpoint, UI, and guardrails.
safety-policy-enforcement (safety)
WhatsApp flows require authentication/authorization through the app when the phone number or user identity is uncertain, and guardrail evasion is tested in evaluations.
Tradeoffs
Single-agent architecture with state-dependent behavior
Chose One agent with state-specific prompts and specialized tool workflows over A fully separate multi-agent system.
Rationale: The design gives flow-specific behavior and independent tool workflows without multiplying top-level agents.
Fast paths for simple requests
Chose Shortcut flows for simple food searches, preferences, and promotions over Always running the complete complex agent flow.
Rationale: Hungry users need low latency, and simple requests do not justify the full workflow.
Use English prompts in a Portuguese-market product
Chose English internal prompts over Portuguese prompts matching the user language.
Rationale: English prompts reduced token counts, latency, and context pressure in the models they used.
Connect tools to UI elements
Chose Carousels, buttons, and follow-up suggestions generated from tool outputs over Pure chat-only responses.
Rationale: Users in food ordering do not want long typing loops; UI shortcuts make the route to ordering shorter.
Keep WhatsApp connected to app authorization
Chose WhatsApp plus app/browser validation for identity-sensitive moments over A fully independent WhatsApp ordering agent.
Rationale: WhatsApp is essential in Brazil but needs identity checks before higher-risk commerce actions.
Gotchas (what bit them)
Prompt edge cases accumulate into bloated prompts.
Root cause: Production bugs, complaints, and eval failures tempt teams to add another system-prompt rule instead of fixing tool semantics or testing the behavior.
Resolution: Create eval cases for each edge case, improve tool and variable names, and remove explicit prompt rules while running regression evaluations.
Non-English prompts pay a token and latency tax.
Root cause: The models used by the team tokenize English more efficiently than Portuguese and most other languages.
Resolution: Keep internal prompts in English while still serving Portuguese-speaking users.
Large context windows still degrade quality and cost.
Root cause: Putting more context into the prompt can create needle-in-a-haystack behavior even when the model window technically fits.
Resolution: Select relevant context, summarize history, reduce tool outputs, and avoid indiscriminate tool exposure.
Tool outputs and tool catalogs can blow the context window.
Root cause: Long tool outputs, long conversations, and many tool descriptions consume context and force more model decisions.
Resolution: Summarize conversations, choose only relevant context, group tools that always run together, and avoid exposing huge tool catalogs.
WhatsApp creates commerce security and identity challenges.
Root cause: WhatsApp is widely used for commerce in Brazil, but messaging channels are exposed to scams and standalone identity uncertainty.
Resolution: Tie WhatsApp to app-based validation and require authentication when the user or phone number is unknown.
Evaluation
iFood combines production-trace evals, regular tests, natural-language scenario definitions, and an evaluation agent that simulates users against the endpoint and UI. Scenario evals also test guardrail evasion and support prompt deflation by turning edge cases into regression tests before removing rules.
Metrics: P95 latency reduced from about 30 seconds to about 10 seconds · scenario pass/fail behavior against endpoint responses · UI behavior checks · guardrail evasion attempts over multiple turns · production trace evaluations
3 supporting quotes
Outcomes
- ISO is live to millions of Brazilian users on the app and WhatsApp.
- P95 latency improved from about 30 seconds to about 10 seconds.
- The agent supports personalized search, coupons, cart actions, and payment experiments.
- The team established scenario-based evaluation and prompt-deflation practices for production iteration.
- The architecture supports proactive engagement when users become inactive or need suggestions.
iFood operates at national e-commerce scale: 160 million monthly orders, 55 million monthly users, 400,000 delivery drivers, 1,500 cities, 150 proprietary AI models, 14 billion real-time predictions per month, and a 16-petabyte data lake.