Day 1
What is an AI Agent?
Understand agents, their core components, and how they differ from traditional software.
An AI agent is an autonomous system that perceives its environment, reasons about goals, and takes actions to achieve them. Unlike traditional programs that follow fixed paths, agents use LLM-driven loops to decide what to do next based on current context and past observations.
Today’s Lesson
Read
Agent Loop
Bounded ReAct and reflection loops that stop cleanly.
Practice
Apply what you learned by solving these coding problems.
Review
Test yourself with these interview-style questions.
1Describe the decision process for determining whether a user request needs an agent. Walk through the signals you would check and how you would route between a simple LLM call, a retrieval call, and a full agent loop. Give three example inputs and explain why each maps to a different path.+
The decision checks three signals: does the request require external data (needs retrieval or tool), multi-step reasoning (needs agent loop), or user-specific context (needs tools). Example: "Capital of France?" is a static fact — simple LLM call suffices. "Latest Q4 revenue" needs retrieval — RAG path. "Book a flight to London on Friday" requires tool calls, validation, and confirmation — full agent loop. Routing this upfront saves cost and latency by avoiding unnecessary loop overhead for simple queries.
Read full answer
The first architectural decision in any agent system is when to engage the full loop. I use a pre-routing classifier that checks three dimensions: data freshness, action requirement, and complexity. Static knowledge questions like "What is the capital of France?" go directly to a base LLM call with no tools — cheapest and fastest. Questions that need current data, like "What is the latest Python version?", go through a retrieval-augmented path: embed query, fetch docs, generate grounded answer — still no agent loop. Questions requiring action, like "Send an email to Alice confirming the meeting," enter the full agent loop with tool dispatch and multi-step reasoning. The classifier itself can be heuristic-based (keyword patterns) or a small LM call. This routing is critical because engaging the agent loop for a simple Q&A wastes 5-10x the tokens and latency. In production I measure routing accuracy as a key metric — misrouting a complex request to the simple path causes failures, while misrouting a simple request to the agent loop wastes money.
2A junior engineer says "a chatbot is just a simple agent." Identify three specific differences between a chatbot and an AI agent that make this statement incorrect. For each difference, describe a concrete scenario where the distinction matters.+
A chatbot is reactive and stateless, producing a single response per input, while an agent maintains state, reasons about goals, and iterates through tool calls. First, agents have persistent state across loop iterations — a chatbot cannot remember what it did three turns ago unless the full history is in the prompt. Second, agents autonomously decide which tools to call and in what order, while a chatbot only generates text. Third, agents have termination conditions — they stop when a goal is met or a limit is reached — while a chatbot generates one response per invocation without goal awareness.
Read full answer
The statement conflates two fundamentally different architectures. A chatbot is a stateless request-response system: it takes a prompt, generates text, and returns it. An agent is a stateful loop that perceives, reasons about goals, and acts through tools until a termination condition is met. Three distinctions matter most in practice. First, state management: a chatbot has no inherent memory beyond the conversation window, whereas an agent maintains working memory across tool calls and can decide what to keep or discard. In a support scenario, a chatbot would lose the original issue context after two follow-ups, while an agent tracks it. Second, autonomous action: a chatbot only produces text, but an agent calls tools, interprets results, and adapts its plan. If a user says "find the cheapest flight and book it," a chatbot writes a plan but an agent executes it. Third, termination: a chatbot returns after one generation, but an agent loops until a Final Answer is produced or a step limit is hit. This matters for cost control — without termination logic, an agent could loop indefinitely.
3Compare the ReAct loop with a pure chain-of-thought approach. Under what conditions would you choose each? How does the addition of tool execution change the reliability profile of the system?+
Chain-of-thought (CoT) generates reasoning tokens internally without external action, while ReAct interleaves reasoning with tool calls and observations. CoT is appropriate when the task requires only internal reasoning, such as math problems or logic puzzles, and external information is not needed. ReAct is necessary when the agent must query external data, act on the real world, or iteratively refine its understanding through tool feedback. Adding tool execution introduces new failure modes: tool hallucination, argument errors, and observation misinterpretation.
Read full answer
Chain-of-thought and ReAct serve different reliability profiles. CoT is appropriate for self-contained reasoning tasks: math word problems, logic puzzles, code generation, and any task solvable from the model's training data. Its reliability depends only on the model's reasoning quality because there are no external dependencies. CoT's failure modes are limited to reasoning errors, which are easier to isolate. ReAct adds tool execution, which introduces the full stack of distributed-system failure modes: network timeouts, API errors, malformed arguments, rate limits, and unexpected data. However, ReAct can solve problems that CoT cannot — any task requiring real-time data, user-specific information, or physical-world actions. In production, I see ReAct as strictly more powerful but requiring significantly more infrastructure: retry logic, error classification, observation validation, and guardrails. The choice comes down to whether the task requires external information.
Back to 30-Day Agentic AI Interview Prep Path