# 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.

AI and LLM interview question Q094, Prompt and context engineering. Beginner, occasional (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/how-do-you-control-answer-length-and-verbosity

## Say it in 30 seconds

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.

## Say it in 2 minutes

Length has two parts I control. The first is the target: I say in the prompt how long the reply should run and what shape it takes, such as sixty words in one paragraph for a case screen. The second is a hard limit. In the API, the interface my code calls, that limit is max_tokens, the most tokens the model may write in one reply.

The limit only stops the reply. A model that is not told a length writes its usual answer, and if that answer is longer than the cap, the reply is cut where the cap ends. Anthropic's docs say the reply then reaches the max_tokens limit. OpenAI's reasoning docs count hidden thinking inside that same budget, so the cap can run out "before any visible output tokens are produced". So a cap alone can leave a half-finished summary on the screen.

So I use the target to get the right size, leave the cap with headroom above it, and read the stop reason in code. If the reply hit the cap, my code asks again with a smaller target, once, so cost cannot run away. Some models, such as Claude Opus 5, run long by default. For those I ask for brevity in plain words, since raising or lowering effort (how hard the model works before it answers) does not reliably shorten the visible reply.

On an insurer's claims screen, that is the difference between a clean summary and one that ends mid-sentence. Vendors also offer verbosity settings, like OpenAI's for GPT-5, which influence how long the final answer runs. I still test the output on real cases.

## 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."

- **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.

*Diagram, A cap alone versus a target and a cap: 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.*
1. The usual reply runs into the cap.
2. A shorter target finishes before the cap.
3. The stop reason says the cap was hit, so the code asks again.
4. The finished reply goes to the case screen.

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. **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. **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. **Show one example of the right size:** One short sample reply shows the size better than a rule on its own.
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. **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. **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:

```text
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.

*Diagram, What sets the length of a reply: 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.*
1. Your prompt names the target, the shape and the reason.
2. A vendor setting, where there is one, nudges the length too.
3. The model writes until it finishes or reaches the cap.
4. A cut reply is flagged, so your code can ask again.
5. A reply that finished on its own goes to the screen.

## 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." Better: The 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." Better: Model 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." Better: Anthropic 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?

A. The prompt asks for 60 words, and the cap is 200 tokens.
B. The prompt names no length, the cap is 120 tokens, and no code reads the stop reason.
C. The prompt asks for three bullets, and the code logs every reply.
D. The prompt names the case screen, and the code lowers the temperature (how random the wording is).

**Answer:** B. With no length in the prompt, the model writes as much as it likes. The cap cuts it at 120, and nothing checks the stop reason, so the cut reply goes straight to the screen.

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

A. Raise the cap by ten times and never check again
B. Ask for a shorter reply with a clear target, then retry once if it is cut again
C. Switch to a bigger model, which writes shorter replies
D. Lower the temperature (how random the wording is) so the model writes less

**Answer:** B. A cut means the reply ran past the cap. A clear target fixes the cause, and one checked retry stops a loop from running up cost. The target does the work, not the model's name or size.

## Can you answer these from memory?

**Flash cards**

- **Does a token cap make a reply shorter?** No. It is a ceiling. A reply that reaches it is cut off.
- **What does max_tokens do?** Caps how many tokens one reply may write. Hitting it cuts the reply.
- **How do you ask for a length?** Name a target and a shape in the prompt, and give the reason.
- **What is a stop reason?** The API's note on why the reply ended: finished, or the cap was hit.
- **Is effort a length dial on Claude Opus 5?** No. Anthropic says it does not reliably change the visible length.
- **What does GPT-5 verbosity do?** Influences the length of the final answer. It is a default the prompt can override.

## Likely follow-up questions

- Q029 What do stop sequences and max tokens do? https://designervenkat.online/interview/ai/what-do-stop-sequences-and-max-tokens-do
- Q081 What makes a good prompt? https://designervenkat.online/interview/ai/what-makes-a-good-prompt
- Q085 How do you get reliable JSON output? https://designervenkat.online/interview/ai/how-to-get-reliable-json-from-an-llm
- Q100 How do you test prompts systematically? https://designervenkat.online/interview/ai/how-to-test-prompts-systematically
- Q108 When do you raise a reasoning-effort setting? https://designervenkat.online/interview/ai/when-do-you-raise-a-reasoning-effort-setting
- Q030 Why are input and output tokens priced differently? https://designervenkat.online/interview/ai/why-are-input-and-output-tokens-priced-differently
