CCAR-F scenarios › Developer Productivity with Claude · Question 40 of 60

Scenario 4 · Developer Productivity with Claude

Your team is building internal developer tools on the Claude Agent SDK. The agent helps engineers find their way around unfamiliar or legacy codebases, generates boilerplate, and automates repetitive chores. It works through the built-in Read, Write, Bash, Grep, and Glob tools, plus connections to Model Context Protocol (MCP) servers.

Agentic Architecture & Orchestration

Your Agent SDK loop for the "automate repetitive tasks" feature sometimes stops halfway through a job. The loop ends as soon as a response contains a text block, but Claude often writes text such as "Next I'll run the migration script" in the same response as a tool_use block. How should the loop decide whether to continue?

Show answer and explanation

Answer: D — Continue while stop_reason is "tool_use", appending each tool result to the conversation, and terminate when stop_reason is "end_turn".

The loop's control flow should follow stop_reason: run the requested tools and append their results while it is "tool_use", and stop at "end_turn". (a) and (b) parse natural-language signals to decide when to stop, which section 6 names as an anti-pattern, and a model can write such a phrase early or leave it out. (c) uses an arbitrary iteration cap as the main stopping mechanism, so short jobs keep running and long jobs get cut off.