Claude Certified Architect – Foundations Practice Question 66: Max Tokens Not Length Control

Claude Certified Architect, Foundations · Test 7 · question 6 of 10

Prompt Engineering & Structured Outputeasy

A help-desk assistant returns answers of several paragraphs, but the UI has room for about three sentences. A developer sets max_tokens to 60 to force short replies. Now many answers end mid-sentence and the responses report stop_reason "max_tokens". What is the right way to get concise, complete answers?

Select one answer
Show answer and explanation

Answer:

  • C. Ask for the desired length and format in the prompt, and keep max_tokens as a ceiling with headroom

C is correct. The API reference describes max_tokens as the absolute maximum number of tokens to generate before stopping; the model does not see it as a target and does not plan a shorter answer to fit. When the limit is reached, generation stops and the response has stop_reason: "max_tokens", which the stop-reason docs treat as a truncated response. Length is controlled by the prompt, for example "Answer in at most three sentences, plain text", while max_tokens stays a safety ceiling set with headroom above the expected length.

A is wrong because a lower cap just truncates more answers. B is wrong because temperature affects randomness in sampling, not how long the answer is. D is wrong because it hides the truncation and discards content, and answers can still be cut off before they make their point.

Reference: Handling stop reasons and Messages API - max_tokens

Practice Test 7 ›

Study guides for Claude Certified Architect, Foundations