Question 61
Open question ↗Scenario: Agent Architecture and Orchestration
An engineer builds an agent loop that calls Claude with tools. To decide when the task is finished, the loop scans the assistant's text for the phrase "task complete" and also stops after a fixed `max_iterations=5`. In production the agent sometimes halts mid-task and other times keeps looping after it is actually done.
What is the correct completion signal for the agent loop?
- A.Keep the text scan but raise `max_iterations` to 15 so the agent has more room to finish.
- B.Continue the loop while `stop_reason == "tool_use"` and stop when `stop_reason == "end_turn"`.
- C.Stop as soon as the assistant returns any text content block alongside tool calls.
- D.Ask the model at each step to self-report a boolean `is_done` field and stop when it is true.