A developer's custom loop on the Messages API runs each reply's tool_use blocks, but it treats any reply containing a text block as the final answer and returns that text. Users of the order assistant now often get only 'Let me look up that order for you.' The logged replies are complete and also hold a lookup_order tool_use block.
How would you fix the loop?
- A
Decide on stop_reason instead: run the requested tools and call again while it is tool_use, and finish on any other value.
- B
Raise max_tokens on each request so Claude has room to finish the lookup and write the full answer in one reply.
- C
Set tool_choice to any on each request so Claude must call a tool in its turn instead of writing a text reply.
- D
Add a system prompt rule telling Claude to write no text in a turn where it calls a tool, so each reply holds just the tool calls.