AI Engineer Interview Questions
40 original questions across LLM fundamentals, RAG, agents and tool use, evals, MCP, prompt injection and agent permissions, LLMOps and serving, latency and cost trade-offs, Python for AI, and the evolving AI-era practice of evals over vibes and knowing when not to use an LLM at all.
Related: Machine Learning Fundamentals →
15 Fresher15 Mid-Level10 Senior
Fresher
At a high level, how does a large language model decide what word to output next?
Generation is autoregressive — the model produces one token, appends it to the input it's already seen, and repeats, each new token chosen based on everything generated so far plus the original prompt. Underneath that loop, a self-attention mechanism lets every token in the current input weigh and draw on every other token when building its representation, which is what lets the model resolve a word's meaning from surrounding context — the same word can mean something different depending on what's around it, and attention is the mechanism that lets the model use that surrounding context rather than treating each word in isolation. The model's final output at each step isn't a single fixed answer — it's a probability distribution over what the next token could plausibly be, and the generation process samples from that distribution rather than always deterministically picking one fixed 'correct' token.
What interviewers look for
- explains autoregressive, token-by-token generation where each step depends on everything generated so far
- explains self-attention lets the model weigh surrounding context to resolve meaning, not treat words in isolation
- connects this to the output being a probability distribution over possible next tokens, not a single fixed answer
What do temperature and top-p control during generation, and why would you deliberately set one value for a factual task and a very different one for a creative task?
Temperature controls how randomly the next token gets selected from the model's probability distribution — a very low setting makes selection close to deterministic, consistently favoring the single most likely token, while a higher setting allows meaningfully less likely tokens a real chance of being picked, producing more varied, less predictable output. Top-p works alongside this by restricting the pool of candidate tokens to only those making up some cumulative share of the total probability mass, rather than considering every possible token regardless of how unlikely. For a factual task — answering a specific question correctly — a low temperature setting consistently favors the most probable, generally most reliable answer; for a creative task, where variety and surprise are desirable qualities rather than defects, a higher setting is the right choice. Neither setting makes the model more accurate — they control how wide or narrow the space of possible outputs is, not whether any given output is correct.
What interviewers look for
- explains temperature controls randomness in token selection, from near-deterministic to more varied
- explains top-p restricts the candidate pool to a cumulative probability share, as a separate but related control
- clarifies these control the width of the output space, not accuracy or correctness directly
What problem does retrieval-augmented generation solve that fine-tuning a model on your own documents doesn't solve as well?
Fine-tuning bakes specific facts into the model's weights at training time, which means anything that changes after that training run requires an entirely new training run to update — there's no lightweight way to just edit one fact once it's baked into weights. Retrieval-augmented generation instead fetches the current, live content of your documents at the moment a question is asked and hands it to the model as context for that specific request, so updating what the system 'knows' is as simple as updating the underlying documents themselves, with no retraining step involved. It also lets the system point to exactly which specific document a given answer came from, which a fine-tuned model generally can't do, since facts absorbed into weights during training don't carry any record of which original source they came from.
What interviewers look for
- explains fine-tuning bakes facts into weights at training time, requiring a new training run to update them
- explains retrieval fetches live, current document content at query time, so updates need no retraining
- names citing the specific source document as something retrieval enables that fine-tuning generally can't
Why does chunk size matter for retrieval quality, and what goes wrong at each extreme — chunks that are too small versus chunks that are too large?
Chunks that are too small risk losing the surrounding context that gave a sentence its meaning — an isolated sentence extracted without the qualifier or the preceding setup that made it accurate can end up misleading on its own, even though it was perfectly correct within its original surrounding context. Chunks that are too large dilute the one relevant piece of information with a lot of surrounding unrelated material, which makes that chunk's own embedding a kind of blurred average that doesn't represent any single idea particularly well, and it also wastes the model's limited context budget on mostly irrelevant filler once that chunk is retrieved and included. The right size is a real tradeoff, usually tuned empirically for a specific document type, between keeping enough context to stay meaningful and staying narrow enough that each chunk's embedding represents one coherent idea rather than a blend of several unrelated ones.
What interviewers look for
- explains chunks that are too small can lose the surrounding context that made the content accurate or meaningful
- explains chunks that are too large dilute relevance and waste context budget on irrelevant surrounding material
- frames chunk size as an empirical tradeoff tuned per document type, not one universally correct number
What's the difference between a single LLM call answering a question and what's called an 'agent'?
A single call is stateless and self-contained — one input goes in, one text output comes out, with no ability to take any real action in the world or verify anything beyond what was already in its own training. An agent adds a genuine loop around that: it reasons about what to do next, calls a tool or takes some real action, observes the real result that action produced, and decides its next step based on that observation, repeating this cycle until it determines the task is done. The defining feature is the ability to take a real action and then incorporate the genuine result of that action into its next decision, forming a feedback loop — not simply that it sounds more sophisticated or produces a longer response than a single call would.
What interviewers look for
- explains a single call is stateless, one input and one output, with no ability to take real action
- explains an agent adds a genuine reason-act-observe loop repeating until the task is done
- identifies taking a real action and incorporating its result as the defining difference, not just apparent sophistication
Why doesn't a simple exact-match comparison work for evaluating most LLM outputs, the way it reliably works for testing a typical deterministic function?
A deterministic function given the same input always produces the exact same output, which is exactly what makes exact-match a meaningful test for it. An LLM can express a correct answer in many different, equally valid ways — different wording, different sentence structure, different level of detail — so an exact-match comparison against one single reference answer would mark a response wrong purely because it's phrased differently, even when it's substantively correct, producing a large number of false negatives that don't reflect the system's real quality. Real evaluation for this kind of output needs a check that tolerates valid phrasing variation — confirming a required fact or entity is present, checking that a structured output satisfies a defined schema, or using a separate scoring step, sometimes another model call, to judge whether the response is substantively correct regardless of its exact wording.
What interviewers look for
- explains exact-match assumes deterministic, identical output, which doesn't hold for LLM-generated text
- explains this produces false negatives for answers that are substantively correct but differently worded
- names a real alternative — checking for required entities/facts, schema validation, or a separate judging step
What problem does a standardized protocol for connecting an AI model to external tools and data sources solve, compared to every application writing its own custom integration for each tool?
Without a shared standard, every single application that wants to connect a model to, say, a particular internal database or file system has to write its own custom integration code for that one combination, and that exact same integration effort then gets independently redone from scratch by every other team that also wants to connect the same tool to a different application. A standardized protocol means a given tool or data source gets wired up to the shared standard exactly once, and any compliant application can then use it immediately without writing any new custom glue code of its own. The real payoff is reusability across many different applications and tools at once — the same reason one universal connector is more valuable than building many separate, mutually incompatible custom cables, each one engineered for exactly one specific pairing and nothing else.
What interviewers look for
- explains the problem without a standard — repeated, redundant custom integration work for every application/tool pairing
- explains a standard means wiring a tool up once and reusing it across many compliant applications
- connects this to a genuine reusability payoff, not simply 'it's more organized'
What is prompt injection in plain terms, and why is it a different kind of problem from a typical input-validation bug?
Prompt injection is untrusted content — something a user typed, or content pulled in from elsewhere — that ends up being interpreted by the model as a new instruction to follow, rather than as plain data to be processed, which lets it override or undermine whatever the system was set up to do. A typical input-validation bug usually means malformed data breaks a fixed, well-defined parsing rule in a predictable, testable way that can be reliably checked for. Prompt injection is harder because there's no hard, enforced boundary in a plain-text prompt between 'this part is an instruction' and 'this part is just data,' the way a query language has a strict syntactic boundary — the model reads everything as natural language, and a sufficiently convincing piece of embedded text can look like a legitimate instruction to it, with no fixed syntax rule reliably marking exactly where the real instruction ends and untrusted content begins.
What interviewers look for
- defines prompt injection as untrusted content interpreted as a new instruction rather than as data
- explains why this differs from typical input validation — no hard syntactic boundary between instructions and data in plain text
- connects this to why it's harder to reliably detect than a malformed-data bug
Direct injection and indirect injection are both forms of prompt injection — what separates them, and why would indirect injection still be worth defending against even on a product whose entire user base is fully trusted?
In a direct attempt, the person typing the prompt is the one crafting the malicious instruction, so vetting or restricting your own user base at least narrows that path. In an indirect attempt, the malicious instruction arrives inside something else the model is asked to process on a user's behalf — a document it's summarizing, a webpage it's fetching — material the user never wrote and may never have even opened. A fully trusted user base does nothing to close this off, because the attacker in that scenario isn't your user at all — it's whoever wrote or planted content inside that external document, page, or file. The model reads it with the same weight it gives any other input, so the threat comes in through the data being processed, never through anything a trusted user actually typed.
What interviewers look for
- distinguishes direct injection (a user typing malicious instructions) from indirect (malicious instructions embedded in external processed content)
- explains why indirect injection matters even with fully trusted users
- identifies the real attacker in the indirect case as whoever authored the external content, not the user
Why does serving a large language model in production typically need specialized serving infrastructure, rather than simply loading the model into a normal web server process the way you'd deploy a typical, lightweight ML model?
A large language model's memory footprint and the compute required per request are both dramatically larger than a typical lightweight ML model's, and naively finishing one request entirely before starting the next one wastes a substantial amount of available compute capacity that sits idle between requests instead of being shared across them. Specialized serving frameworks exist to handle efficiently batching multiple requests together, to manage the model's memory — particularly the significant per-request state that accumulates during token-by-token generation — far more carefully than generic application code ever would, and they're purpose-built around the specific token-by-token generation pattern LLMs use, which a generic web server framework has no special handling or optimization for whatsoever.
What interviewers look for
- explains an LLM's memory footprint and per-request compute need are both far larger than typical lightweight ML models
- explains naive one-request-at-a-time serving wastes significant available compute capacity
- names specialized serving frameworks' value — efficient batching and careful memory management for the generation pattern
Why does streaming a model's response token by token improve perceived responsiveness, and when would you deliberately choose NOT to stream?
Streaming shows the user the very beginning of the response as soon as it's generated, rather than making them wait for the entire response to finish generating before showing anything — this makes a generation that takes several seconds feel meaningfully faster to the person waiting, even though the total time to finish generating everything hasn't changed one bit; what's changed is that something visible starts appearing sooner, which is what perceived latency measures. You'd deliberately choose not to stream when the caller needs the complete, fully valid response before it can do anything useful with it — a backend process that's going to parse the output as structured data generally needs the entire thing to be complete and syntactically valid before it's usable for anything, since a partial, half-received fragment of structured output usually isn't parseable.
What interviewers look for
- explains streaming improves perceived responsiveness by showing partial output sooner, without changing total generation time
- correctly identifies structured output meant for programmatic parsing as the case where streaming doesn't help
- distinguishes perceived latency from total latency
Why would you reach for asyncio rather than making sequential calls when your code needs to call three independent AI model endpoints?
Each individual call to a model endpoint spends the vast majority of its wall-clock time simply waiting for a network response to come back, not doing real CPU work on the calling side — so the three independent calls can be issued concurrently and all wait on their respective responses at the same time, rather than strictly one after another in sequence, and the total real wait ends up being roughly the time of the single slowest call, instead of the sum of all three added together. This helps because the bottleneck here is network waiting, not CPU computation on the calling side — it's not true parallel CPU execution the way multiprocessing provides, just overlapping the otherwise-idle waiting time across several in-flight requests at once.
What interviewers look for
- explains each call is mostly spent waiting on network I/O, not doing CPU work on the calling side
- explains concurrent calls overlap that waiting time instead of summing it sequentially one after another
- clarifies this is concurrency during I/O wait not true CPU parallelism
An AI API's response occasionally includes a field in its JSON that's usually present but sometimes entirely missing — say, only present on an error case. What's the bug risk here that a typical code review would most likely miss?
Code that reads that field directly without first checking whether it's present will work fine and will pass review cleanly against essentially every example anyone tests or reviews, simply because the field is present in nearly every normal, successful case — the bug only manifests on the specific, less common response shape where the field is absent, which is exactly the case least likely to show up in a quick manual review or in a small, hand-picked set of test examples someone happened to try. The real defense is treating every field in an AI API's response as potentially absent unless that API's own documented contract explicitly guarantees otherwise, using an explicit presence check or a typed optional field, rather than quietly assuming that a field which is usually there will always be there on every single call.
What interviewers look for
- explains the bug passes review because the happy-path case, where the field is present, is what typically gets tested
- identifies the failure case as the less common response shape, exactly what a quick review is least likely to cover
- proposes treating response fields as potentially absent unless explicitly guaranteed, rather than assumed always present
A team ships every new prompt change based on 'it looked better when I tried a few examples.' What's wrong with this as a standing practice, not just as a one-off judgment call?
'Looked better on a few examples' has no defined, repeatable success criteria behind it, and it's checked against a tiny, likely unintentionally cherry-picked sample — without that structure, there's no reliable way to know whether a given change is a real improvement, a regression hiding entirely outside the handful of examples that happened to get checked, or simply different without being better in any measurable sense. The healthier standing practice treats every prompt or model change the same way a genuine code change gets treated — evaluated against a real, representative evaluation set, run before and after the change, scored by a consistent method — because 'it felt better to me' and 'it's, measurably better' are frequently not the same claim, and only a real evaluation process can reliably tell the two apart.
What interviewers look for
- identifies the lack of defined, repeatable criteria and a representative sample as the problem, not just this one instance
- explains the real risk — a regression could be hiding entirely outside the small sample that happened to get checked
- proposes treating prompt/model changes like genuine code changes, evaluated against a real evaluation set, not subjective impression
Why does keeping a human in the loop matter for a high-stakes AI feature, rather than simply making the feature slower for no real benefit?
A human checkpoint exists to catch the exact category of error an automated evaluation score or the model's own stated confidence level wouldn't catch — a plausible-sounding, confidently-stated, but substantively wrong answer in a domain where getting it wrong carries a real, meaningful consequence for someone. It's not fundamentally about adding friction or deliberately slowing the feature down for its own sake — it's a deliberate, explicit tradeoff, accepting somewhat slower throughput in direct exchange for a genuine, independent check positioned at the point where an error would matter. The honest design question worth asking is exactly where a human checkpoint earns that tradeoff — a case with real stakes attached — versus where it's just unnecessary friction bolted onto an already low-stakes case that never needed the extra protection.
What interviewers look for
- explains a human checkpoint catches confidently-stated wrong answers that automated checks or the model's own confidence wouldn't catch
- frames this as a deliberate tradeoff — accepting slower throughput for a genuine check, not friction added for its own sake
- raises that the checkpoint should be placed where real stakes justify it, not applied uniformly everywhere regardless of stakes
Mid-Level
A model has a maximum context window. Mechanically, what happens if an application tries to send more tokens than that limit allows in one request, and what does that imply for how you design around it?
The request is rejected or the input gets truncated, depending on the specific API's behavior — the model doesn't automatically compress the conversation, silently summarize older parts, or otherwise work around the limit on its own behalf; the context window is a hard ceiling on total input plus output tokens, not a soft guideline the system quietly accommodates. The real implication is that managing what fits inside that fixed budget is entirely the calling application's own responsibility, not something that happens for free — truncating older conversation history, splitting a long document into smaller pieces processed separately, or summarizing earlier context into a more compact form before including it are all techniques for staying within the limit deliberately, rather than discovering the limit the hard way when a request is unexpectedly rejected or silently cut off in production.
What interviewers look for
- explains the context window is a hard ceiling, with no automatic compression or workaround on the model's part
- explains managing what fits is entirely the application's own responsibility, not handled for free
- names at least one concrete technique — truncation, chunking, or summarization — for designing around the limit deliberately
A RAG system retrieves chunks that are relevant to the question, but the final answer still contains a specific fact that isn't present in any of those chunks. What's happening, and how would you catch this systematically rather than noticing it by chance?
This is hallucination happening despite correct retrieval — the model is drawing on its own pretrained knowledge, or simply pattern-completing something plausible-sounding, instead of staying strictly grounded in only the content it was given. Retrieval quality alone doesn't prevent this, because retrieval and generation are two separate steps in the pipeline that can each individually work correctly while the combination of the two still fails — good retrieval guarantees the right material was handed to the model, not that the model stuck to using only that material when producing its answer. Catching this systematically means running an explicit faithfulness check as a routine part of the pipeline — comparing each individual claim made in the generated answer against the specific retrieved context to confirm it's supported there, using either an automated scoring approach or a separate model acting as a judge — rather than relying on someone happening to notice a wrong-sounding answer during occasional manual spot-checking.
What interviewers look for
- identifies this as hallucination despite correct retrieval, a generation-grounding failure, not a retrieval failure
- explains retrieval and generation are separate steps that can each individually work while the combination still fails
- proposes an explicit, routine faithfulness check comparing claims against retrieved context, not occasional manual spot-checking
An agent with tool access is stuck looping — calling the same tool repeatedly without making real progress on the task. What's the fix here, beyond just adding a hard iteration limit?
A hard iteration cap is a necessary safety net, but it only bounds the damage a stuck loop can do — it doesn't fix why the loop is happening. The real fix starts with understanding the specific cause: very often the tool's own response isn't usable by the agent's next reasoning step, because it's malformed, ambiguous, or missing a field the agent needs to decide what to do next, so the agent keeps calling the same tool again hoping for a result it can act on. Or the task can't be completed with the tools currently available, and the agent has no explicit way to recognize that and report failure rather than simply keep retrying indefinitely. The fix is either improving the tool's response so the next reasoning step can use it, or giving the agent an explicit path to conclude 'this isn't working' and escalate or report the failure instead of looping forever.
What interviewers look for
- explains a hard iteration cap bounds damage but doesn't fix why the loop is happening
- investigates a real root cause — often an unusable or ambiguous tool response the agent can't act on
- proposes either fixing the tool response or giving the agent an explicit failure-reporting path, not just capping retries
Why might a multi-agent 'supervisor plus specialized workers' design perform worse than a single, well-prompted agent handling the exact same task end to end?
Splitting a task across several agents adds genuine coordination overhead — the supervisor has to decompose the task correctly and route each piece to the right worker correctly, and any error in that decomposition or routing step compounds on top of whatever errors each individual worker agent might also separately make, so the total error surface across the whole system is larger than one well-designed single agent's, not automatically smaller just because more agents are involved. Multi-agent designs earn their added complexity when a task benefits from real specialization — agents each tuned for a distinct sub-skill — or real parallelism, independent sub-tasks that can run concurrently rather than sequentially. For a task that a single well-prompted agent could already handle directly and reliably, splitting it up adds new coordination failure modes without adding any real capability the single agent didn't already have.
What interviewers look for
- explains splitting the task adds genuine coordination overhead and a larger total error surface, not automatically better results
- explains multi-agent designs earn their complexity for real specialization or genuine parallelism needs
- concludes a task a single agent already handles well doesn't benefit from being split up
Why do teams reach for a second model to grade a first model's output, and what goes wrong if that's the only evaluation method in place?
Using a separate model call to score or compare outputs against a defined rubric scales dramatically better than having a human review every single generated response individually, especially once volume grows beyond what any human review process could realistically keep up with. The real risk is that the judging model carries its own specific biases and blind spots — it might systematically favor longer or more confident-sounding answers regardless of their correctness, or it might share the exact same kind of mistake the model being evaluated tends to make, in which case it would reliably miss precisely the errors a human reviewer would have caught immediately. Relying on this as the only evaluation method means those specific blind spots go completely unchecked and uncorrected; the practical mitigation is periodically validating the judge's own scores against genuine human judgment on a representative sample, rather than simply assuming the judging model is itself a perfectly neutral, infallible grader.
What interviewers look for
- explains using a separate model as judge scales far better than full human review of every response
- names a concrete specific risk — bias toward length or confidence, or sharing the same blind spots as the model being judged
- proposes periodically validating the judge's scores against real human judgment on a sample, not assuming it's infallible
A team ships a new prompt version because it 'felt better' after someone ran a handful of ad hoc checks by hand. What's missing from this, and what would a real evaluation process look like instead?
A handful of manually chosen tests is a tiny, almost certainly unrepresentative sample, and 'felt better' has no defined, repeatable success criteria behind it — two different people looking at the exact same small set of examples could easily reach opposite conclusions, with no objective way to settle the disagreement between them. A real evaluation process needs an evaluation dataset — a sizeable, representative set of real or realistic inputs paired with defined expected properties or reference answers — run against both the old and new prompt versions, scored through a consistent method such as an automated check, a model acting as judge, or structured human review, and compared against a measured metric like win rate, not a subjective impression gathered from a small handful of hand-picked examples.
What interviewers look for
- identifies the gap — a tiny, likely-unrepresentative sample with no defined, repeatable success criteria
- proposes a real evaluation dataset run against both versions with a consistent scoring method
- names comparing on a measured metric, not a subjective impression from a small sample
A tool exposed to an AI model through a standardized connection protocol lets the model read files from a connected filesystem on its own initiative. What's the security concern here that's different from a normal API integration a human engineer wrote?
The real concern is that the model itself decides which specific files to read and exactly when, based on its own in-the-moment reasoning about the current conversation — unlike a traditional API integration, where a human developer wrote a specific, fixed code path calling the API with parameters the developer themselves controls, here the access pattern is driven by the model's own judgment in real time, which can itself be influenced by whatever content it happens to be processing right then, including content that's untrusted. If some untrusted content the model is currently working through — a document, a webpage — contains text crafted to steer the model's next decision, that content can potentially influence which files get accessed next, in a way a traditional API integration structurally can't be influenced, since its call parameters come from trusted application code the developer wrote, never from content the system merely happened to read moments earlier.
What interviewers look for
- explains the model itself decides what to access and when, based on its own real-time reasoning, unlike a fixed developer-written code path
- explains this access pattern can be influenced by untrusted content the model is currently processing
- connects this to a structurally different risk than a traditional API call, whose parameters come from trusted developer-written code
You're exposing several internal tools to an AI agent through a standardized tool-connection protocol. What permission model would you want in place, rather than simply giving the agent the same access level a trusted human engineer would normally have?
The agent should get the minimum access each individual tool-exposed capability needs for its intended, specific purpose, scoped separately per tool, rather than inheriting one broad standing permission set the way a trusted human engineer might reasonably hold across many systems at once — a tool that lets the agent query a reporting database purely for read-only analytics has no need for write access to that same database, even if a human colleague with equivalent job-level access would reasonably hold both. The practical reason this matters even more for an agent than for a generally cautious human: an agent's next action can be influenced by content it's currently processing in a way a human exercising their own independent judgment generally isn't, at least not to the same degree, so a narrowly scoped permission set bounds the damage if that kind of influence ever does happen — in a way that extending the same implicit trust you'd place in a careful human simply doesn't.
What interviewers look for
- proposes minimum necessary access scoped per individual tool, not inheriting broad human-engineer-level standing access
- gives a concrete example of access that isn't needed for a specific tool's intended purpose
- explains why this matters more for an agent than a human — real susceptibility to being influenced by content it processes
An agent that can both send emails and read a user's calendar is asked to 'summarize my week and email it to my manager.' What's the risk specific to this particular combination of capabilities, beyond just 'the agent might make a mistake'?
The specific risk is that reading the calendar is a step where the agent processes content it didn't author itself and can't fully vouch for — a calendar entry's title or description could contain text deliberately crafted to resemble an instruction, and if the agent's next decision is influenced by that embedded text while it also happens to have the ability to send email, the combination of 'read untrusted content, then take an external action based on it' is exactly the shape of a real prompt-injection attack with a genuine, real-world consequence attached, not merely a theoretical text-processing curiosity. Either capability — just reading the calendar, or just sending email — carries meaningfully lower risk than the specific combination of 'read untrusted content' immediately followed by 'take an irreversible external action based on what was just read,' which is exactly the pattern worth deliberately scrutinizing whenever an agent holds both kinds of capability together.
What interviewers look for
- identifies the calendar-reading step as processing content the agent didn't author and can't fully vouch for
- explains the specific risky pattern — reading untrusted content immediately followed by an external, consequential action
- distinguishes this concrete combination from a generic 'the agent might simply make a mistake' framing
When does fine-tuning a model make genuine sense, and what's the common mistake of reaching for it when a different technique would work better?
Fine-tuning earns its place for teaching a model a consistent output format, tone, or style that's hard to reliably achieve through prompting alone, and when there's a large enough set of real examples available to train on. The common mistake is reaching for fine-tuning to teach a model new facts it doesn't currently know, when retrieval handles that exact same need far more cheaply and far more maintainably — updating a retrieved document is trivial and instant, while updating facts that are already baked into fine-tuned weights requires an entirely new training run. Fine-tuning also tends to get reached for prematurely in cases where a better-written system prompt, or just a handful of well-chosen examples included directly in the prompt itself, would have solved the problem without the real overhead of running a training job and then managing and redeploying a new model artifact going forward.
What interviewers look for
- explains fine-tuning fits teaching format/tone/style with sufficient real examples, not injecting new facts
- explains why retrieval handles new facts more cheaply and maintainably than fine-tuning would
- names reaching for fine-tuning prematurely, when better prompting or few-shot examples would work, as the common mistake
A model-serving endpoint's latency is perfectly fine at low traffic but degrades badly once concurrent requests increase. Beyond simply 'add more hardware,' what's happening, and what would you check first?
Generation is inherently sequential within each individual request — the model produces output token by token for that one request — and serving many requests concurrently means the underlying hardware's finite compute and memory now get shared across all of them at once, so each individual request's effective throughput drops measurably as more requests compete for that same fixed resource simultaneously, which is a fundamentally different scaling shape than a typical stateless web request that's mostly just waiting on a quick database round-trip. What's worth checking first: whether the serving setup is batching concurrent requests together efficiently, or processing them in a way that wastes available capacity, and whether the real bottleneck under load is raw compute, or memory capacity for holding multiple requests' in-flight generation state at the same time — adding more hardware without first understanding which of the two is the constraint risks solving only half the real problem, or the wrong half entirely.
What interviewers look for
- explains generation is sequential per request, and shared compute/memory across concurrent requests directly reduces each request's throughput
- distinguishes this scaling shape from a typical stateless web request mostly waiting on a quick database call
- proposes checking whether batching is efficient and which specific resource (compute versus memory) is the bottleneck before adding hardware
A feature's per-request cost is dominated by input token count, not output tokens. What are the levers to reduce this, beyond just manually trimming the prompt text itself shorter?
Beyond manually shortening the prompt by hand, caching repeated or shared context — a long system prompt or a reference document that's identical across many separate requests — so it isn't resent and fully reprocessed from scratch on every single call, where the provider supports that kind of caching, is a real, concrete lever. Trimming conversation history down to only what's needed for the current turn, rather than resending the entire accumulated history on every single request, also directly and meaningfully reduces input size. Summarizing older context into a more compact form before including it, deliberately trading a small amount of fidelity for a meaningfully smaller token count, is another concrete technique worth having available. All of these reduce the number of tokens processed per request, which is the real underlying lever, rather than simply manually wordsmithing one prompt to shave it down to be slightly shorter.
What interviewers look for
- names caching repeated or shared context as a concrete lever, not just manually shortening the prompt text
- names trimming conversation history to only what's needed for the current turn as a separate concrete lever
- names summarizing older context, trading fidelity for token count, as another concrete technique
You need to estimate and control the cost of a new AI feature before it ships, rather than discovering the real number from the first month's bill after launch. What would you set up?
Log token usage from the very first version, even during early development — input and output tracked separately, since they're typically priced quite differently — on every single request, since retrofitting usage visibility after an unexpectedly large bill has already arrived is a harder project than simply having that data already flowing from day one. For real control before anything ships: cap the maximum output length deliberately rather than leaving it fully unbounded, use caching wherever the provider supports it for repeated shared context, and run a cost estimate against a realistic expected usage volume and pattern before launch — not a rough, optimistic guess — so there's a genuine number on hand to compare real traffic against once the feature is live, rather than finding out the real answer for the first time directly from the bill itself.
What interviewers look for
- proposes logging input/output token usage separately from the very first version, not retrofitted after a surprise bill
- names capping output length and using caching as concrete pre-launch controls
- proposes running a cost estimate against realistic expected volume before shipping, not a rough guess
A conversation with an AI assistant has grown too long for the model's context window. What's wrong with simply dropping the oldest messages to make room, and what's a better approach?
Naively dropping the oldest turns loses whatever information was contained in them entirely silently and unpredictably — if an important instruction or a key fact was established early on in the conversation, it's simply gone from the model's effective working memory with absolutely no warning given to anyone, and the model itself has no way to even know that something relevant was quietly dropped from what it can see. A better approach summarizes the older turns into a more compact representation before removing the originals, preserving the real gist of what mattered while still freeing up space, and deliberately keeping the system prompt plus the most recent turns fully intact as the parts most likely to still matter going forward. It's worth being honest, though, that summarization itself carries a real cost — an extra model call to produce that summary — and a real failure mode of its own, where a flawed summary can itself quietly lose something that mattered, so it's a meaningful improvement over naive dropping, not a perfect, risk-free fix.
What interviewers look for
- explains naive dropping loses information silently and unpredictably, with no signal that something relevant was lost
- proposes summarizing older turns before removing them as the better approach
- honestly acknowledges summarization carries its own real cost and its own failure mode, not a perfect fix
A product team wants to use an LLM to make a fully automated decision — no human review — that denies or approves something consequential for a real person. What's your pushback as the AI engineer on that team?
An LLM's output is fundamentally a plausible-sounding completion, not a guaranteed-correct judgment, and for a decision that's consequential for a specific real person, the real-world cost of a wrong decision landing with absolutely no check is asymmetric and serious — unlike a low-stakes internal suggestion where an occasional wrong answer is a minor, forgettable inconvenience, a wrongly denied or wrongly approved consequential decision can cause real, hard-to-reverse harm to a specific person who may have no visibility whatsoever into why or how that decision was made. The pushback isn't 'never use an LLM for anything like this' — it's that a decision with this particular stakes profile needs a real human review step, or at the very least a clear, accessible appeal path, before fully removing a human from the loop entirely; using an LLM purely to assist a human reviewer, surfacing relevant information faster so the human decides better and quicker, is a meaningfully different and far more defensible design than using it to make the final, unreviewed call.
What interviewers look for
- explains an LLM's output is a plausible completion, not a guaranteed-correct judgment, which matters more as real stakes increase
- explains the asymmetric real-world cost of an unreviewed wrong decision for a consequential case affecting a real person
- distinguishes LLM-assisting-a-human-reviewer from LLM-making-the-final-unreviewed-call as the design choice at stake
Senior
A teammate argues that as context windows keep growing, retrieval-augmented generation will stop being necessary — just paste the entire knowledge base into every prompt. What's wrong with that argument?
Cost and latency scale with the number of input tokens processed, regardless of whether the model needed all of them to answer the specific question asked — stuffing an entire knowledge base into every single call means paying that same cost and latency penalty on every request, even the overwhelming majority where almost none of that content was relevant. Beyond cost, models don't reliably attend to every part of a very long context with equal weight — content buried in the middle of an unusually long input can in practice get effectively under-weighted relative to content near the beginning or end, so a larger window doesn't automatically guarantee a specific fact buried deep inside gets reliably surfaced when it matters. Retrieval's value was never really 'working around a context limit too small to fit everything' — it's deliberately selecting the relevant slice of content so cost and latency stay bounded per request and the model's attention isn't diluted across mostly-irrelevant material, which remains true and valuable no matter how large context windows eventually get.
What interviewers look for
- explains cost and latency scale with total input tokens regardless of whether all of it was needed for the answer
- explains models don't reliably attend equally across a very long context, so a larger window doesn't guarantee a fact gets surfaced
- reframes retrieval's value as selecting the relevant slice, not working around a technical window-size limitation
Likely follow-up: How would you measure whether a specific long-context use case is hitting this mid-context attention problem in practice?
Retrieval quality looks good when you test it in isolation, but end-to-end answer quality in production is still inconsistent. Walk through how you'd isolate which part of the pipeline is responsible, rather than guessing.
Test each stage of the pipeline independently against its own real intermediate output, rather than trusting one single end-to-end quality score to tell you where the problem lives. Check retrieval on its own terms — given a specific query, did the right chunks get retrieved — separately from checking generation on its own terms: given exactly the right chunks handed to it directly, does the model produce a faithful, relevant answer from them. If retrieval independently checks out as good, and end-to-end quality is still inconsistent, the real problem lives somewhere in generation itself, in how the prompt is constructed, or in how retrieved chunks get assembled into the final prompt — ordering, truncation if too many chunks get stuffed in at once, inconsistent formatting between chunks. Chasing a retrieval-side fix for a problem that's happening in generation or prompt assembly wastes real effort and won't move the end-to-end quality number.
What interviewers look for
- proposes testing retrieval and generation independently against real intermediate outputs, rather than trusting one end-to-end score
- explains how to isolate a generation-stage problem — given confirmed-correct chunks, does generation use them faithfully
- warns that chasing a fix in the wrong stage wastes effort without improving the end-to-end quality
Likely follow-up: The generation stage checks out fine too when given the right chunks directly. What would you check next?
You're deciding between building one agent with access to many tools, versus several specialized agents each scoped to fewer tools. What's the architectural tradeoff here, beyond 'more agents means more complexity'?
A single agent with access to many tools keeps the overall control flow simple — one reasoning loop, one place to see the full history of what happened — but it means every single decision that agent makes has to correctly select from the full, growing list of available tools, and tool-selection quality can degrade as that list keeps growing, since more options at every single step is more opportunity to pick the wrong one. Several specialized agents, each scoped to a smaller, more relevant subset of tools, make each individual agent's own tool-selection decision meaningfully easier and more reliable, at the real cost of needing an explicit routing or supervision layer to decide which specialized agent handles a given incoming request — trading improved tool-selection reliability within each agent for genuine added coordination complexity across agents. The deciding factor should be whether the tool set is large and varied enough that tool-selection quality is a real, measured problem for the single-agent approach not an unexamined assumption that splitting into specialized agents is automatically the more sophisticated or correct choice.
What interviewers look for
- explains a single agent keeps control flow simple, but tool-selection quality can degrade as the tool list grows
- explains specialized agents ease tool-selection within each one, at the real cost of needing a routing/supervision layer
- insists the decision should rest on measured tool-selection quality for the tool set, not an assumption that splitting is inherently better
Likely follow-up: How would you measure whether tool-selection quality is degrading in a single-agent setup before deciding to split it?
The golden set backing your eval suite hasn't changed in a year, and the current prompt-and-model pairing has been sitting near the top of the scale for months. What should that pattern make you suspicious of, and how would you respond?
A score that's stayed near-perfect on the exact same fixed dataset for months is itself a signal worth investigating, not simply good news to accept at face value — either the system has gotten reliably good at exactly those particular cases, which is plausible but worth verifying rather than assumed, or the dataset has quietly stopped representing the real range of inputs the system sees in production now, with real traffic having drifted toward cases the year-old evaluation set never covered. The risk is false confidence: a perfect score on a stale, no-longer-representative dataset says essentially nothing about how the system performs on the inputs that matter today, and the fix is periodically refreshing the evaluation set with real, recent examples pulled directly from production — deliberately including hard or edge cases found in traffic — rather than continuing to treat a passing score on a year-old fixed set as ongoing, current proof of quality.
What interviewers look for
- identifies a long-unchanging near-perfect score as a signal worth investigating, not simply reassuring good news
- explains the specific risk — false confidence from a dataset that may no longer represent current production traffic
- proposes periodically refreshing the evaluation set with real, recent production examples, including hard edge cases
Likely follow-up: How would you decide how often to refresh the evaluation set without turning it into a constant moving target that's hard to compare against over time?
Your organization wants to connect an AI agent to dozens of internal tools through a standardized protocol, each tool maintained independently by a different team across the company. What's the governance problem this specific scale creates, that a single team adding one isolated tool integration simply doesn't have?
With dozens of independently-maintained tools, no single team has full visibility into the complete set of capabilities the agent can invoke, or into how those separately-reasonable capabilities might combine in ways no individual team ever anticipated when building their own piece in isolation. A tool that reads customer data and a completely separate tool that sends messages externally, each perfectly reasonable and properly scoped, maintained by two teams who never once coordinated with each other, can combine into a capability — reading sensitive data and then transmitting it externally — that nobody explicitly reviewed or approved as a combination, even though each individual piece passed its own isolated review cleanly. The governance need this creates is a central registry and review process for the full set of capabilities exposed to the agent as a whole, deliberately looking at how capabilities combine, not merely each individual team's own tool reviewed purely in isolation on its own separate merits.
What interviewers look for
- explains no single team has visibility into the full combined capability set across dozens of independently-maintained tools
- gives a concrete example of two individually-reasonable tools combining into a risky, unreviewed capability
- proposes a central registry/review process examining capability combinations, not just individual tool reviews
Likely follow-up: How would you retrofit this kind of central review onto an organization that already has 30 tools connected without any central oversight?
You're designing permission controls for an agent that can take real, consequential actions based on content it reads from untrusted sources. What's the architectural principle that protects against prompt injection here, beyond simply writing a good system prompt telling the model not to be fooled?
A system prompt that instructs the model not to follow instructions embedded in content it reads is a real mitigation, but not a reliable structural control on its own — it reduces how often an injection attempt succeeds, but it doesn't structurally prevent it, because the model itself remains the thing making the final decision, and a sufficiently well-crafted piece of injected content can still occasionally override that instruction the same way it can override any other instruction given to the model. The structural principle is separating 'what the model suggests doing' from 'what ends up happening,' with a real, non-model control point placed deliberately in between — requiring explicit confirmation, whether from a human or a separate rule-based check that doesn't itself rely on the model's own judgment, before any consequential action executes, especially immediately after the agent has just processed untrusted content. This approach deliberately doesn't depend on the model reliably resisting every clever injection attempt every single time — it accepts that the model might occasionally be successfully influenced, and puts an independent gate between that possibly-influenced decision and any action carrying a real, lasting consequence.
What interviewers look for
- explains a system prompt telling the model not to be fooled is a real mitigation but not a structural, reliable control
- proposes separating what the model suggests from what executes, with a genuine non-model confirmation gate in between
- explains this approach accepts the model might occasionally be influenced, and gates the consequential action itself rather than relying on the model resisting every time
Likely follow-up: How would you decide which actions are consequential enough to need this gate, versus low-stakes enough to let the agent execute directly?
You're deciding between a managed API for serving your model and self-hosting an open-source model instead. What's the decision framework here, beyond the common claim that 'self-hosting is cheaper at scale'?
A cost crossover favoring self-hosting at some real volume is a true consideration, but it's only one input among several, not the whole decision on its own — self-hosting also requires the team to own real, ongoing model-serving operations (upgrades, scaling behavior, keeping the serving infrastructure itself reliable), which is substantial continuing engineering work that a managed API quietly absorbs on your behalf as part of what you're paying for. The real decision framework weighs whether the team has the operational capacity to run this reliably day to day, whether data sensitivity or a compliance requirement means the data can't leave your own infrastructure regardless of cost (a real, non-cost-driven reason to self-host independent of volume), and whether sustained traffic volume is high enough that the cost crossover point is truly being reached in practice, rather than assumed from a rough, optimistic estimate that doesn't reflect real sustained usage patterns. A managed API costing more per token doesn't automatically mean self-hosting is the right call if the team lacks the operational capacity to run it reliably.
What interviewers look for
- treats the cost crossover as one real input, not the sole deciding factor on its own
- names the operational capacity to run self-hosted serving reliably as a genuine, ongoing cost beyond raw infrastructure spend
- names data sensitivity or compliance as a potential non-cost-driven reason to self-host regardless of volume
Likely follow-up: The team is confident it has the operational capacity, but has never run production serving infrastructure before. Does that change your recommendation?
Your team wants a single 'average cost per request' number as the feature's main cost metric to track. What's the problem with relying on a single average here, and what would you track instead?
A single average blends together requests with very different costs — a short, simple query and a long, complex multi-turn conversation can differ in real cost by a large factor, and an average completely hides that real spread, in exactly the same way an average latency figure hides a genuine tail-latency problem affecting only a slice of real traffic. A feature can look cheap on average while a meaningful fraction of its real usage is expensive in a way that single blended number never surfaces. Tracking cost distribution instead — a percentile breakdown, or cost segmented explicitly by request type or complexity — reveals which specific usage patterns are driving the spend, which is the information that's actionable for optimization; a single average tells you only that the feature costs something, not where to focus any real effort to improve it.
What interviewers look for
- explains an average blends together requests with different costs, hiding the real spread
- draws the explicit parallel to how an average latency figure hides a real tail-latency problem
- proposes tracking cost distribution/percentiles or segmenting by request type as the actionable alternative
Likely follow-up: How would you decide which specific request type to optimize first once the distribution reveals where the real spend is concentrated?
You're reviewing a teammate's AI-calling Python code in a pull request. What's a specific class of bug you'd deliberately look for that typically wouldn't show up when reviewing ordinary, non-AI application code?
Beyond the missing-optional-field issue, a specific class of bug worth deliberately checking for is code that quietly assumes a single, deterministic, always-correct response shape and doesn't handle the model producing a structurally different but still technically 'successful' response — valid-looking JSON that doesn't quite match the expected schema, a response that got truncated mid-generation because it hit a length limit rather than finishing its thought, or a tool-call response arriving in an unexpected format the calling code never anticipated. None of these look like a traditional error to code that was written assuming deterministic, uniformly-shaped APIs the way most internal services behave — they all return a success status, just carrying content that doesn't match what the downstream code expected to receive, and that specific mismatch between 'the call technically succeeded' and 'the response is usable the way the code assumed' is exactly the bug class that's unique to calling non-deterministic AI APIs, compared to calling a typical internal service.
What interviewers look for
- names a specific AI-specific bug class beyond the missing-field case — mid-generation truncation, schema-mismatched but valid-looking output, or unexpected tool-call format
- explains why these don't look like traditional errors — they return a success status with content that's simply unusable as expected
- identifies this success-but-unusable mismatch as a bug class unique to non-deterministic AI APIs, not typical internal services
Leadership is excited about using an LLM for a new feature and asks you, as the AI engineer, to just 'make it work.' Describe a scenario where your recommendation would be not to use an LLM, and how you'd make that case against real organizational momentum already pushing toward using one.
A strong case against using an LLM is a task that requires deterministic, verifiable correctness on every single instance — exact arithmetic, a legally binding calculation, anything where a single confidently-wrong answer is simply unacceptable and there's no realistic way for a human-review step to catch every single instance at the required production volume. For a task shaped like that, a traditional deterministic system — rule-based logic, a direct calculation, a lookup against an authoritative source of truth — is both meaningfully more reliable and very likely cheaper than wrapping that same problem inside an LLM call and then trying to bolt on verification after the fact to make the result trustworthy. Making this case against genuine organizational momentum means being concrete rather than vaguely cautious: naming the specific failure mode that would occur in practice, estimating how often it would plausibly happen at real production volume, and stating what it would cost when it does — rather than offering a vague, easily-dismissed 'AI can sometimes be unreliable' objection that doesn't engage with the specific, concrete decision being made.
What interviewers look for
- identifies deterministic, verifiable-correctness tasks (exact calculation, legally binding outputs) as the strong case against using an LLM
- explains a traditional deterministic system is both more reliable and likely cheaper for that specific task shape
- proposes making the case with a concrete failure mode, realistic frequency, and real cost — not a vague general caution about AI reliability
Likely follow-up: Leadership still wants to proceed with an LLM for this exact use case despite your recommendation. What's your next move?

