TL;DR: A failure rate that appears only under load is almost never randomness; it is a condition that load makes more common. Slice the failed calls by stop reason, model and version, code path and the field that failed. The usual culprits, in order: output truncated at the token limit, a fallback or retry path without constrained decoding, a schema feature the provider does not enforce, and a streaming parser reading arguments before the last chunk. Fix the cause and keep the rate as a metric.
How to approach it
Treat it as an investigation with data, and say what you would pull first: every failed call in the last day with its stop reason, model id and version, the code path that produced it, the raw output, and which validation rule failed. Ask what "under load" changes in this system: longer queues, timeouts, fallbacks to another model, smaller token limits to protect latency.
A strong answer
Group the failures before forming a theory. A few lines over the call log usually decide it:
from collections import Counter
calls = (
[{"ok": True, "stop": "tool_use", "model": "m-large", "path": "primary"}] * 940 +
[{"ok": False, "stop": "max_tokens", "model": "m-large", "path": "primary"}] * 22 +
[{"ok": True, "stop": "tool_use", "model": "m-small", "path": "fallback"}] * 30 +
[{"ok": False, "stop": "tool_use", "model": "m-small", "path": "fallback"}] * 8
)
failed = [c for c in calls if not c["ok"]]
print(f"{len(failed) / len(calls):.1%}") # => 3.0%
print(Counter((c["stop"], c["path"]) for c in failed).most_common())
The breakdown prints [(('max_tokens', 'primary'), 22), (('tool_use', 'fallback'), 8)]: the 3% is two different bugs, neither of them randomness.
Cause 1: truncation. Twenty-two failures stopped on max_tokens. The output is a valid prefix of a JSON object that never closed. Under load, the team lowered the output limit to protect latency, or contexts grew and squeezed the budget. Fix: raise the limit for tool calls, shrink the argument object (fewer free-text fields, shorter enums), and handle a length stop explicitly so it is retried with more room instead of fed to the parser.
Cause 2: an unconstrained path. Eight failures came from the fallback model, which the router uses when the primary is saturated. The fallback request was built without the strict schema setting, so it produces free-form JSON that sometimes misses a required field. Fix: route every path through the same request builder, and test the fallback with the same suite.
Causes to rule out when the slices point elsewhere:
- A schema feature the provider does not enforce: a
pattern, a deeponeOfor numeric bounds that pass through unconstrained. Failures then cluster on one field. Flatten the schema or validate that field in the harness. - A streaming parser that assembles arguments from chunks and parses on a timer or on a partial frame. Failures cluster on long arguments and on slow responses. Parse only after the call-complete event.
Each fix gets a regression test and a dashboard line: validation failure rate per model version and path, with stop reasons, so the next change that reintroduces either cause shows up the same day.
What interviewers probe next
"Could you just repair the JSON with a retry?" A bounded repair turn hides the symptom for the fallback case and does nothing for truncation (the model will truncate again at the same limit). Fix the cause; keep repair for the residual.
"What if the failures were spread evenly across every slice?" Then look at the inputs: a particular kind of request (very long user messages, many items) that produces large arguments, or a recent change to the schema. An even spread across models and paths points at the content, not the plumbing.
"How would you have caught this before production?" Load tests that run the full routing logic including fallbacks, and an eval slice with long inputs designed to stress argument size.
How it's scored
Weak: Calls it model randomness, raises the retry count or patches the JSON with a regex.
Hire: Pulls the failed calls, checks stop reasons and finds truncation or an unconstrained path, and fixes it at the source.
Strong Hire: Slices by stop reason, model version, code path and field before theorising, finds that one rate hides several causes, fixes each (token limits and argument size; one request builder for every path; schema simplification; parse-on-complete), and adds per-path metrics and load tests that include fallbacks.
Common mistakes
- Treating a 3% aggregate as one problem.
- Forgetting that fallback and retry paths are separate code paths with separate configuration.
- Parsing a length-stopped response as if it were complete.
- Fixing it once without a metric, so it returns with the next model or routing change.