Courseiva
Claude API Mechanics →mediumMultiple Choice

CCDV-F Claude API Mechanics Practice Question

A developer is building a document-summarization service on the Anthropic Messages API. The service must always return a summary followed by exactly one structured JSON block containing metadata (e.g., word count, sentiment). To guarantee the model never emits any text after the JSON block, the developer adds the closing brace of the JSON structure to the 'stop_sequences' array. What is the effect of this configuration on the API response?

⚠ Common exam trap

The trap here is assuming stop sequences act like output filters that remove content, when they actually truncate generation at the match point and drop the matched string itself.

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

✓

The response's 'stop_reason' is 'stop_sequence' and the text field contains the JSON block with the stop string trimmed off.

A stop sequence halts generation as soon as the matching string is produced, and the matched string itself is not included in the returned text. The response's stop_reason becomes 'stop_sequence', letting the application know a configured terminator fired rather than the model finishing naturally. This is why developers who place a closing JSON brace in stop_sequences see the brace omitted from the output.

Answer analysis

Option-by-option breakdown

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

  • ✗

    The API returns an error because stop_sequences cannot contain characters that might appear inside the model's generated JSON.

    Why it's wrong here

    The API accepts arbitrary strings in stop_sequences, including braces, quotes, and other punctuation. There is no validation that rejects a stop string merely because it could appear inside structured content. The request will be processed normally; the only consequence is where generation halts. So this configuration does not produce a 400 error here.

  • ✗

    The response's 'stop_reason' is 'max_tokens' because stop sequences only apply to the final assistant turn, not to content inside a single message.

    Why it's wrong here

    Stop sequences apply to any generated content in the current request, regardless of conversation role. 'max_tokens' is only reported when the model hits the token ceiling, which is unrelated to stop-sequence matching. The presence of a configured stop string that appears in output will halt generation well before max_tokens is reached in typical summaries.

  • ✗

    The API silently strips the entire JSON block from the response, returning only the summary text to the caller.

    Why it's wrong here

    Stop sequences do not delete earlier content; they only truncate at the match point. Everything before the matched string remains in the response text. The JSON block will still be present up to (but not including) the closing brace. Nothing is silently removed from the middle of the output.

  • ✓

    The response's 'stop_reason' is 'stop_sequence' and the text field contains the JSON block with the stop string trimmed off.

    Why this is correct

    When a stop sequence is encountered, generation halts and the matched stop string is excluded from the returned text. The 'stop_reason' field is set to 'stop_sequence' so callers can distinguish this from a natural end_turn. The developer gets the summary plus JSON with the trailing brace removed, which matters for downstream parsing.

About these practice questions

This CCDV-F question is part of Courseiva's 257-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 CCDV-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 CCDV-F exam.