esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

How Do You Control Answer Length and Verbosity?

How to make an AI reply the right size with a clear target, a token cap and a check in code, explained simply for your AI interview.

In short

Ask for a clear length and shape in the prompt, set a token cap with room to spare, and check the stop reason in code. A cap only cuts a reply off when it runs out, so the target does the real work.

12 min readBeginnerOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

A token cap is a hard ceiling on how long one reply can run. It does not make the model shorten its answer, so a long reply just gets cut off. I put the length in the prompt, with a target and a shape, keep the cap with some room to spare, and check the stop reason in code, with one shorter retry if the reply was cut.

What does controlling length mean, in plain words?

Length has two parts. One is how many words the reply runs to. The other is the padding around the answer: a greeting, a repeat of the question, a summary at the end. You can steer both with the prompt, but only a token cap gives you a hard ceiling on the total.

Think of a claims adjuster asked for a note that fits the case screen. A good adjuster writes to the box. A new hire who was never told the box size writes two pages, and the screen cuts off the end. A model acts like that new hire unless the prompt names the size. A prompt for an insurer might read: "Summarise this claim in 60 words or fewer for the case screen."

Key words

Token
A small piece of text, often a word or part of one, that the model writes one at a time.
Token cap
The most tokens one reply may write, set by your code. In Anthropic's API (the interface your code calls) it is max_tokens.
Stop reason
The note the API sends back saying why the reply ended: finished, or the cap was hit.
Target
The length and shape you ask for in the prompt, such as three bullets or 60 words.
Verbosity
How wordy a model is by default. Some vendors offer a setting that changes it.

Does a token cap make the reply shorter?

No. A cap is a ceiling, not an instruction. Anthropic's docs call max_tokens "a hard per-request cap on generated tokens", and when the reply reaches it, the API stops there.

  • “The response reached your max_tokens limit.”

    Anthropic, stop reasons

  • “limit the total number of tokens the model generates, including reasoning tokens, visible output tokens, and non-visible formatting tokens, by using the max_output_tokens parameter”

    OpenAI, reasoning guide

Take a claims screen with room for 120 tokens. The model's usual summary runs about 400 tokens (a made-up number, for the example). Set the cap to 120 and nothing else, and the reply stops at 120 tokens with its end missing. The adjuster sees a summary that stops short.

A cap alone versus a target and a cap

Cap only

Usual long answer

no length asked for in the prompt

Cap and a target

Length and shape named

for example 60 words, one paragraph

Cut at the cap

the reply stops where the cap ends

Fits under the cap

the reply finishes on its own

Shorten and retry

your code asks once more, smaller

Reply used

a whole answer for the screen

  1. 1The usual reply runs into the cap.
  2. 2A shorter target finishes before the cap.
  3. 3The stop reason says the cap was hit, so the code asks again.
  4. 4The finished reply goes to the case screen.
The same cap gives two outcomes. With no target, the reply runs into the cap and is cut. With a target, the shorter reply finishes, and your code uses it. A cut reply gets one shorter retry.

A target is a guide, so the code still checks the stop reason. That check is the part that protects the screen.

How do you make the reply fit, step by step?

Use several levers together. The prompt sets the size, and the cap is the last safety net. For Claude Opus 5, Anthropic's guide says: "To control response length, prompt for it explicitly." It also says a reason helps, because context about why a length matters can help the model deliver more targeted responses.

  1. 1

    Name the length and the shape

    Say how long, and in what form: 60 words in one paragraph, or three bullets with fixed labels.

  2. 2

    Say why

    Give the reason, such as the case screen holds 60 words. With the reason, the model has more to go on and can aim its reply better.

  3. 3

    Show one example of the right size

    One short sample reply shows the size better than a rule on its own.

  4. 4

    Set the cap with room to spare

    Leave room above the target, so a normal reply is rarely cut. Anthropic's guide also says to leave room in max_tokens for thinking (extra hidden work before the answer), if the model thinks first.

  5. 5

    Check the stop reason in code

    If the reply stopped at the cap, your code knows. It does not pass a cut reply to the screen.

  6. 6

    Shorten and retry once

    Ask again with a smaller target, and stop after one retry, so the bill cannot run away.

Here it is in plain Python. The model is faked, so the code decides what gets through.

Python
# A simplified claims summariser. A fake model writes one piece per token; a short target makes it write less.
PIECES = [
    "Claim 4471: rear-end crash, two cars.",
    " Driver A reports neck pain, and the police report",
    " was filed that day, and the repair estimate",
    " is still pending.",
]
SHORT = ["Claim 4471: rear-end crash, two cars.", " Repair estimate pending."]

def write_summary(short, max_tokens):
    planned = SHORT if short else PIECES
    text, used = "", 0
    for piece in planned:
        if used == max_tokens:
            return text, "max_tokens"
        text += piece
        used += 1
    return text, "end_turn"

def screen_text(max_tokens):
    text, reason = write_summary(False, max_tokens)
    if reason == "end_turn":
        return text
    text, reason = write_summary(True, max_tokens)  # one retry, with a shorter target
    if reason == "end_turn":
        return text
    return "Cut off: needs a human look"

for cap in [5, 3, 1]:
    print(screen_text(cap))

Output

Claim 4471: rear-end crash, two cars. Driver A reports neck pain, and the police report was filed that day, and the repair estimate is still pending.
Claim 4471: rear-end crash, two cars. Repair estimate pending.
Cut off: needs a human look

Do vendor verbosity settings change the length?

Some vendors give you a dial. OpenAI's GPT-5 has a verbosity setting, which it describes as the parameter that influences the length of the final answer. On Claude Opus 5, Anthropic's guide says effort controls how much the model thinks, not how much it says: lowering effort can reduce thinking volume without reliably shortening the visible response.

  • Vendor verbosity

    A dial in the API

    OpenAI's guide tells of Cursor's team, which set verbosity to low to keep text outputs brief, then strongly encouraged verbose outputs in coding tools only.

  • Effort setting

    Not a length dial

    Anthropic says that on Claude Opus 5 raising or lowering effort does not reliably change the visible length. Ask for brevity in the prompt.

  • “in GPT-5 we introduce a new API parameter called verbosity, which influences the length of the model's final answer, as opposed to the length of its thinking.”

    OpenAI, GPT-5 prompting guide

  • “raising or lowering effort does not reliably change visible response length.”

    Anthropic, prompting best practices

OpenAI's GPT-5 verbosity setting sets the default. By default, reasoning verbosity is medium if it is not set, and setting it to low gives shorter outputs. OpenAI also says GPT-5 is trained to respond to natural-language verbosity overrides in the prompt, so the prompt can override that default. Use the setting for the default, and the prompt for the screen that needs something else.

What sets the length of a reply

Your prompt

target, shape and the reason

Vendor setting

for example GPT-5 verbosity

Model

writes the reply, token by token

Stop reason

your code reads why it stopped

Cut at the cap

ask again, shorter, once

Reply used

finished on its own

  1. 1Your prompt names the target, the shape and the reason.
  2. 2A vendor setting, where there is one, nudges the length too.
  3. 3The model writes until it finishes or reaches the cap.
  4. 4A cut reply is flagged, so your code can ask again.
  5. 5A reply that finished on its own goes to the screen.
Your prompt, and a vendor setting where there is one, feed the model. Your code then reads the stop reason. A reply cut at the cap goes back once with a shorter ask, and a reply that finished on its own is used as it is.

What does the interviewer want to hear?

A strong answer covers

  • A plain point: the cap is a ceiling, and a cut reply is the failure.
  • The target in the prompt does the work of size, with a reason and an example.
  • The cap is set above the target, with room for the model's hidden thinking.
  • The stop reason is checked in code, with one shorter retry.
  • OpenAI's GPT-5 has a verbosity setting that sets the default, and the prompt can override it.
  • Length is tested on real cases, because a target is a guide.

Common traps

  • Trap"Setting max_tokens to 60 makes the model write 60 words."

    BetterThe cap counts tokens, which are pieces of text, and it stops the reply. It does not plan the reply. Put the target in the prompt.

  • Trap"A bigger model writes shorter answers."

    BetterModel choice can change the default length, and Anthropic says Claude Opus 5 runs longer by default. The target sets the size, and the cap stops any overrun.

  • Trap"Turn the effort down and it will be brief."

    BetterAnthropic says effort does not reliably change visible length on Claude Opus 5. Ask for brevity in plain words.

Can you spot the cut-off?

Spot the cause

Your team's claim summariser keeps cutting replies on the case screen. Which setup is the most likely cause?

Quick check

A reply is cut at the token cap, and the stop reason says so. What is the best next step?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q029What do stop sequences and max tokens do?10 min
  2. Q081What makes a good prompt?13 min
  3. Q085How do you get reliable JSON output?12 min
  4. Q100How do you test prompts systematically?12 min
  5. Q108When do you raise a reasoning-effort setting?10 min
  6. Q030Why are input and output tokens priced differently?11 min

Last updated on 27 November 2026

Building a tool where replies must fit a screen?

I design and build AI products and agents, including the prompts, caps and checks that keep replies the right size. Book a short call and tell me what your screen or system needs.