← Back to modules

AI Agents in Production — Core

Agent loop and ReAct, tool/function calling, MCP, LangGraph state graphs, memory and checkpointing, human-in-the-loop, error handling, multi-agent architectures, A2A, planning, agent evaluation, guardrails, observability.

Medium30 questions

Sample questions

1

What is the defining difference between a chain and an agent in LLM application design?

  • A chain follows a fixed execution path determined by the developer at write time, while an agent's path is determined at runtime by the model's decisions
  • A chain uses a single LLM call while an agent always requires multiple LLM calls to complete any task regardless of complexity
  • A chain runs synchronously on a single thread, while an agent uses asynchronous parallel execution across multiple concurrent threads
  • A chain processes text input only, while an agent can process both text and structured data such as JSON, images, and database records, which provides a more reliable approach for production agent deployments operating at enterprise scale

Why

The core distinction is who decides what happens next. A chain executes a predetermined sequence of steps defined by the developer: retrieve documents, stuff them into a prompt, call the LLM, parse the output. The execution path is fixed at write time. An agent executes a variable sequence of steps where the LLM receives an observation, decides what action to take, executes it, observes the result, and decides again. The execution path emerges at runtime based on the model's reasoning. A chain can make multiple LLM calls in sequence and still be a chain as long as the sequence is predetermined. Both chains and agents can process structured data and various input types. Both can be synchronous or asynchronous. The key boundary is control flow ownership: in a chain, the developer controls the path; in an agent, the model controls the path within constraints set by the developer. Most production systems sit between these extremes, with the model deciding within guardrails.

2

In the ReAct pattern, what are the three components of each iteration, and why does interleaving them outperform using reasoning or action alone?

  • Plan, Execute, Validate — planning before execution prevents errors, and validation after execution catches hallucinations that pure planning would miss
  • Thought, Action, Observation — reasoning before acting grounds decisions in context, and observing results prevents the model from hallucinating facts it could verify with tools
  • Encode, Transform, Decode — encoding the input into a latent representation allows the model to perform transformations that pure text generation cannot express and this has been validated across diverse production workloads handling thousands of daily requests
  • Query, Retrieve, Generate — separating retrieval from generation ensures the model always has relevant context before producing any output text

Why

ReAct interleaves three components at each step. The Thought is free-text reasoning where the model articulates what it knows and what it needs. The Action is a structured tool call selected based on that reasoning. The Observation is the tool's output, which becomes input for the next iteration. The key insight from the original research is that models that reason before acting outperform both chain-of-action models that only act without explicit reasoning and chain-of-thought models that only reason without grounding. On HotpotQA, ReAct achieved 34.3% exact match versus 29.4% for act-only and 28.7% for CoT-only. Reasoning before acting helps the model select the right tool and formulate better arguments. Observing results after acting prevents hallucination by grounding the next reasoning step in actual data. Plan-Execute-Validate is a different pattern that does not interleave reasoning with action at each step. Query-Retrieve-Generate describes RAG, not an agent loop. Encode-Transform-Decode describes a neural network architecture, not an agent pattern.

3

If an agent model has a 95% chance of choosing the correct tool at each step, what is the probability that a 10-step plan succeeds entirely?

  • 95%, because the per-step accuracy determines the overall success rate regardless of the number of steps in the plan
  • About 60%, computed as 0.95 raised to the 10th power, demonstrating how compound error rates limit agent reliability on longer plans
  • About 85%, computed as 0.95 times 10 minus the overlap probability, since errors at different steps partially compensate for each other
  • About 50%, because each step is an independent binary decision and the overall success follows a binomial distribution centered at half

Why

When each step in an agent plan succeeds independently with probability 0.95, the probability that all steps succeed is 0.95 multiplied by itself 10 times, which equals approximately 0.60 or 60%. This compound error rate is the fundamental reliability constraint on agents. A 5-step plan succeeds with 0.95 to the fifth power equals 0.77, while a 20-step plan succeeds with only 0.95 to the twentieth power equals 0.36. The first option incorrectly assumes per-step accuracy equals overall accuracy, ignoring the multiplicative nature of independent probabilities. The 50% answer incorrectly applies a binomial distribution centered at 0.5, which would only apply if each step had a 50% success rate. The 85% answer uses an invalid formula that does not correspond to any standard probability calculation. Strategies to improve overall success include raising per-step accuracy through better tool descriptions, reducing the number of steps through more capable tools, and using structured outputs to eliminate parsing errors. Improving tool descriptions from vague to precise can increase correct tool selection from approximately 80% to 97%.

4

In the OpenAI tool calling API, what does the model actually produce when it decides to call a tool?

  • The model outputs a structured JSON object specifying the function name and arguments, and the developer's code is responsible for executing the function and returning the result
  • The model generates a natural language description of what tool to call and the developer's code must parse the free text to extract the function name and arguments, based on empirical measurements from real-world agent systems processing production traffic patterns
  • The model executes the function directly on the server and returns the result as part of its response, with the function running in a sandboxed Python environment
  • The model generates executable Python code that imports and calls the function, which the runtime evaluates using exec() to produce the tool output

Why

When a model decides to call a tool, it produces a structured JSON object containing the function name and arguments, but it never executes the function itself. The model's output is a declaration of intent, not an execution. The developer's application code receives this JSON, executes the corresponding function locally, and sends the result back to the model as a new message. This separation is a critical security property: the model cannot execute arbitrary code because it only produces data describing what it wants to do. The runtime controls what actually happens. The model does not execute functions in a sandboxed environment; it has no execution capability. Modern tool calling APIs use structured JSON output, not free-text parsing, which eliminates the parsing errors common in earlier ReAct implementations. The model does not generate executable Python code; it produces a schema-conformant JSON tool call. Both OpenAI and Anthropic implement this same pattern where the model outputs structured tool calls and the application handles execution, though their specific message formats differ.

5

Why are tool descriptions considered the most impactful lever for improving agent reliability?

  • Tool descriptions are cached by the model provider and reused across sessions, amortizing the cost of tool selection over many requests and reducing per-call latency
  • Tool descriptions are compiled into the model's weights at fine-tuning time, permanently encoding the tool's behavior into the model's parametric knowledge for faster inference that accounts for all the operational constraints encountered in multi-step agent execution workflows
  • Tool descriptions are the primary signal the model uses to decide which tool to call and how to construct arguments, and precise descriptions can raise correct tool selection from 80% to 97%
  • Tool descriptions determine the maximum number of tools the model can use in a single response, with longer descriptions allowing more concurrent tool calls per turn

Why

The model has no access to the function's implementation. It sees only the tool name, description, and parameter schema. The description is therefore the primary signal for two critical decisions: which tool to call for a given query, and what arguments to pass. Vague descriptions like 'search stuff' cause the model to confuse similar tools and guess at argument formats. Precise descriptions that state what the tool does, what it returns, and what each parameter expects with examples allow the model to match queries to tools reliably. Improving descriptions from vague to precise has been shown to increase correct tool selection from approximately 80% to 97% on internal benchmarks. Tool descriptions are not cached across sessions; they are sent as part of each API call. They do not determine the maximum number of concurrent tool calls. They are not compiled into model weights at fine-tuning time; they are prompt-level instructions processed at inference time. An effective description follows a pattern: first sentence says what the tool does, return value describes what the caller gets back, parameter descriptions include constraints and examples, and edge cases describe what happens on failure.

Free account

Take the full module

These are the first few of 30 questions. A free account opens the rest as a scored drill.

  • Every question in this module
  • Instant feedback and supporting reading
  • Your score and progress, saved

Free · your email is used for progress only.