ai engineer interview questions

AI Engineer Interview Questions on LLMs, RAG and Agents

Table of Contents

Short answer. These AI engineer interview questions cover 31 questions in 6 groups (LLM basics, RAG, agents and tool use, evaluation, safety and security, system design), each with a short model answer and what the interviewer checks. Two system-design walk-throughs with diagrams and a 2-hour prep plan follow. Answers were checked on November 25, 2026 against Anthropic, OpenAI, the MCP specification (revision 2026-07-28) and the OWASP 2025 LLM Top 10.

Written by the AgileFever editorial team. Facts checked on November 25, 2026 against the official pages of the organizations named in this post. AgileFever sells training for some of the topics covered here, and we say so wherever it applies.

Interviewers for LLM roles rarely ask for definitions. They ask what you would do when retrieval returns the wrong chunk, when an agent loops, or when a tool result contains an instruction. The AI engineer interview questions below follow that pattern. Say each answer aloud in your own words, then compare it with the model answer. If you are still choosing a role, read AI engineer vs ML engineer first. It targets application roles, not research roles that test training maths.

AI engineer interview questions on LLM basics

For how prompts and context differ in practice, see prompt engineering vs context engineering.

Question Model answer Interviewer checks
1. What is a token, and what counts toward the context window? A token is the unit of text a model reads and writes, often part of a word. Per Anthropic, the system prompt, messages, tool results, tool definitions and the model’s output, including thinking, all count toward the window. Tokens drive cost and limits.
2. Does a bigger context window mean you can stop curating context? No. Anthropic’s documentation says accuracy and recall degrade as tokens grow, which it calls context rot. Some models list windows up to 1M tokens, which raises the ceiling, not the quality of a crowded prompt. Cost, latency and recall trade-offs.
3. Why do models hallucinate, and what do you do about it? A model generates likely text, not verified facts. Anthropic recommends allowing “I don’t know”, extracting quotes first, requiring citations and restricting answers to provided documents, and says these reduce but do not eliminate hallucinations. Layered fixes, honest limits.
4. JSON mode, structured outputs or prompting for JSON? OpenAI says both modes return valid JSON but only Structured Outputs enforce your schema. Anthropic offers schema-constrained output too. Neither checks business rules, so validate in code. Valid vs schema-valid vs correct.
5. What is prompt caching and when does it help? It reuses a repeated prompt prefix, ordered tools, system, messages, so put stable content first; changing tool definitions invalidates everything after them.
Version note: Anthropic’s default lifetime is 5 minutes, reads cost 0.1x base input by default (0.05x on some models), minimum length 512 to 4,096 tokens by model.
Prefix order and invalidation.

RAG questions

RAG is the most tested topic among AI engineer interview questions, because most business LLM features start there.

Question Model answer Interviewer checks
6. Walk me through a RAG pipeline end to end. Offline: parse, chunk, embed and index with metadata. Online: rewrite or embed the question, retrieve candidates, rerank, put the top chunks in the prompt with an instruction to answer only from them and cite, then check the answer. Both paths, metadata, grounding.
7. RAG, fine-tuning or better prompts? OpenAI’s accuracy guide starts with prompts, adds RAG for missing, outdated or private knowledge, and fine-tuning when behavior is the problem, such as format or tone. Diagnose first: its example shows RAG lowering a score when the issue was behavior. Knowledge vs behavior problems.
8. How do you choose chunk size and overlap? Tune it: split on headings, then compare sizes on a labelled retrieval test set.
Version note: OpenAI’s file search defaults to 800-token chunks with 400 overlap, range 100 to 4,096 tokens.
Experiments, not a magic number.
9. When do hybrid search and reranking help? Embeddings match meaning but can miss exact strings such as error codes, which keyword search (BM25) catches. Combine both, then rerank. Anthropic’s study reports failed retrievals falling from 5.7% to 1.9% on its test sets, so measure on yours. Why each retriever fails alone.
10. When would you skip RAG? When the knowledge base is small. Anthropic said in September 2024 that under 200,000 tokens (about 500 pages) it can go in the prompt, with caching to cut cost.
Version note: Some current models list 1M-token windows, so the threshold depends on model, cost and recall.
No vector database by reflex.
11. The right document exists but the answer is wrong. How do you debug? Split the failure. Was the right chunk retrieved? If not, fix chunking, hybrid search, query rewriting or filters. If yes, inspect chunk order, chunk count, conflicting sources and the grounding instruction. Log query, chunk IDs, scores and final prompt. Retrieval vs generation failure.
12. How do you stop RAG leaking data between users? Filter at retrieval by the caller’s identity, not in the prompt. OWASP LLM08:2025 names cross-context leaks in multi-tenant stores and recommends permission-aware vector stores, validated sources and tamper-resistant logs. Authorization outside the model.
Failed retrievals in the top 20 chunks, by method

Share of queries where the right chunk was missing. Lower is better.

Baseline embeddings5.7%
Contextual embeddings3.7%
Plus contextual BM252.9%
Plus reranking1.9%

Source: Anthropic, Introducing Contextual Retrieval, September 19, 2024, checked November 25, 2026. Anthropic’s test sets, not yours.

Agent and tool-use questions

Frameworks matter less than the loop under them; see AI agent frameworks compared for the options.

Question Model answer Interviewer checks
13. Explain function calling. Who runs the function? Your application does. The model returns a structured call (Claude: stop_reason tool_use; OpenAI: a function call with a call_id), your code runs it and returns the result linked by that ID, and the loop repeats until the model answers. The model never executes code.
14. How do you make tool arguments reliable? Write precise descriptions and use strict schemas: OpenAI needs additionalProperties false and all fields required; Anthropic’s strict true makes calls match input_schema. Then validate in code, because model output is untrusted.
Version note: On the newest Claude models, tool_choice any and tool return a 400 error; use auto with strict true.
Schema, description, validation.
15. Workflow or agent? Anthropic (December 19, 2024) defines workflows as predefined code paths and agents as LLMs directing their own process and tools. It advises the simplest solution that works, since agents trade latency and cost for flexibility. Resists needless agents.
16. How do you stop an agent looping or overspending? Set a maximum iteration count, token and spend budgets and timeouts, then hand off to a person at the limit. OWASP LLM10 lists rate limits, quotas and timeouts. Hard limits in code.
17. How should a tool report an error? As data the model can act on: Claude takes a tool_result with is_error true. MCP separates protocol errors from tool execution errors (isError) and says clients should give the latter to the model to retry. Errors written for self-correction.
18. What is MCP, and how does it differ from function calling? Function calling lets a model ask your app to run a function. MCP is an open JSON-RPC 2.0 protocol where hosts connect to servers exposing tools, resources and prompts, so one integration serves many hosts.
Version note: The 2026-07-28 revision has no initialize handshake or sessions; older articles describe both. See MCP explained.
Protocol vs API feature.

Evaluation questions

Method, step by step: how to evaluate an LLM application.

Question Model answer Interviewer checks
19. How do you evaluate a feature with no single right answer? Write specific, measurable success criteria, then test on real inputs including edge cases. Anthropic advises task-specific evals, automated grading and volume over a few hand-graded cases. Score a rubric of narrow questions. Criteria first, then volume.
20. Can you trust an LLM as a judge? Partly. Anthropic advises a different model from the one that wrote the answer, a constrained output such as yes or no, and an anchored scale. Spot-check it against human labels. The judge needs checking too.
21. How do you evaluate a RAG system? Score retrieval and generation separately: is the supporting chunk in the top results, and is the answer supported by it, complete, and a refusal when context lacks the answer? Two scores, not one.
22. A model upgrade ships next week. What do you run? The full test set on old and new models, compared by category, then a review of new failures, a cost and latency check and a staged rollout. OpenAI calls evals essential when upgrading models. Regression runs as routine.

Safety and security questions

Risk names come from the OWASP Top 10 for LLM Applications (2025 edition), LLM01 Prompt Injection to LLM10 Unbounded Consumption. Defences are walked through in prompt injection and guardrails.

Question Model answer Interviewer checks
23. Direct vs indirect prompt injection? Direct: the user’s own prompt alters behavior. Indirect: the model reads external content, such as a web page, email or tool result, that carries instructions. OWASP says RAG and fine-tuning do not fully mitigate either. Attacks arrive through data.
24. How do you defend an agent that reads and sends email? Assume some injections succeed and limit damage: read-only access where possible, tool allowlist, human approval to send, third-party text only inside labelled tool results (Anthropic), and red-team with hostile emails. Containment over clever prompts.
25. What is excessive agency? OWASP LLM06: damage from too much functionality, permission or autonomy. Fix it with the fewest tools, user-scoped credentials, approval for high-impact actions and authorization enforced downstream. Three causes, auth outside the model.
26. What is improper output handling? OWASP LLM05: passing model output onward without validation, which can cause XSS, SQL injection or code execution. Treat the model as an untrusted user, encode for context and use parameterized queries. Output is untrusted input.
27. Can you keep secrets or rules in the system prompt? No. OWASP LLM07 says it is not a secret or a security control. Keep keys and permissions out and enforce authorization in code. Instructions are not enforcement.
28. How do you treat a third-party MCP server’s tools? As untrusted. The specification says tool annotations are untrusted unless the server is trusted and tools represent arbitrary code execution; clients should confirm sensitive calls, show inputs, validate results and log. Supply-chain thinking.

System design questions

Question Model answer Interviewer checks
29. How do you cut an LLM feature’s latency and cost? Cache the stable prefix, retrieve fewer and better chunks, cap output, stream, and route simple requests to a smaller model (Anthropic’s routing pattern). Re-run the test set after each change. Levers plus a quality check.
30. Design a customer support bot with retrieval and tools. Walk-through 1 below. Structure, failure paths.
31. Design an internal knowledge assistant with per-user access. Walk-through 2 below. Authorization, freshness.

Walk-through 1: a support bot with RAG and tools

State requirements first: answer from the help center, look up order status, start refunds only with human approval, never expose another customer’s data, hand off when unsure.

Support bot: retrieval for answers, tools for actions

Refunds create a request for a person.

Request pathKnowledge and actionsCustomermessageInput checks:length, rate limitOrchestrator LLManswer, retrieve or call toolOutput check,citations, replyRetrievalhybrid search + rerankOrder lookupread-only, user-scopedRefund requestneeds human approvalHuman agent queuehandoff with transcriptLog: query, chunk IDs, tool calls, tokens, cost

Illustrative example, not a record of a real deployment.

  • Retrieval. Index articles by heading with a last-updated date, use hybrid search and a reranker, answer only from retrieved text and cite it.
  • Tools. The order lookup takes the customer ID from your session, never from the model. The refund tool creates a pending request a person approves, the OWASP LLM06 fix.
  • Failure paths. No relevant chunk, a low reranker score or a tool error means “I could not find that” plus a handoff, not a guess.
  • Evaluation. Real past tickets scored separately for retrieval hits, grounded answers, correct tool choice and correct refusals, re-run on every change.

Walk-through 2: an internal knowledge assistant with per-user access

Requirements: search wikis, tickets and documents, cite sources, respect each person’s access, stay current as pages change.

Internal assistant: permissions travel with each chunk

The access filter runs before the model sees any text.

Ingestion (offline, on every change)Query (online)Sources:wiki, tickets, docsParse and chunkby headingsEmbed + metadata:source, ACL, dateIndex:vector + keywordQuestion +user identityFilter byuser’s accessHybrid search+ rerankLLM answerwith citations

Illustrative example, not a record of a real deployment.

  • Permissions. Store each chunk’s access list as metadata and filter on the caller’s identity at query time, as OWASP LLM08 recommends.
  • Freshness. Re-ingest on change events and delete chunks for removed pages.
  • Trust. Anyone who can edit a page can plant text the assistant reads, so validate sources and treat chunks as untrusted.
  • Evaluation. Labelled questions per team plus permission tests: a user without access must get nothing.
Version note. Cache prices, minimum lengths and tool_choice rules change by model. Confirm a number on the vendor page before you quote it.

Red-flag answers that cost you the round

Answer to avoid Why it fails
“RAG removes hallucinations.” Anthropic says its techniques do not eliminate them; OWASP says RAG does not fully stop injection.
“The system prompt says never reveal that.” OWASP LLM07: a prompt is not a security control.
“The agent has admin access and decides what is safe.” OWASP LLM06: enforce authorization downstream, with least privilege.
“I tried ten prompts and it looked fine.” Anthropic asks for task-specific tests with volume.
“Fine-tune it so it knows our documents.” OpenAI: RAG for missing knowledge, fine-tuning for behavior.
“Send everything; the window is huge.” Recall degrades as tokens grow.
“Run the SQL the model returns.” OWASP LLM05: validate and parameterize.
“Start with an agent framework.” Anthropic advises the simplest solution first.

A 2-hour prep plan

A suggested plan for the night before, not a measured result. Practise aloud with a timer. If Python is your weak spot, start with the Python for AI roadmap.

Suggested 2-hour plan
1
0:00 to 0:20, LLM basics
Answer questions 1 to 5 aloud and add one cost or limit to each.
2
0:20 to 0:45, RAG
Draw the pipeline from memory, then answer 6 to 12, especially the debugging order in 11.
3
0:45 to 1:05, agents
Write the tool loop in pseudocode with a stop condition, then answer 13 to 18.
4
1:05 to 1:20, evaluation and security
Recite the ten OWASP names and answer 19 to 28 with one defence each.
5
1:20 to 1:50, system design
Run both walk-throughs for 15 minutes each, drawing as you speak.
6
1:50 to 2:00, your project
Prepare one project you built and one failure you fixed.

If you want a guided build and mock interviews

You can prepare for AI engineer interview questions by self-study; a course helps when you have no project to discuss. AgileFever sells the GenAI and Agentic AI BootCamp. Its page lists advanced RAG, agent architectures and MCP integration, and mock interviews under career assistance. As listed on November 25, 2026, the US page shows $2,000 per batch, 74 hours (64 live, 10 self-paced) over 8 weeks, and expects basic Python. AgileFever adds 18% GST at checkout for buyers in India; your country’s fee is in the Schedules section. Compare any course with the agentic AI course syllabus checklist. If you can already build and evaluate a RAG app and an agent with tool approvals, skip the course and rehearse the walk-throughs.

Additional discounts are available. Contact us to know more.

Questions people ask

What do AI engineer interview questions usually cover?

LLM basics, RAG, agents and tool use, evaluation, security and one system-design round. Rounds vary by employer, so treat any list, including this one, as a map of topics, not a guarantee.

How do I answer a RAG question I have not built?

State the pipeline, name the first failure you would check and say how you would measure it. Question 11 gives a reusable order.

Do I need to know LangGraph or another framework?

Know the loop underneath: model call, tool call, result, stop condition. Frameworks wrap it.

Which security topics should I prepare?

Prompt injection, excessive agency, improper output handling, system prompt leakage and unbounded consumption, each with a two-sentence defence.

Are the numbers in these answers permanent?

No. Cache prices, chunk defaults and tool_choice rules change by model and version. Say the idea and quote a number only if you have checked it.

Contact Us

    By checking the box, you consent to receive registrations, class reminders, updates, support text messages from AgileFever at the provided number. Message and data rates may apply. Message frequency varies (typically 1–2 msgs/week). To end messaging from us, you may always reply with STOP. You may also reply with HELP for more information. Check Privacy Policy and Terms & Conditions.