Design a RAG-Based Agent System
Design a system in which an LLM agent answers questions and completes tasks over a company's own knowledge and tools. It retrieves relevant documents, decides when to call tools such as search, a database query or a ticketing API, and returns an answer with its sources.
Cover the document ingestion and retrieval path, the agent loop and how its state is managed across steps and turns, and long conversations that outgrow the context window. Two follow-ups are standard: a tool call fails or returns nonsense in production, how do you trace and debug it; and how do you evaluate the agent, including when precision, recall or F1 is the right measure.
Hints
Hint 1
Split it into an offline path, documents to index, and an online path, question to answer. Most quality problems are in the offline path and the retrieval step.
Hint 2
Treat every tool as a typed function with a schema, a timeout and an idempotency rule. The model proposes a call; your code validates and executes it.
Hint 3
You cannot debug what you did not record. Each step of the loop should emit a span with its inputs, outputs, latency and token counts.
Asked at
Sign in to talk to the interviewer — ask what's in scope, what scale to design for, or for a nudge when you're stuck. Conversations save to your account.
Sign in to use the assistant — ask what the problem means, get a hint when you're stuck, or have your current work reviewed. Conversations save to your account.