# How does the Claude Agent SDK decide when to call tools and finish a run?

Exam: CCAR-F — Claude Certified Architect - Foundations (CCAR-F)
Knowledge domain: Agentic Architecture & Orchestration
Updated: 2026-11-25T09:22:55.333814+00:00
HTML: https://learningpathx.com/faq/CCAR-F/ccarf-agent-sdk-loop.html

## Also asked as

- What happens from prompt to final result in a Claude Agent SDK loop?
- How are tool results fed back during a Claude Agent SDK run?

The Claude Agent SDK runs an iterative loop. Claude receives the task, current conversation and tool definitions, then emits text, tool requests, or both. The harness checks and executes permitted tool requests, adds their results to the conversation, and calls Claude again with the updated evidence. A response without another tool call ends the normal loop. Limits and runtime errors can also stop it.

For an evidence-gathering agent, the first tool result might contain a reference to a document. Claude can request the document in a later turn and use the returned evidence in its final response. A denied or failed action should remain visible as that outcome. A denial matters even when the model can still answer from other evidence.

Use the SDK’s result message to observe how the run ended. Text can appear alongside a tool request mid-run, so watch for the result event when deciding whether the run has reached its normal completion point. Your application sets the task, permission policy and success checks throughout.

[How the Claude Agent SDK loop works](https://code.claude.com/docs/en/agent-sdk/agent-loop) · [Agent SDK permissions](https://code.claude.com/docs/en/agent-sdk/permissions)

Source: [Claude Agent Loops, Sessions, and Runtime Controls](https://learningpathx.com/news/claude-agent-loops-sessions-and-runtime-controls.html)
