Claude, Nutshell Series

Claude Exam Quick Revision 3: Agentic Loops & Tool Calling

Agentic Loop

Flow:

Claude → tool_use → execute tool → tool_result → Claude → next action → end_turn

When Should the Loop Stop?

  • stop_reason = tool_use: Execute tool and continue.
  • stop_reason = end_turn: Claude has finished the turn.

Do not: Parse phrases such as “task complete” or “I am done.”

A maximum-turn limit is useful as a safety guard, but it is not the primary completion signal.

Returning Tool Results

  • Return the result in a user-role message.
  • Use a tool_result block.
  • Match the original tool_use_id.
  • The result does not have to be JSON-only.

Multi-Turn Tool Calling

Each tool result can influence Claude’s next decision.

Example: Search → Read → Analyse → Call API → Final answer.

Memory: tool_use = continue. end_turn = finish.

Leave a comment