Tech_Interview_Prep

LLM Agents & Tool Use

Letting an LLM decide which actions to take — calling tools, APIs, or other models — rather than just generating text.

What it is

An LLM agent uses the model not just to generate a final answer, but to decide what to do next — which tool to call, what arguments to pass, and whether the task is complete — often looping through multiple steps of reasoning and action before returning a result to the user.

Core building blocks

  • Tool/function calling: the model is given a set of available tools (each with a name, description, and expected arguments) and outputs a structured call to one of them instead of (or alongside) free-text — the calling application then actually executes the tool and feeds the result back to the model.
  • The reasoning loop: a common pattern (often called ReAct — reason, then act) has the model alternate between reasoning about the current state and choosing an action, observing the tool's result, and repeating until it decides it has enough information to answer.
  • Planning: for multi-step tasks, some agent designs have the model first sketch a plan (a sequence of sub-tasks) before executing, rather than deciding one step at a time — trading more upfront latency for more coherent multi-step behavior.
  • Memory: agents often need to track state across many steps (what's been tried, what's been learned) beyond what fits in a single context window, which is usually handled with an external scratchpad or summarized running state.

Why it matters

  • Tool use is what lets an LLM take real-world actions (query a database, call an API, run code) rather than being limited to whatever it can generate from its own parameters — this is the difference between a chatbot and an agent that can actually get things done.
  • Agentic loops are unreliable in ways plain single-turn generation isn't: a model can pick the wrong tool, loop indefinitely, or compound an early mistake across many steps — which is why agent systems need explicit guardrails (step limits, validation of tool outputs, human-in-the-loop checkpoints for risky actions).
  • Agents are also significantly more expensive and slower than a single LLM call, since each step in the loop is its own model invocation — a real cost/latency tradeoff against a simpler, single-shot approach when the task doesn't actually need multi-step reasoning.
Leads to: LLM Evaluation