ExtraBrain Interview Questions
Agentic AI Engineer Interview Questions: Tool Calling, MCP and Agent Loops
Short answer
Agentic AI interviews test whether you can make an unreliable model act safely. Expect questions on when to use a workflow instead of an agent, how a tool-calling loop works, how to design tool schemas, what MCP standardizes, how to stop runaway loops, how to defend against prompt injection from tool results, and how to evaluate an agent end to end. Strong answers name the guardrail, the stop condition and the metric.
Agentic AI interview questions on agent loops, tool schemas, MCP, prompt injection, context and evals, with answer outlines and a tested agent loop.
Agent questions have moved from “what is an agent?” to “here is a transcript where the agent refunded the wrong order; walk me through what you’d change.” Interviewers want to hear about loop control, tool contracts and permissions, because that is where agents fail in production.
Our AI agent engineer interview prep guide covers how to frame a design round. This page is the companion question bank: the specific questions that come up, with answer outlines, a tested agent loop and what the current MCP specification says.
Fundamentals
When would you build a workflow instead of an agent?
Use Anthropic’s definitions from Building effective agents: workflows run models and tools through predefined code paths, while agents decide their own steps and tool use. Agents trade latency and cost for flexibility, so they fit open-ended tasks where you can’t predict the number of steps. If the path is known, a workflow is cheaper, faster and easier to test. Say you would start with the simplest version and add autonomy only when an eval shows it helps.
| Pattern | Use it when | Interview example |
|---|---|---|
| Prompt chaining | Steps are fixed and checkable | Draft, check, then translate |
| Routing | Inputs fall into distinct types | Billing vs technical tickets |
| Parallelization | Subtasks are independent | Several reviewers vote on one answer |
| Orchestrator-workers | Subtasks can’t be known in advance | Multi-file code change |
| Evaluator-optimizer | Clear criteria for “better” | Iterating on a translation |
Walk me through a tool-calling loop.
OpenAI’s function calling guide describes five steps: send the request with tool definitions, receive a function call, run it in your code, send the output back matched by call_id, and get a final answer or more calls. Mention that the model can request several calls in one turn, and that tool_choice can be auto, required, a forced function, allowed_tools or none.
Then show you can write the loop yourself, with the guardrails the interviewer is listening for:
import json
def get_order(order_id): return {"order_id": order_id, "status": "shipped"}
def refund_order(order_id, amount): return {"order_id": order_id, "refunded": amount}
TOOLS = { "get_order": {"fn": get_order, "required": {"order_id"}, "risky": False}, "refund_order": {"fn": refund_order, "required": {"order_id", "amount"}, "risky": True},}
def run_agent(model, user_message, approve, max_steps=6): messages = [{"role": "user", "content": user_message}] seen_calls = set() for _ in range(max_steps): reply = model(messages) if reply["type"] == "final": return reply["text"] messages.append({"role": "assistant", "tool_call": reply}) # the call must precede its result name, args = reply["name"], reply["arguments"] call_key = (name, json.dumps(args, sort_keys=True)) tool = TOOLS.get(name) if tool is None: result = {"error": f"Unknown tool {name}. Available: {sorted(TOOLS)}"} elif missing := tool["required"] - args.keys(): result = {"error": f"Missing arguments {sorted(missing)}. Call {name} again with them."} elif call_key in seen_calls: return "Stopped: the agent repeated an identical call. Escalating to a human." elif tool["risky"] and not approve(name, args): result = {"error": "A human declined this action. Do not retry it."} else: seen_calls.add(call_key) result = tool["fn"](**args) messages.append({"role": "tool", "call_id": reply["id"], "content": json.dumps(result)}) return "Stopped: step limit reached. Escalating to a human."
script = iter([ # a scripted stand-in for the model, so the loop runs without an API {"type": "tool_call", "id": "call_1", "name": "get_order", "arguments": {}}, {"type": "tool_call", "id": "call_2", "name": "get_order", "arguments": {"order_id": "A17"}}, {"type": "tool_call", "id": "call_3", "name": "refund_order", "arguments": {"order_id": "A17", "amount": 40}}, {"type": "final", "text": "Order A17 has shipped. The refund needs approval, so I passed it to a human."},])
def fake_model(messages): if messages[-1]["role"] == "tool": print("tool ->", messages[-1]["content"]) return next(script)
print(run_agent(fake_model, "Refund order A17", approve=lambda name, args: False))Running it prints what the model sees after each tool call, then the final answer:
tool -> {"error": "Missing arguments ['order_id']. Call get_order again with them."}tool -> {"order_id": "A17", "status": "shipped"}tool -> {"error": "A human declined this action. Do not retry it."}Order A17 has shipped. The refund needs approval, so I passed it to a human.Walk through the design choices: the model’s call is recorded before its result, and each result carries the call_id it answers, as real APIs require; errors go back to the model as tool results it can act on; risky tools need approval; identical repeated calls end the run; and a step limit guarantees termination. The message format is simplified, so map it onto your provider’s schema.
Tool design questions
What makes a good tool definition?
With strict mode, OpenAI requires additionalProperties: false on every object and every property listed in required, with optional fields expressed by allowing null. Anthropic’s post on writing tools for agents adds the design side: build a few targeted tools instead of wrapping every endpoint, namespace related tools, return readable context instead of opaque IDs, paginate and truncate large results, and write error messages that tell the agent how to fix the call. Unambiguous parameter names such as user_id instead of user reduce wrong calls. Anthropic’s agents post also gives a mistake-proofing example: requiring absolute file paths removed a whole class of relative-path errors.
What is MCP, and what changed in 2026?
The Model Context Protocol specification defines hosts (the LLM application), clients (connectors inside the host) and servers (services that provide context), talking JSON-RPC 2.0. Servers offer resources, prompts and tools; clients can offer elicitation, where a server asks the user for more information. According to the versioning page, the current revision is 2026-07-28. It uses stateless, self-contained requests with per-request capability negotiation and an optional server/discover call, while revisions up to 2025-11-25 used an initialization handshake. Name the security rules too: tool descriptions and annotations are untrusted unless they come from a trusted server, and hosts must get explicit user consent before invoking a tool.
Safety questions
How do you defend an agent against prompt injection?
Start with the threat. OWASP’s LLM01 separates direct injection from indirect injection, where instructions hide in content the model reads, such as a web page, an email or a tool result. Agents raise the stakes because they act. The mitigations OWASP lists map cleanly onto agent design: least privilege for tools, human approval for high-risk actions, clearly labeled untrusted content, deterministic validation of outputs and regular adversarial testing. OWASP also says no method is foolproof, so the goal is limiting damage. Excessive agency (LLM06) is the related risk: a tool that can delete when the task only needs read access.
How do you stop an agent from looping forever?
Anthropic recommends stopping conditions such as a maximum number of iterations. Add budgets for tokens, wall-clock time and cost, detect repeated identical calls, and define what happens at the limit: return partial results and escalate to a person. Interviewers like hearing that the stop path is tested, not just written.
Context and memory questions
How do you manage context on a long task?
Anthropic’s context engineering post describes context rot: recall degrades as the window fills, so aim for the smallest set of high-signal tokens. Techniques to name: just-in-time retrieval (keep file paths or queries and load content when needed), compaction (summarize and restart the window, clearing old tool outputs first), structured notes stored outside the context, and sub-agents that work in clean contexts and return condensed summaries.
When is a multi-agent design worth it?
When subtasks are independent or unpredictable enough that an orchestrator should hand them out, and each worker benefits from a clean context. The costs are more tokens, more latency and harder debugging, so justify it with an eval result rather than with the architecture diagram.
Evaluation questions
How do you evaluate an agent?
Test end-to-end tasks in a sandbox and check the final state programmatically: was the right order refunded, did the right file change? Track task success, tool-call errors, steps and cost per task, and read transcripts where the agent got confused. Anthropic’s tools post recommends held-out test sets so you don’t overfit tool descriptions to your eval. If asked about origins, the ReAct paper introduced interleaving reasoning traces with actions, the pattern most agent loops still follow.
Rehearse with real follow-ups
Agent rounds are conversational, and the follow-ups (“what if the tool times out mid-refund?”) decide the outcome. Practice with a partner or record a mock session in ExtraBrain and review the transcript for places where you skipped the stop condition or the permission check. Retrieval often comes up inside agent design, so our RAG engineer interview questions are worth a pass too. Follow each company’s stated rules on AI use during the interview itself; ExtraBrain is meant for preparation and your own notes.
FAQ
Do I need to know LangGraph or another framework?
Know one well enough to discuss it, but expect questions about the underlying loop. Anthropic’s agents post suggests starting with model APIs directly because frameworks can hide the prompts and responses you need to debug.
Will I have to write code in an agent interview?
Often a small loop like the one above, or a tool schema. System design rounds focus on guardrails, state and evaluation.
How is MCP different from function calling?
Function calling is how one model API requests a tool call. MCP is a protocol that lets any compliant host discover and use tools, resources and prompts from external servers.
What is the biggest red flag in an agent design answer?
Giving the agent broad write access with no approval step, no budget and no way to tell whether it succeeded.
Sources (checked November 21, 2026)
- Anthropic, Building effective agents
- OpenAI, Function calling guide
- Anthropic, Writing effective tools for agents
- Model Context Protocol specification, revision 2026-07-28
- Model Context Protocol versioning
- OWASP LLM01:2025 Prompt Injection
- Anthropic, Effective context engineering for AI agents
- Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models