AI Engineering Interview Questions: LLM Observability
Reviewed by Mark Dickie · Last updated
LLM observability is the practice of instrumenting production language-model applications so you can trace requests, measure output quality, detect drift, and debug failures across the full inference pipeline. For interview preparation, you should understand the core telemetry signals (token-level traces, prompt and completion logs, latency percentiles), how evaluation metrics like faithfulness and answer relevance are computed at scale, and what distinguishes LLM observability from traditional application monitoring (non-deterministic outputs, cost-per-request, and the need for semantic evaluation rather than assertion-based checks). You should also be ready to discuss how to instrument a chain or agent, where to sample versus log everything, and how to set up alerts for quality degradation rather than just uptime.
What signals should you monitor in a production LLM system?
A typical LLM observability stack captures both infrastructure-level and quality-level signals. The infrastructure side looks familiar if you have operated any API service, but the quality side is specific to generative workloads.
| Signal Category | Examples | Why It Matters |
|---|---|---|
| Latency | Time-to-first-token, total generation time, p50/p95/p99 | Directly affects user experience and cost |
| Token usage | Prompt tokens, completion tokens, cost per request | Budget tracking and anomaly detection |
| Output quality | Faithfulness, answer relevance, toxicity, hallucination rate | Catches silent quality drift before users complain |
| Input distribution | Prompt length, topic shifts, language mix | Detects data drift and prompt injection attempts |
| Error rates | Timeouts, refusals, rate-limit hits, context-window overflows | Standard reliability monitoring |
How do you trace a multi-step LLM pipeline?
Interviewers often ask you to walk through how you would instrument a Retrieval-Augmented Generation (RAG) pipeline or a multi-agent workflow. A strong answer covers where spans go, what attributes to attach, and how to correlate them:
- Create a root trace span for the entire user request, tagged with user ID, session ID, and the request timestamp.
- Add child spans for each retrieval call, embedding generation, and LLM completion, including the model name, prompt template version, and retrieved document IDs.
- Log the full prompt and completion text on each LLM span, or a sampled subset if volume is high, so you can replay or evaluate offline.
- Attach structured metadata (temperature, top-p, max tokens) so configuration changes can be correlated with quality shifts.
- Export traces to a backend that supports span search and aggregation, such as LangSmith, Arize Phoenix, or OpenTelemetry-compatible collectors.
What is the difference between LLM observability and traditional APM?
Traditional application performance monitoring (APM) assumes deterministic outputs: the same input produces the same response, so you can rely on status codes and latency as proxies for health. LLM systems break that assumption. Two identical prompts can return different completions, and a 200 OK response can still be a hallucination. That means observability for LLMs requires semantic evaluation pipelines, where outputs are scored against reference answers or judged by a second model, alongside the usual infrastructure metrics. If an interviewer asks where to draw the line, the practical answer is that you keep traditional APM for the serving infrastructure and add a quality-evaluation layer on top for the model itself.
Key facts
- Tarmac has 31 AI Engineering interview questions on this topic, 25 of them on this page, at difficulty 1–5 of 5.
- Tarmac tracked 4,175 job postings asking for AI Engineering in August 2026.
- Roles asking for AI Engineering advertise a median base salary of US$180,000, across 757 job postings as of August 2026.
- Tarmac last reviewed these AI Engineering interview questions on 31 August 2026.
At a glance
| Questions | 25 shown · 31 in the bank |
|---|---|
| Difficulty | 1–5 of 5 |
| Formats | Multiple choice, Flashcard, Fill in the blank, True / false, Find the bug, Short answer, Ordering, Multiple answer, Coding exercise |
| Interactive | 1 run your code against tests, in the app |
What you'll review
- ai production
- agent loops
- llm observability
- latency cost
- llm eval
Practice questions
Try one before you open the answer. Pick an option and press Check; it's marked on the spot.
AI Engineering/ai-production
In a production LLM application, what does the temperature sampling parameter primarily control?#
Options
Show answer
The temperature parameter controls the randomness of token selection during generation. A temperature of 0 makes the model deterministic, while higher values increase variability and creativity by flattening the probability distribution over tokens. It does not affect token limits, speed, or concurrency.
Temperature scales the logits before the softmax in LLM decoding. A value of 0 makes the model deterministic (always pick the highest-probability token), while higher values flatten the distribution, increasing randomness and variability in the output. It does not control token limits, generation speed, or concurrency.
AI Engineering/ai-production
What is an LLM hallucination in the context of a production AI application?#
Show answer
A hallucination occurs when the model generates text that sounds plausible and confident but is factually incorrect or entirely fabricated — e.g., inventing citations, misstating facts, or fabricating API behavior. Production systems mitigate this with retrieval grounding (RAG), output validation, and guardrails.
Hallucination is a foundational concept in AI production engineering. It refers to the model producing fluent but ungrounded or false output. Recognizing it is the first step toward deploying mitigation strategies such as RAG, fact-checking layers, and structured output validation.
AI Engineering/agents/agent-loops
Why does every agent run need an id that appears on all of its telemetry?#
Show answer
An agent's unit of work is the run, not the request. One user action becomes a dozen model calls, twice as many tool calls, and possibly sub-agents with their own loops — without a shared id those are unrelated log lines you cannot reassemble. A run id turns them into one story: cost rolls up per user-facing request rather than per API call, a support ticket leads to the exact iteration that went wrong, and sub-agent spend is attributed to the parent instead of vanishing into a separate budget. Add it at the entry point and thread it through every call, tool invocation and delegation.
Request-scoped logging is the default in most services and it is the wrong grain for an agent — it produces per-call records with no way to say which user action they belonged to. Almost every operational question about an agent is run-shaped: what did this run cost, why did it stop, which step went wrong, what did the model see at that point. All of them need the id, and threading it in later means backfilling every call site.
AI Engineering/ai-production
In a Retrieval-Augmented Generation (RAG) pipeline, retrieved documents are typically split into smaller, often overlapping pieces of text before being embedded or passed to the LLM. This process is called _____.#
Show answer
In a Retrieval-Augmented Generation (RAG) pipeline, retrieved documents are typically split into smaller, often overlapping pieces of text before being embedded or passed to the LLM. This process is called chunking.
Chunking is the standard term for breaking long documents into smaller, manageable text segments (chunks) so that each piece fits within embedding model input limits and the LLM's context window. Overlapping chunks help preserve context continuity across boundaries. This is a foundational step in building RAG systems for production.
AI Engineering/ai-production/llm-observability
A user reports that the assistant gave a wrong answer an hour ago, but you cannot reproduce it now. To make incidents like this debuggable, what is the single most important thing your LLM observability must record for every request?#
Options
Show answer
Record the fully-resolved input (the exact prompt after templating and retrieval), the model name and version, the sampling parameters, and the raw completion. The same request can yield different outputs over time because sampling is non-deterministic, a model alias can be repointed, and retrieval indexes change, so the only way to replay a past response is to have logged the exact inputs that produced it. Throughput and IP data are operational metrics that never let you re-run a single call.
The same request can yield different outputs across time — sampling is non-deterministic, a model alias can be repointed to a new version, and retrieval depends on an index that changes — so the only way to replay a past response is to have logged the exact inputs that produced it: the resolved prompt (post-templating, post-retrieval), the model and version, the sampling params (temperature/top_p/seed), and the raw completion (b). Throughput (a) and IP/session data (c) are operational and UX metrics that never let you re-run a single call. Option (d) throws away the input — and the model is not stateless with respect to its prompt: the prompt is the input, so without it there is nothing to reproduce.
AI Engineering/ai-production/llm-observability
In an LLM observability platform (e.g. LangSmith, Langfuse, Arize Phoenix), what does a trace contain and why is the trace-per-request model preferable to logging flat events?#
Options
Show answer
A trace is a tree of spans — one per step: retrieval, LLM call, tool call, and so on — each with its own timing, inputs, and outputs, which shows exactly where latency and failures occur within a multi-step pipeline. Flat event logging can total latency but cannot tell you whether the time went to retrieval or the LLM call. A trace is not a single log line, does not omit internal steps, and has nothing to do with request deduplication.
A trace in LLM observability follows the distributed-tracing model: the root span represents the full user request, and child spans represent each discrete step — retrieval, reranking, each LLM call, each tool invocation. Every span records its own start time, duration, inputs, outputs, token counts, and error state (b). This hierarchy is what flat logging cannot give you: with flat events you can total latency but not tell whether 2 seconds were spent in retrieval or in the LLM call. Structured traces let you immediately pinpoint which stage is slow, which step hallucinated, or where the pipeline branched unexpectedly. The trace is not a single log line (a), does not omit internal steps (c), and has nothing to do with deduplication (d).
AI Engineering/ai-production/llm-observability
Standard application logs (request/response bodies and latency) are sufficient to debug quality regressions in an LLM-powered feature in production.#
Options
Show answer
False. Application logs capture what went in and came out, but LLM quality regressions are rarely diagnosable from raw text alone. You need structured LLM observability: traced spans recording the full prompt, the retrieved chunks and their scores, the model version and parameters, token counts, and a per-turn cost breakdown, plus the ability to replay and diff traces across prompt versions. Without span-level tracing you cannot tell which retrieval step returned bad context or whether a model version change broke something.
Application logs capture what went in and came out, but quality regressions in LLM systems are rarely diagnosable from raw text alone. You need structured LLM observability: traced spans that record the full prompt, the retrieved chunks and their scores, the model version and parameters, token counts, and a per-turn cost breakdown — plus the ability to replay or diff traces across prompt versions. Without span-level tracing you cannot answer "which retrieval step returned bad context?", "did the model ignore the instruction?", or "did a model version change break this?" Tools like LangSmith, Phoenix, or OpenTelemetry LLM semantic conventions provide this layer.
AI Engineering/ai-production/latency-cost
This retries on rate-limit (429) errors but makes the outage worse. Which line is the problem?#
async function callWithRetry(fn, attempts = 5) {
for (let i = 0; i < attempts; i++) {
try {
return await fn();
} catch (err) {
if (err.status !== 429) throw err;
continue;
}
}
throw new Error("exhausted retries");
}Show answer
The bug is on line 7.
Line 7 continues immediately with no delay, so all five attempts fire back-to-back in microseconds. On a 429 the provider is telling you to slow down; retrying instantly hammers the endpoint and can extend or worsen the rate-limit window — a self-inflicted thundering herd. The fix is exponential backoff with jitter (e.g. await sleep(base * 2 ** i + random)), and ideally honoring the Retry-After header the API returns. Tight retry loops without backoff are a frequent cause of cascading failures under load.
AI Engineering/ai-production/llm-observability
Your LLM bill is rising and you don't know why. What should production LLM observability track per request so you can attribute and control cost, and which dimensions let you find the expensive paths?#
Show answer
Log token usage split into input (prompt) and output (completion) tokens per call, the model used, and the computed cost (tokens times the per-model rate, accounting for cached vs uncached input tokens). Then attach dimensions you can slice by: which feature or endpoint, user or tenant, prompt version, and trace id, plus latency. With that you can aggregate cost by model, by feature, and by user to find the expensive paths — for example a single feature sending huge prompts, a retrieval step stuffing too many tokens into context, an agent looping and re-calling the model, or traffic that should route to a cheaper model. Separating input from output tokens matters because output tokens are usually billed much higher, and tracking cached vs uncached input shows whether prompt caching is actually saving money.
Cost attribution needs per-request token accounting: input vs output tokens (output is typically billed at a higher rate), the model, cached vs uncached input tokens, and the derived dollar cost. Tag each record with feature/endpoint, user/tenant, prompt version, trace id, and latency so you can aggregate and slice. Those slices surface the expensive paths — an over-stuffed retrieval context, an agent that loops and re-invokes the model, a feature using an overpowered model, or a workload that should fall back to something cheaper. Without input/output separation and per-dimension tagging, a rising bill is a mystery; with them it's a query.
AI Engineering/ai-production/llm-observability
What is an LLM trace, and what should a single span record to be useful for debugging a production issue?#
Show answer
A trace represents one end-to-end request through an LLM application (e.g. one RAG query), composed of spans — timed segments for each logical step (retrieval, reranking, model call, tool call, post-processing). A useful span records: inputs (the prompt or query, parameters like temperature and model), outputs (the completion or tool result), timestamps (start, end, latency), token counts (prompt + completion tokens), and metadata (user/session id, environment, model version). When debugging, this lets you reconstruct exactly what the model saw, how long each step took, which step introduced an error, and what the call cost — without relying on client-side logging that may differ from what the provider received.
Traces decompose a request into spans, and each span must capture inputs, outputs, timing, and token counts to be actionable. Without structured tracing, post-mortem debugging of LLM failures is guesswork — you can't reconstruct the exact prompt the model saw.
AI Engineering/evaluation-safety/llm-eval
Order the stages of standing up evaluation for a new LLM feature so you can ship and iterate with confidence.#
Put these in order
Show answer
Stand up evaluation in this order:
- Define the task and success criteria / metrics
- Build a representative eval dataset with expected outcomes
- Run candidate prompts/models against the dataset and score them
- Compare results and pick the best variant
- Monitor live outputs in production and feed failures back into the eval set
Evaluation starts by defining what good means (criteria/metrics), then assembling a representative dataset of inputs with expected outcomes. You score candidate variants against it, compare and select the winner, and finally monitor in production, routing real-world failures back into the dataset so the eval set hardens over time. Skipping the dataset step is the classic mistake — you can't iterate on quality you don't measure.
AI Engineering/ai-production/llm-observability
In LLM observability, a _____ is the top-level unit of work (e.g. one user request), while a _____ is a child unit within it (e.g. a single retrieval step or model call). Together they form a distributed - tree that lets you measure latency and cost at every stage.#
Show answer
In LLM observability, a trace is the top-level unit of work (e.g. one user request), while a span is a child unit within it (e.g. a single retrieval step or model call). Together they form a distributed trace-span tree that lets you measure latency and cost at every stage.
Borrowed from distributed systems (OpenTelemetry), a trace captures the full lifecycle of a request, while nested spans represent individual operations — an LLM inference call, a vector search, a tool execution. LLM observability tools (LangSmith, Langfuse, Phoenix, etc.) attach token counts, latency, and model parameters to each span, enabling you to pinpoint which stage is slow or expensive without guessing.
AI Engineering/ai-production
You deploy a supervised model trained on historical data into production. Over time the live input feature distribution begins to diverge from the training distribution, even though labels are not immediately available. What is the standard term for this phenomenon, and name two statistical tests or metrics commonly used to detect it?#
Show answer
The phenomenon is called data drift (or covariate drift / input drift). Two commonly used detection methods are the Kolmogorov-Smirnov (KS) test and the Population Stability Index (PSI). Other valid examples include the Wasserstein distance, KL divergence, or Jensen-Shannon divergence.
When the distribution of input features in production shifts away from the training distribution — without the labels necessarily being available yet — this is called data drift (also covariate drift or input drift). Common detection techniques compare the statistical distribution of a baseline (training) sample against a recent live sample: the Kolmogorov-Smirnov (KS) test for continuous features, the Population Stability Index (PSI), and information-theoretic measures such as KL divergence, Jensen-Shannon divergence, or the Wasserstein distance. The answer must name the phenomenon and at least two of these methods.
AI Engineering/ai-production/llm-observability
Your RAG pipeline's p99 cost per request spiked 4× overnight with no code deployment. LLM observability shows the p99 input-token count also jumped 4× at the same time. What is the most likely root cause to investigate first?#
Options
Show answer
Investigate the retrieval layer first: it likely started returning far more chunks per query, perhaps from a changed similarity threshold or a reindexing that inflated result counts. Cost tracks total tokens, and the data shows input tokens spiked 4×, which in a RAG pipeline are dominated by retrieved context. A provider price change would not move token counts, a missing max_tokens cap affects output not input, and user query length is negligible against the bulk of retrieved context.
Cost is proportional to total tokens (input + output); the observability data shows input tokens spiked 4×, not output tokens. In a RAG pipeline, input tokens are dominated by the retrieved context chunks stuffed into the prompt. A 4× jump in input tokens with no code change almost always means retrieval is now returning many more chunks — a shifted similarity threshold (e.g. a higher top_k or a lower score cutoff), a reindexing that changed result counts, or a misconfigured reranker (b). Provider price changes (a) would not change token counts. A missing max_tokens cap (c) affects output tokens, not input. User query length (d) has a negligible effect on total input tokens when the bulk of the prompt is retrieved context.
AI Engineering/ai-production/llm-observability
You instrument your production LLM app with thumbs-up/thumbs-down feedback buttons. Over time you notice the thumbs-down rate is 12%, but examining those flagged traces reveals that 60% of the thumbs-downs are on answers that are actually correct. What is the most actionable conclusion?#
Options
Show answer
The feedback signal is noisy — user ratings conflate quality with user preference — so flagged traces must be reviewed by a human rater before being used for eval or fine-tuning. A 60% false-negative rate on flagged traces shows users click thumbs-down for reasons other than incorrectness, such as tone or format. Taking all thumbs-downs as negative training examples would poison the signal with clean cases, and acting on them without review ignores the 40% that are real errors.
User feedback is a leading indicator, not ground truth. The 60% false-negative rate on flagged traces shows that users are clicking thumbs-down for reasons other than factual incorrectness — unhelpful tone, unexpected format, a correct answer that contradicts what the user believed, or accidental clicks. Taking all thumbs-down responses as negative training examples (a) would introduce 60% clean examples as false negatives, directly degrading the fine-tuning signal. Acting on thumbs-downs without a human review step (c) has the same flaw and ignores the 40% that are real errors. Industry benchmarks (d) are irrelevant here — the finding is about signal quality, not the rate itself. The right action is to put flagged traces through a human (or LLM-judge) review layer that separates actual quality failures from user-preference mismatches before using the data for evaluation or training (b).
AI Engineering/ai-production/llm-observability
You are adding tracing and metrics to a production LLM service so you can spot quality regressions and runaway cost. Which of the following are genuinely useful signals to capture per request?#
Options
Pick every one that applies.
Show answer
The genuinely useful per-request signals are latency split into time-to-first-token and total generation time, input and output token counts with the dollar cost derived from them, the tool-call steps and which retrieved chunks were placed in context for agent or RAG calls, and the finish or stop reason. These explain quality and cost and let you replay a bad answer. The hosted API's GPU die temperature and kernel scheduling belong to the provider's hardware and tell you nothing about your output or bill.
Useful LLM telemetry is the data that explains quality and cost. TTFT-vs-total latency (a) separates a slow-to-start model from a long generation. Token counts (b) are the unit of both cost and context pressure. The agent's tool steps and the exact retrieved chunks (c) are what you replay to debug a wrong answer in a RAG/agent flow. The finish reason (d) distinguishes a clean completion from a truncated or filtered one — often the root cause of a 'cut off' answer. The GPU temperature and scheduling (e) belong to the provider's hardware that you neither see nor control on a hosted API, and tell you nothing about output quality or your bill.
AI Engineering/ai-production/llm-observability
You are instrumenting a multi-step LLM pipeline (query → retrieval → reranker → generation). Which of the following are best practices for distributed tracing of LLM pipelines? Select all that apply.#
Options
Pick every one that applies.
Show answer
The best practices are propagating a single trace ID through every step so the full path is one queryable trace, logging the exact prompt and raw completion per LLM call with PII redacted where required, recording latency and token counts at each span so bottlenecks are attributable, and tagging spans with metadata to filter by model version, prompt template version, and retrieval config. Sampling 100% of traces in all environments is not a best practice — it is prohibitively expensive; standard practice is tail-based or probabilistic sampling in production with full capture for errors.
A trace ID that spans every pipeline step (a) is the foundation — without it, individual span logs are islands you cannot correlate. Logging the exact injected prompt and raw completion (b) is what lets you replay and debug a specific bad output; PII redaction is the compliance control, not a reason to omit the log. Per-span latency and token counts (c) let you identify whether the bottleneck is retrieval, the reranker, or generation. Version metadata on spans (e) is critical for before/after comparisons when a prompt template or model changes. Sampling 100% in all environments (d) is not a best practice — it is prohibitively expensive at production scale; the standard approach is high sampling in dev/staging and tail-based or probabilistic sampling in production, with 100% capture for errors.
AI Engineering/ai-production/llm-observability
Why is request-level logging insufficient for debugging a multi-step LLM agent, and what does trace/span-based observability (e.g. LangSmith, Langfuse, OpenLLMetry) capture that you specifically need?#
Show answer
A single agent request fans out into many LLM calls, tool invocations, and retrieval steps, so one log line for the whole request hides where it actually went wrong. Trace/span observability records the request as a tree: a top-level trace with nested spans for each step — every prompt and completion, each tool call and its arguments and result, retrieval queries and the passages returned, token counts, latency, and cost per step. That's what you need to debug an agent: you can see the exact prompts and intermediate outputs, find which step produced the bad result (a wrong tool call, an empty retrieval, a runaway loop), and attribute latency and cost to specific spans. It also gives you the raw material for evals and for spotting regressions when you change a prompt or model.
One agent request is really a tree of LLM calls, tool invocations, and retrievals, so request-level logging tells you it failed but not where. Trace/span instrumentation models the run as a top-level trace with nested spans per step, capturing each prompt+completion, tool call arguments and results, retrieval queries and returned passages, plus per-step token counts, latency, and cost. That granularity is exactly what agent debugging requires — you can inspect intermediate outputs, localise the failing step (bad tool call, empty retrieval, a loop), and attribute latency/cost. The same traces feed eval datasets and regression detection across prompt/model changes.
AI Engineering/ai-production/llm-observability
What signals should you collect in production to monitor LLM output quality over time, given that you usually can't run a full eval on every request?#
Show answer
Layer three tiers: (1) Implicit behavioral signals — thumb up/down, copy-to-clipboard, regenerate, follow-up clarification questions. These are cheap and high-volume but noisy and sparse. (2) Automated heuristic checks — length, refusal detection, hallucination guard outputs, schema validation failures, profanity/PII filters. Run on every request; catch obvious quality drops. (3) Sampled LLM-as-judge scoring — run a judge model on a small percentage of traffic against a rubric (faithfulness, relevance, tone). Expensive per call but the only signal sensitive to subtle quality regressions. Alert when heuristic failure rates spike; do trend analysis on sampled judge scores; use implicit signals to weight sampling toward bad-outcome cases.
Full eval coverage on production traffic is cost-prohibitive, so effective monitoring stacks cheap always-on heuristics, sampled judge scoring, and implicit user feedback — each catching different failure modes at different fidelities.
AI Engineering/ai-production/llm-observability
Order the steps to add end-to-end observability tracing to an existing LLM feature in production.#
Put these in order
Show answer
Add end-to-end tracing in this order:
- Instrument the code to emit a trace span for every LLM call, capturing prompt, completion, and latency
- Propagate a single trace-id through the full request so all spans from one user turn are correlated
- Ship the spans to an observability backend (LLM-aware or general-purpose)
- Build dashboards or alerts for the metrics that matter: TTFT, total latency, cost, error rate
- Define sampling rules to control trace volume and cost in high-traffic production
Observability is layered bottom-up: first instrument individual LLM calls to capture the raw signal (prompt, completion, latency, token counts); then propagate a trace-id so multi-step agent calls form a coherent trace rather than isolated records; next export to a backend that can store and query spans at scale; then surface dashboards and alerts for operationally critical metrics; finally configure sampling because capturing every token of every call at volume is prohibitively expensive — sampling keeps costs manageable while preserving statistical coverage of failures.
AI Engineering/agents/agent-loops
An agent has called search(query="q3 revenue") with byte-identical arguments on five consecutive iterations, each returning the same result, and shows no sign of stopping. Which change most directly catches this class of stall?#
Options
Show answer
Hash each (tool name, arguments) pair and break or intervene when the same hash repeats with no new information in between. An identical call returning an identical result adds nothing to the context, so the next iteration decides the same way — a fixed point the model cannot escape unaided. Temperature 0 makes repetition more likely, not less; raising the step cap buys more identical iterations; and a bigger context window does not help, because the observations are already visible.
A repeated call with identical arguments and an identical result adds no information, so the next iteration faces the same context and makes the same decision — a fixed point the model cannot escape by itself. Hashing the call signature detects exactly that: same tool, same arguments, nothing new in between. What you do on detection is a design choice (break with a partial answer, inject a nudge that the tool has been tried, escalate to a human), but you cannot act until you detect. Temperature 0 (b) makes the loop more deterministic and so more likely to repeat — a genuinely tempting wrong answer, because low temperature is the right default for most tool-calling. Raising the step cap (c) buys more identical iterations at linear cost. A bigger window (d) misdiagnoses the problem: the observations are already visible; that is why the model keeps concluding the same thing.
AI Engineering/agents/agent-loops
You are adding per-iteration tracing to an agent loop so a bad run can be diagnosed a week later. Which should each iteration's span carry? Select all that apply.#
Options
Pick every one that applies.
Show answer
Record the tool calls with their arguments, the results truncated to a recorded limit, per-iteration token counts, and a run id shared by every span that ties the run back to the originating request. Those four answer the questions you will actually have: what the model decided, what it learned, which iteration cost the money, and how to get from a ticket to the trace. Storing every full rendered prompt indefinitely is the trap — prompts contain whatever the run touched, so that turns the trace store into an unclassified copy of production data. Truncate or hash by default, keep full prompts behind a short window, and redact at capture.
The four that belong are the ones that answer the questions you will actually have. Calls and arguments (a) show what the model decided; results (b) show what it learned, truncated because one large payload should not blow up your trace store; token counts (c) turn 'this run was expensive' into a specific iteration; and a shared run id (d) is what makes the spans a run rather than a pile of unrelated events, and what lets you get from a support ticket to the trace. Option (e) is where teams get into trouble: prompts contain whatever the run touched — customer records, documents, credentials pasted into a chat — so indefinite full-fidelity retention turns your observability stack into an unclassified copy of production data with its own retention and access-control obligations. Store a hash or a truncated rendering by default, keep full prompts behind a short window and explicit access, and redact at capture rather than intending to clean up later.
AI Engineering/agents/agent-loops
A customer disputes what your agent did last Tuesday. You re-run the same request today and get a different sequence of tool calls. Name the reasons that can happen, and say what you should have recorded to answer the customer instead.#
Show answer
Re-running is not replay. Sampling makes output non-identical even at temperature 0, because batching and floating-point reduction order vary provider-side; the model may have been updated; your prompt, tool descriptions or tool set may have changed with a deploy; and the tools return live data, so the world the agent read is not the world it reads now. The answer is not to reproduce the run but to have recorded it: a per-iteration trace under a run id with the rendered prompt, each call and its arguments, the results as returned at the time, token counts, the model version, and the stop reason.
The instinct to reproduce a past run is the wrong reflex, and the question is designed to catch it. Four independent things drift — provider-side sampling non-determinism, model updates, your own deploys, and the underlying data the tools read — so a re-run months or even minutes later is evidence about today, not about Tuesday. Anything that matters after the fact has to have been captured at the time. The model version belongs in the trace for exactly this reason, and it is the field teams most often omit until an incident makes them wish they had it. There is a compliance edge worth knowing too: recorded prompts and results contain whatever the run touched, so this trace is production data with retention and access obligations, not just debugging output.
AI Engineering/agents/agent-loops
Implement rollup_cost(spans). A run's telemetry is a flat list of spans; each is a dict with id, parent (an id, or null for a root) and tokens (int). A parent agent's spans have child spans beneath them when it delegated to a sub-agent, nested to any depth.#
Starter code
def rollup_cost(spans):
# TODO: attribute every span to the root it descends from
return {s["id"]: s["tokens"] for s in spans if s["parent"] is None}Your solution must pass
- single root, no children
- one level of delegation
- nested delegation
This one is written and run, not read. Solve it in the app and your code is executed against these tests and the hidden ones.
AI Engineering/ai-production/llm-observability
An LLM observability alert fires indicating a spike in user-reported bad answers. Order the triage steps from alert to actionable fix.#
Put these in order
Show answer
Triage the alert from coarse signal to fix in this order:
- Query the trace backend to isolate the request cohort that triggered the spike
- Inspect individual traces to identify which pipeline stage (retrieval, prompt construction, generation) correlates with failure
- Sample failing completions and classify the failure mode (hallucination, retrieval miss, format error, etc.)
- Reproduce the most common failure locally with a minimal prompt and document the root cause
- Ship a targeted fix (prompt patch, retrieval config change, or guard) and confirm the alert clears on the next production window
Triage moves from the coarse signal to the atomic cause: isolate the cohort (time window, model version, experiment arm) from traces so you are not analysing noise; find the stage where the failure is concentrated — retrieval misses and generation errors need different fixes; classify the failure mode by sampling actual bad completions, because the same symptom can have multiple causes; reproduce locally to confirm the root cause in a controlled environment before writing any fix; and verify the fix in production by confirming the alert clears — a fix that only passes local evals but leaves the alert firing means something else is wrong.
Related interview questions
Job market
See ai-engineering salaries and hiring demand from live job postings.
The other 6 questions
This page shows 25 and marks what you pick. That's as far as a page can go. A free account opens the other 6 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.
Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan