Courseiva

CCAR-F Prompt Engineering and Structured Output Practice Question

A developer wants Claude to generate a list of items but stop immediately after the fifth item is completed to save on token costs. Which configuration change is most appropriate?

⚠ Common exam trap

Candidates often attempt to use max_tokens to control the output length, which is unreliable as it truncates content arbitrarily rather than stopping at a logical completion point.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Set a custom stop sequence.

Stop sequences allow the API to terminate generation as soon as a specific string is encountered. By defining a sequence that naturally follows the completion of the fifth item, developers can effectively control output length and costs without relying solely on the max_tokens parameter, which might truncate the response mid-sentence.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Reduce the temperature to 0.1.

    Why it's wrong here

    Lowering the temperature makes the model more deterministic but does not stop it from generating more than five items. The model will still continue to generate text until it naturally finishes or reaches the max_tokens limit, regardless of how 'focused' or 'predictable' its output becomes.

  • ✓

    Set a custom stop sequence.

    Why this is correct

    A stop sequence is a string that, if generated, causes the model to stop immediately. If the developer knows the model will output '6.' at the start of the sixth item, they can set '6.' as a stop sequence to ensure generation terminates after the fifth item.

  • ✗

    Use a system prompt to ask for brevity.

    Why it's wrong here

    Asking for brevity is an instruction that the model may or may not follow precisely. It is not a reliable technical control for stopping generation at a specific point. The model might still generate six or seven items despite being told to be brief in the system prompt.

  • ✗

    Increase the top-k parameter value.

    Why it's wrong here

    Top-k sampling limits the model to the top 'k' most likely next tokens but has no relationship with the length of the overall response. Increasing or decreasing top-k will not help the developer stop the output after a specific number of list items have been generated.

About these practice questions

Courseiva writes every CCAR-F question from scratch — 271 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Anthropic exam blueprint

This CCAR-F practice question is part of Courseiva's free Anthropic certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CCAR-F exam.