Before Building AI Agents Watch This (Deep Agent Expertise)
Nishikant Dhanuka from Prosus Group shares practical lessons on building effective AI agents for e-commerce and productivity. He covers why context engineering is more crucial than prompt tweaking, how to build a modern search pipeline, the failures of pure-chat interfaces, and why a robust evaluation framework is the real competitive advantage.
Building AI agents that are genuinely useful requires moving beyond surface-level tweaks like system prompts and model selection. The real differentiators lie in the unsexy, foundational work of context engineering, reinventing search, designing intuitive user interfaces, and implementing rigorous evaluation frameworks.
The Primacy of Context Engineering
While much of the public discourse focuses on prompt engineering, the most significant gains come from “context engineering.” This is analogous to data engineering in traditional data science—it’s the foundational work that ensures the model has the right information to produce a valuable output. An agent with rich context will always outperform a more advanced agent without it.
Context is composed of four key elements:
- System Prompt: The baseline instructions for the agent.
- User Message: The immediate query from the user.
- Enterprise Context: This is the most challenging and crucial part. It involves pulling in real-time, often messy, and scattered enterprise data. For an e-commerce agent, this includes product availability, store opening hours, active promotions, and accepted payment methods. This is a significant data engineering challenge, requiring pipelines that can fetch and format this data on the fly to inform the agent’s response.
- User History (Memory): To create a “sticky” product that users value, the agent must know them. This context includes their past purchases, browsing history, and preferences. A simple but effective cold-start strategy is to leverage existing user data from the core application (e.g., past food orders) before building more complex memory systems.
Reinventing Search for Conversational AI
For e-commerce agents, search is the starting point of the user journey. If it fails, the user loses trust and drops off. Conversational queries are often broad, ambiguous, and fuzzy (e.g., “help me furnish my house,” “I want a romantic dinner”), which traditional keyword search cannot handle.
While semantic search helps, it also has limitations. A modern, effective search pipeline for an AI agent involves a multi-step process:
- Query Understanding: An LLM is used before the search to understand, expand, and personalize the user’s fuzzy query. For “romantic dinner,” it might break it down into concepts like specific cuisines, ambiance, or items like wine and dessert.
- Hybrid Search: The expanded query is then run through a combination of traditional keyword search (which still works well for specific terms like “burger”) and semantic search for conceptual matches.
- Re-ranking: An LLM is used after the search to re-rank the initial results. It takes the candidate items, the original user query, and the user’s context (history, preferences) to present the most relevant options.
UI/UX: The Failure of Pure Chat
A common mistake is assuming a purely conversational, chat-based interface is the ultimate solution. A/B tests often show that forcing users into a new, chat-only paradigm for tasks like shopping results in terrible conversion rates.
Key learnings from these failures include:
- User Adoption Lags Technology: The technology is capable, but users are accustomed to traditional UIs. A new interface introduces friction and will only be adopted if it provides an immediate and massive leap in value.
- The “Blank Screen” Problem: A simple chat box is not inviting. It doesn’t guide the user or showcase the agent’s capabilities. Effective onboarding through tooltips, suggested queries, and guided journeys is essential.
- The Hybrid Solution: Generative UI: The most promising interface is a mix of chat and traditional UI. In this model, the agent’s response is not just text but also dynamic, “generative” UI components like product carousels, comparison tables, or suggestion boxes. The agent decides which UI component to render based on the conversational context.
- Contextual Micro-Agents: Instead of a single, do-it-all chatbot, a more effective approach is to have contextual agents that appear at the right moment to help with a specific micro-task. For example, when a user is viewing a product, an agent could pop up and offer to compare it with a similar item.
Evals: The True Competitive Moat
A robust evaluation framework is the real moat for an AI product, more so than a secret system prompt. Evals provide a systematic way to measure quality, ensure the agent is production-ready, and monitor for degradation over time.
Best practices for building an effective eval system include:
- Start Early with Synthetic Data: Don’t wait for real user traffic to build your evals. Begin by having the team interact with the agent, or use an LLM to generate a synthetic dataset of queries and personas.
- Prioritize Deterministic Metrics: Before jumping to “LLM as a judge,” look for low-hanging fruit. Use deterministic business metrics as signals of a successful interaction. For example, if a conversation resulted in a user adding an item to their cart, it was likely a positive one.
- Follow a Hierarchy: Start with high-level, business-centric questions for your evals: Did the agent satisfy the user’s intent? Did the conversation move towards a conversion? This 80/20 approach provides the most actionable insights. Only after mastering this level should you drill down into more granular technical metrics like tool-calling accuracy.
- Host “Labeling Parties”: Regularly bring together a cross-functional team (including business stakeholders) to manually label real conversations. This collaborative process is invaluable for identifying where the agent—and the automated “LLM as a judge”—is failing.
- Iterate on Your Judge: Use the insights from labeling parties to improve your “LLM as a judge” prompt. Provide it with few-shot examples of discrepancies between human and AI labels to calibrate its judgment and make it a more reliable proxy for quality.
- Build Custom Annotation Tools: To make labeling parties effective, create simple, custom UI tools for annotation. A business user can’t be expected to parse complex JSON traces. A visual tool that shows the conversation alongside the products that were displayed is far more effective for gathering high-quality feedback.