TechSchool
Home / Interview questions / AI engineering / Agents and Tool Use

Agents and Tool Use Interview Questions

Short answers to 12 agents and tool use interview questions.

Questions and answers (12)

Answers are written in plain English and reviewed for technical accuracy. Each answer states the point first, then the reason.

1. Explain the ReAct pattern and what it solves over chain-of-thought alone.

ReAct is a loop of thought, action and observation. The model writes a short reasoning step, calls a tool, reads the result, and repeats. Chain-of-thought alone reasons without new facts, so it can invent wrong steps. ReAct grounds each step in real tool output and corrects the plan.

2. How do you handle tool-call errors, timeouts and retries in an agentic loop?

Wrap every tool call in a timeout, a retry budget and a typed error result. Return the error to the model as an observation so it can change the plan. Use exponential backoff and stop after 3 attempts. Cap total loop steps to avoid infinite retries.

for attempt in range(3):
    try:
        return call_tool(name, args, timeout=10)
    except ToolError as e:
        last = e
return {"error": str(last), "retryable": False}

3. What is the difference between structured output and function calling?

Structured output forces the reply text to match a schema. Function calling lets the model request a named tool with typed arguments. Structured output shapes one answer, while function calling starts an action. Use function calling when the model must act, and structured output when it must return data.

4. What is MCP (Model Context Protocol) and how does it differ from traditional function calling?

MCP is an open protocol that connects a model host to external tools and data through servers. Traditional function calling defines tools inside one request, so each app wires its own code. MCP separates the server from the host, so one server serves many clients. The tradeoff is an extra network hop and a new trust boundary.

5. How many tools is too many? How do you design tool schemas an LLM can actually use correctly?

Tool count is too high when the model picks the wrong tool or misses a needed one. Keep the active set near 10 to 20 tools and group the rest behind a router. Give each tool a short name, a clear description and typed parameters with enums. Add one example call per tool and test selection with a fixed eval set.

6. How does multi-agent orchestration work, and when does it break down?

Multi-agent orchestration gives each agent a role and a shared task, and a planner or manager routes the work. It breaks down when agents share unclear state, loop on handoffs, or pass lossy summaries. Each extra hop adds latency and token cost. Use one agent with tools until a clear split in skills or context appears.

7. Design memory for a long-running agent: what do you store, where, and how do you retrieve it?

Store three layers: a short working context, a summary log of past steps, and a vector store of facts. Keep the working context small and put durable facts in a database with timestamps. Retrieve by task similarity plus recency, and re-rank the top 20 hits to 5. Write a new summary every 10 turns to bound context growth.

8. How does an agent decide when to call a tool versus answer from its own knowledge?

The agent calls a tool when the answer needs fresh, private or exact data, and answers directly for stable general knowledge. Put this rule in the system prompt and give the model a no-tool option. Add a confidence check that routes uncertain cases to search. Measure the tool-call rate on an eval set to tune the threshold.

9. What makes an agent loop terminate correctly? How do you bound cost and steps?

A correct agent loop stops on an explicit done signal or a hard step limit, not on model confidence. Set a maximum step count and a token or cost budget, and stop when either one is reached. Return a clear failure result when a limit fires so the caller can handle it. A common starting point is 20 steps and a per-run cost cap.

for step in range(MAX_STEPS):
    action = model.next_action(state)
    if action.kind == "done":
        return action.result
    state = run(action)
return {"status": "limit_reached"}

10. How do you make an agent's actions reversible, or at least auditable, in a production system?

Make each action a recorded event with an inverse or a snapshot, so you can undo it or replay it. Write the event to an append-only log before the action runs, and store the input, output, and actor. The tradeoff is extra storage and latency for each step. Keep the log immutable and add a request id to every event.

log.append({
    "id": req_id, "actor": agent_id,
    "action": name, "input": args,
    "inverse": undo_spec, "ts": now()
})

11. Design human-in-the-loop approval for an agent that takes consequential actions.

Route each consequential action to a human approval gate before it runs. The agent proposes the action with a plain summary and the expected effect, and the gate blocks until a person approves or rejects. Log the approver, the decision, and the reason for audit. Set a timeout so a pending action cannot block the run forever.

proposal = agent.propose(action)
if action.is_consequential:
    ok = approval_gate.wait(proposal, timeout=3600)
    if not ok:
        return {"status": "rejected"}
run(action)

12. Your agent drifts after a long run and confidently works on the wrong thing. Diagnose it.

The agent likely lost its goal state, so it keeps optimizing a stale or partial context. Check the context window for truncation, and check that the goal and the latest results stay in the prompt. Long runs also grow the KV cache and the token count, and old steps can push the goal out. Add a goal restatement and a periodic state summary to each step.

state = summarize(state)
prompt = [goal_block, state, recent_steps]
assert goal_block in prompt
Related lessons
Ai agent intro Ai agent function calling Agent architecture Ai agent intro Ai transformer