Skip to content

Model API Foundations

16 questions
0 of 16 done · 5 unlocked for you
DONEUNLOCKEDLOCKED

Model API Foundations Interview Questions

What the harness has to read, build and handle on every model call, before there is a loop at all: the four fields in a response and the stop reason the loop branches on, the message list and the pairing rule for tool results, sampling settings and why temperature zero is not determinism, streaming deltas and tool-call fragments, provider wire differences behind one adapter, rate limits and retries inside a run, per-step deadlines and max_tokens, choosing a model by agent-shaped probes, and the failure modes a capable model still has inside a loop.

Worked answers that trace the run, put each decision on the right side of the authority line, and end with the follow-ups and scoring a panel applies.

You have 5 free answers unlocked here.Sign in free for 1 more · 10 are premium.
01–07Foundationsthe mechanisms behind this topic, and the terms a panel uses for them0/7 done
08–13Core questionsthe questions this topic is most often tested on, with full worked answers0/6 done
14–16Field scenariosopen-ended designs, incidents and trade-offs where you must state what is missing0/3 done
PRACTICE TESTStudied this track? Prove it: a timed Model API Foundations test.fresh items every sitting · explanations for every answer · easy items free with an accountStart →

The concepts behind Model API Foundations

Lessons behind these answers. The opening lessons are free; deeper ones are Premium.

Foundational
What a Model Call Returns to the HarnessEvery model call returns four things the harness must read before it acts: the content (text, tool calls or both), the stop reason (finished, hit the token limit, wants tools, was filtered), the usage (input and output tokens, which is the bill and the context size for the next turn) and, with some providers, a refusal or filter signal. Providers name these differently, so the harness normalises them into one shape at the boundary. The commonest bugs in first harnesses come from reading only the text: treating a truncated reply as finished, treating an empty content field as an empty answer when the model asked for a tool, and never recording usage so nobody can budget.
Foundational
The Message List the Harness BuildsEvery model call sends a list of messages with roles: system or developer instructions, user turns, assistant turns (which may carry tool calls) and tool results tied to the call they answer. The provider renders that list into one token sequence with a chat template, so what the model actually reads is a string with role markers, not a list. The list has rules the harness must keep: every tool result pairs with a call id in the previous assistant turn, nothing is dropped from inside a call-and-result pair, and the order of roles follows the template. A harness that trims history by slicing messages breaks these rules and gets a rejected request or a model that reads an orphaned result as noise.
Foundational
Determinism Is a Setting, Not a GuaranteeSampling settings decide how a model turns its per-token probabilities into one token. Low temperature and a seed make tool calls and structured output repeatable enough to test; higher temperature belongs only where you want several different candidates. But temperature 0 is not bit-for-bit deterministic on real serving stacks: batching with other requests and cache reuse change the arithmetic, and when two tokens are nearly tied the choice flips and the rest of the output with it. For an agent that compounds across many steps, this means a single passing run proves little. Tests use a scripted model; evals use repeated runs and report a rate with a denominator.
Core
Sign in
Streaming Inside the LoopA streamed model response arrives as server-sent events carrying deltas: fragments of text, and fragments of tool-call arguments that the harness must reassemble by index before it can dispatch anything. Streaming cuts time to first token for prose turns and changes nothing for tool turns, where the harness has to wait for the complete call anyway. What an agent's client actually needs is a stream of loop events (step started, tool requested, result arrived, final answer, stopped with reason), produced by the loop and consumed by any UI, and a cancellation path that stops the producer rather than just closing the tab. Parsers must handle split UTF-8 bytes, events split across chunks and the final usage event that arrives after the last token.
Advanced
🔒 Premium
One Loop, Many Providers: The Adapter LayerProviders agree on the mechanism of tool calling and disagree on the wire: where the system prompt goes, whether tool calls are fields or content blocks, where tool results are placed and how they are matched to calls, how stop reasons are spelled, whether parallel calls are allowed and how strict schema enforcement is requested. A harness that lets those differences into the loop has provider-shaped bugs everywhere. The alternative is one neutral set of types (message, tool call, tool result, completion) that the loop, the tracer, the budgets and the tests use, and an adapter per provider that converts at the boundary. The adapter is small, it is where every provider-specific trap lives, and it is tested with recorded fixtures and a round-trip property rather than with live calls.
Advanced
🔒 Premium
Rate Limits, Retries and Backoff Inside a LoopModel calls fail in three families: rate limits and overloads (retry after waiting), transient network or server errors (retry with backoff and jitter) and client errors (do not retry; fix the request). A model call is safe to retry because it has no side effect, which is what makes it different from a tool call. The retry budget belongs to the run, not the call, because an agent that retries each of forty steps three times has multiplied a hiccup into a two-minute stall. Honour Retry-After, use full jitter so a fleet does not retry in step, keep a token bucket in front of the provider so you stop hitting the limit, open a circuit when a dependency is down, and when retries are exhausted end the step with a reason the harness records rather than a stack trace the model reads.
Advanced
🔒 Premium
Timeouts, max_tokens and Deadlines per StepThe latency of one model call is roughly a fixed overhead, plus the input tokens divided by the prefill speed, plus the output tokens divided by the decode speed. Inside a loop that arithmetic repeats per step, so a run has a deadline, each step gets a share of it, and max_tokens for a step follows from the time left rather than from a default. A reserve is held back for a final wrap-up call with no tools, so a run that is out of time still returns a grounded partial answer instead of nothing. Timeouts are classified as transient and retried within the run budget, a stop reason of length triggers a continuation or a retry with more room, and a reply cut off mid-JSON is detected by the stop reason and never repaired into a wrong object.
Advanced
🔒 Premium
Choosing a Model for Agent WorkChoosing a model for an agent is a two-stage decision. First a screen on hard requirements: native tool calling with parallel calls, structured output, a context window large enough for the run, a latency floor that fits the deadline, data residency, price per step and a credible fallback. Then a score on probes shaped like agent work rather than chat: picking among similar tools, filling arguments from messy input, declining to call a tool when none fits, recovering from an error observation, holding a constraint across a long context, and following the output format every time. Probes with a ceiling effect separate nobody; the weights are a written decision; the chosen model id is pinned; a provider's deprecation is treated as a release that reruns the whole comparison.
Advanced
🔒 Premium
Why Capable Models Still Fail Inside a LoopA frontier model inside a loop fails in ways that a stronger prompt does not fix, because they follow from how language models work. It agrees with a user who pushes back and changes a correct tool choice. It uses a constraint stated early less reliably once the context is long. It trusts its training-time memory over a fresh tool result, or trusts a tool result that is wrong. It writes an observation it never received, or declares a task complete that is not. And every one of these compounds across steps: a 2% per-step rate is a 45% failure rate over thirty steps. The engineering response is the same for each: a probe that triggers the failure with an automatic check, run on every candidate and every release, and a harness control that does not depend on the model behaving.
Unlock all 16 answers · $25

All 19 topics with every worked answer, all lessons and courses, the full practice bank, and anything new that appears during your access.

6 months · One payment · No auto-renewal