Inference, Serving & Production·Question 62 of 76Advanced

A model can now return close to a million output tokens from one request, as with Gemini 4 Argon's long-decode mode. What changes for serving, streaming, timeouts, cost control and evaluation?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Gemini 4 Argon has a 1,048,576-token unified input-output limit. Default synchronous output is 65,536 tokens, and a long-decode mode with a continuation protocol allows up to about 1M output tokens. Current Claude models accept up to 300K output tokens on the Message Batches API with a beta header. At that length a request is no longer a request. It is a job.

Full worked answer with diagram

Gemini 4 Argon has a 1,048,576-token unified input-output limit. Default synchronous output is 65,536 tokens, and a long-decode mode with a continuation protocol allows up to about 1M output tokens. Current Claude models accept up to 300K output tokens on the Message Batches API with a beta header. At that length a request is no longer a request. It is a job.

Time. At 100 tokens/s, 1M tokens takes about 2.8 hours; at 50 tokens/s, about 5.5. Everything built around request-response breaks:

  • Load balancer and proxy idle timeouts.
  • Client retries that restart from zero and double the bill.
  • Deploys that kill in-flight streams.
  • Rate limits measured per minute.

Treat it as a durable job. Checkpoint generated output server-side, use the provider's continuation protocol (or your own: resend prompt plus output so far and continue), and make the client reconnect to a stream position rather than reissue the request.

Self-hosted serving. One sequence holds a KV allocation that grows to the full window for hours. That is concurrency taken from everyone else, and a preemption target the scheduler will eventually pick. Run long-decode work in a dedicated pool or priority class, with preemption that swaps KV to host memory instead of discarding hours of work. Use chunked or paged KV with offload, and bound concurrent long jobs per node explicitly.

Cost control. At an illustrative $10 per million output tokens, one full-length response is $10, before reasoning tokens or surcharges. A bug that loops it across a tenant's traffic is a real incident. So:

  • Set per-request max_tokens deliberately, not to the maximum.
  • Set per-tenant budgets on burn rate.
  • Detect degeneration online: n-gram repetition, falling novelty, format breakage. Stop early, because the most expensive tokens are the ones after the model starts looping.
  • Prefer the batch API for anything nobody is watching.

Evaluation. Nobody reads a million tokens, so:

  • Structural checks: the outline is followed, cross-references resolve, the schema stays valid to the end.
  • Task-level checks where possible: the generated codebase builds and passes tests, the dataset passes validators.
  • Sampled sections graded for quality and instruction adherence, deliberately weighted to the late part of the output, where drift shows up.
  • A baseline: an agent loop that plans, then generates bounded sections. It is checkpointable, parallelisable and cache-friendly. One long decode has to beat it on global coherence to justify itself.

Long single decodes win when coherence across the whole output matters and re-prefilling for each section would cost more than it saves. Otherwise the bounded-section loop is usually the better design.

Worth sketching. Optional, but it shows the job-not-request shape the interviewer is looking for.

flowchart TD
    J["Submit long-decode job"] --> G["Generate a segment"]
    G --> K["Checkpoint output and position"]
    K --> Q["Quality and budget checks"]
    Q -->|"looping or over budget"| X["Stop early and report"]
    Q -->|"healthy, not done"| C["Continue from checkpoint"]
    C --> G
    Q -->|"done"| F["Assemble, validate, deliver"]

What a good answer covers

  • Gemini 4 Argon has a 1,048,576-token unified input-output limit
  • Default synchronous output is 65,536 tokens, and a long-decode mode with a continuation protocol allows…
  • Current Claude models accept up to 300K output tokens on the Message Batches API with a beta header
  • At that length a request is no longer a request
  • At 100 tokens/s, 1M tokens takes about 2.8 hours; at 50 tokens/s, about 5.5

Key terms: Time · Self-hosted serving · Cost control · Evaluation

Interviewer follow-ups to expect

  1. How would you detect degeneration cheaply while streaming?

  2. What should the client see if the job dies at token 600K?

  3. When is a plan-then-generate agent loop strictly better than one long decode?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep