A housing waitlist helper should keep working until Claude finishes assisting the resident. Which control-flow rule correctly implements that agentic loop?
Select an answer to reveal the explanation.
Short Explanation
Simple rule of thumb: tool_use means keep looping; end_turn means you are done. The waitlist helper should only hang up when Claude signals end_turn—not when it merely mentions waitlists in prose.
Full Explanation
For a housing waitlist helper, the correct agentic control-flow rule is: continue while stop_reason is tool_use, and terminate when stop_reason is end_turn. That pairing maps directly to the model's structured lifecycle. tool_use means Claude still needs MCP results—waitlist position, preference updates, document checks—before it can finish assisting the resident. end_turn means Claude has produced its final assistant turn with no further tool requests, so the loop should return that answer and stop.
This rule works because it separates work-remaining from answer-ready without parsing prose. Housing assistance often chains several lookups; continuing only on tool_use keeps those steps in one coherent, auditable conversation with the resident's case context intact.
Continuing only while stop_reason is end_turn, then executing tools after the final answer, inverts the lifecycle and strands tools after the model already signaled completion. Exiting whenever assistant text contains the word waitlist is a brittle keyword heuristic that can fire mid-investigation. Alternating randomly between tool calls and termination destroys deterministic housing workflows and can drop residents mid-case.
Exam caveat: also handle error and truncation stop reasons with explicit retry or fail-closed policies; do not collapse them into end_turn. Operational check: log stop_reason each iteration and assert the helper never exits on tool_use and never continues after a clean end_turn.