Question 1 · choose 1
Your support resolution agent runs its own loop around the Messages API. A billing dispute can need five or six lookups in a row (get_customer, lookup_order and others) before Claude can answer, and the loop must neither stop early nor keep calling the API after Claude has finished. Which rule should decide whether the loop goes round again?
- AKeep running tools and sending results while stop_reason is "tool_use", and return the reply once it is "end_turn"
- BTell Claude to finish every resolved case with a marker such as [DONE] and stop when the marker appears in the text
- CAllow a fixed number of round trips sized to the longest case seen in testing, then return the latest text
- DEnd the loop as soon as a response contains a text block, since that text is the answer the customer is waiting to see
Show the answer and why
AKeep running tools and sending results while stop_reason is "tool_use", and return the reply once it is "end_turn"
Correct
stop_reason is the API's structured signal: "tool_use" means Claude is waiting for tool results, "end_turn" means it finished its response, however many lookups the case needed.
BTell Claude to finish every resolved case with a marker such as [DONE] and stop when the marker appears in the text
Incorrect
Parsing natural-language markers is brittle: Claude may write the marker while still planning a call, or leave it out, while the API already reports the reason it stopped.
CAllow a fixed number of round trips sized to the longest case seen in testing, then return the latest text
Incorrect
A count chosen in advance cuts off unusual cases that need more steps and says nothing about whether Claude has actually finished.
DEnd the loop as soon as a response contains a text block, since that text is the answer the customer is waiting to see
Incorrect
A response can hold text and tool_use blocks together, for example a sentence of reasoning before a lookup, so text alone does not mean Claude is done.
Drive the loop from stop_reason. Continue while Claude asks for tools ("tool_use"), feeding each result back, and stop when it ends its turn ("end_turn"). Text blocks, fixed counts and invented markers are proxies for a signal the API already returns.
Anthropic documentation