Claude Certified Architect – Foundations Practice Question 57: Stop Sequences Delimiter

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

Prompt Engineering & Structured Outputmedium

A template asks Claude to write a product description and then emit the marker ---END---. The application only needs the text before the marker and does not want to pay for any tokens generated after it. The team also wants to tell programmatically that generation ended because the marker appeared, not because of a length limit. What should the request do?

Select one answer
Show answer and explanation

Answer:

  • B. Pass stop_sequences=["---END---"], then check that stop_reason is "stop_sequence" and read the stop_sequence field

B is correct. stop_sequences is a request parameter holding custom strings; when Claude emits one, generation halts there, the response's stop_reason is "stop_sequence", and the stop_sequence field says which one fired. Generation stops at the marker, so nothing after it is produced or billed.

A is wrong because a small max_tokens cuts output at an arbitrary point and yields stop_reason "max_tokens", and "end_turn" means Claude finished naturally. C is wrong because stop_reason is a response field you read, not a request parameter. D is wrong because it works for parsing but lets the model keep generating (and billing) past the marker, and "end_turn" cannot tell you the marker was reached.

Reference: Handling stop reasons

Practice Test 6 ›

Study guides for Claude Certified Architect, Foundations