EasyDeepLearn
LLMs & GenAI · section 16 of 18

Agents & tool use

10 interview questions on agents & tool use, each answered in full. Free to read, no account needed.

Describe a basic ReAct / agent loop.

medium
  • Loop: (1) LLM receives system prompt + user goal + tool schemas + previous steps.
  • (2) LLM decides between: emit a toolcall\mathrm{tool}_{\mathrm{call}} (name + arguments), or emit a final response.
  • (3) If toolcall\mathrm{tool}_{\mathrm{call}}: execute the tool (calculator, search, code exec, HTTP fetch), append result to context, go back to step 1.
  • (4) Terminate when LLM emits a final response, or on maxsteps  /  maxcost  /  timeout\operatorname{max}_{\mathrm{steps}}\; / \;\operatorname{max}_{\mathrm{cost}}\; / \;\mathrm{timeout}.
  • ReAct (Yao 2022) formalized 'reason + act' interleaving.
  • Modern implementations: OpenAI tool calling, LangGraph, LlamaIndex agents, CrewAI.
#agents#tools#function-callingPermalink & quiz →

How is 'memory' typically implemented in agents?

medium
  • (1) Short-term: full conversation in the context window (up to model's context limit).
  • (2) Summarized memory: periodically summarize old turns to compress.
  • (3) Long-term / episodic: store past traces + facts in a vector DB, retrieve relevant ones per new query (RAG-over-memory).
  • (4) Structured memory: extract entities/facts into a database (name, address, preferences) and query it.
  • (5) Reflection memory: agent writes 'lessons learned' after each task and retrieves them next time.
  • Modern frameworks (LangGraph, LlamaIndex, Mem0) provide these primitives.

When do multi-agent systems beat single-agent?

hard
  • (1) Specialized roles: a 'coder' agent + 'reviewer' agent produce better code than one agent doing both — parallel expertise.
  • (2) Adversarial verification: 'writer' vs 'critic' loops catch errors a single pass misses.
  • (3) Divide-and-conquer: distribute independent subtasks across agents.
  • (4) Domain isolation: each agent has domain-specific tools + system prompt.
  • Costs: more tokens, coordination complexity, potential message-passing loops.
  • Frameworks: CrewAI, AutoGen, LangGraph, MetaGPT.
  • Often overhyped — a well-prompted single agent handles most tasks.

How does a coding agent (SWE-agent, Aider, Cursor) actually work?

hard
  • (1) Repository indexing: chunked embeddings + symbol maps + git blame for the codebase.
  • (2) Task decomposition: LLM parses the user goal, identifies affected files.
  • (3) Tool set: readfile\mathrm{read}_{\mathrm{file}}, writefile\mathrm{write}_{\mathrm{file}}, runtests\mathrm{run}_{\mathrm{tests}}, gitdiff\mathrm{git}_{\mathrm{diff}}, searchcode\mathrm{search}_{\mathrm{code}}.
  • (4) Iteration loop: LLM proposes edits, runs tests, reads errors, refines.
  • (5) Guardrails: cap edits per turn, require confirmation for destructive ops, sandbox execution.
  • Best-in-class: Cursor Agent, Devin, SWE-agent, Aider, Claude Code.
  • Evaluated on SWE-bench Verified (~50-70% for top systems in 2026).

What's hard about web-navigation agents?

hard
  • (1) Grounding: mapping the DOM / screenshot to actionable elements is fragile — CSS selectors break, elements are dynamic, invisible overlays.
  • (2) Latency: page loads add seconds per step.
  • (3) Auth / captchas: most sites need cookies, MFA, or human verification.
  • (4) State: sessions expire mid-agent.
  • (5) Cost: full-page screenshots are expensive input tokens.
  • Benchmarks: WebArena, VisualWebArena, Mind2Web.
  • Successful agents (Anthropic Computer Use, browser-use, OpenAI Operator) combine vision + accessibility trees + long-context reasoning.
#agents#multimodalPermalink & quiz →

What does an ideal function-calling schema look like?

medium
  • (1) Descriptive name (verbobject)(\mathrm{verb}_{\mathrm{object}}): searchorders\mathrm{search}_{\mathrm{orders}}, not f1.
  • (2) Human-readable description explaining when to use it.
  • (3) JSON Schema for parameters with required fields, type, description per field, enum for constrained values, format for dates/emails.
  • (4) Examples in the description if the signature is subtle.
  • (5) Return schema: describe what the tool returns so the LLM can interpret results.
  • (6) Keep the tool set small (~5-15) — larger sets need retrieval-based tool selection.
#function-calling#agents#toolsPermalink & quiz →

How do parallel tool calls work?

medium
  • Modern APIs (OpenAI, Anthropic, Gemini) allow the model to emit multiple tool calls in a single assistant turn — e.g., 'call searchflights(NYCLA,  12/15)\mathrm{search}_{\mathrm{flights}}(\mathrm{NYC} - \mathrm{LA}, \;12 / 15) AND searchhotels(LA,  12/1517)\mathrm{search}_{\mathrm{hotels}}(\mathrm{LA}, \;12 / 15 - 17)'.
  • Runtime executes them concurrently, waits for both, appends both results, then re-invokes the LLM.
  • Reduces latency for independent tools (network parallelism).
  • Model has to be trained / prompted to emit them together — some models default to sequential.
  • Trade-off: harder to debug + partial failures need explicit handling.
#function-calling#agents#latencyPermalink & quiz →

What is the Model Context Protocol (MCP)?

medium
  • MCP (Anthropic, 2024) is an open protocol that standardizes how LLM applications connect to external data sources and tools.
  • An 'MCP server' exposes resources (files, database rows, docs) and tools (function calls) via a JSON-RPC interface; an 'MCP client' (Claude Desktop, Cursor, etc.) can discover and invoke them.
  • Solves the N×M integration problem: instead of every LLM app wiring up every data source directly, both sides speak MCP.
  • Growing ecosystem — official servers for GitHub, filesystem, Postgres, Slack, and hundreds of community servers.
#agents#tools#productionPermalink & quiz →

How do you keep agent costs bounded?

medium
  • (1) Maxsteps\mathrm{Max}_{\mathrm{steps}} per task (10-50 typical).
  • (2) Maxtokens\mathrm{Max}_{\mathrm{tokens}} per turn to prevent long ramblings.
  • (3) Maxcost\mathrm{Max}_{\mathrm{cost}} per task with a hard circuit-breaker.
  • (4) Per-tool budgets ('search may be called at most 5 times').
  • (5) Model routing: use cheap model for tool selection, frontier model for final answer.
  • (6) Prompt caching for the system prompt + tools schema — huge win for repetitive workflows.
  • (7) Cheaper models for internal reasoning steps, frontier for final synthesis.
  • Log cost per trace to identify runaway prompts.
#agents#cost#productionPermalink & quiz →

When should you not build an agent?

medium
  • When the task has a known, fixed sequence of steps.
  • A deterministic pipeline that calls the model at two specific points is cheaper, faster, easier to test and far easier to debug than an agent deciding what to do each turn.
  • Agents earn their cost when the number and order of steps genuinely depend on intermediate results, such as open-ended research or multi-step debugging.
  • They are a poor fit where errors are expensive and irreversible, where latency budgets are tight, or where you cannot afford unbounded token spend.
  • The honest default is a workflow, escalating to an agent only when the branching is real.
#agents#productionPermalink & quiz →

Practise LLMs & GenAI