Page languageFrançaisEnglish
Teacher area
Laurent PoupetClaude trainer and artificial intelligence architectStudent area

Category · Agents and orchestration

What is an agent loop?

In an agent loop, the model answers or requests a tool, the code runs it, and the result comes back, until the task is done or a limit is reached. ReAct (Reasoning and Acting) is its classic form, not to be confused with React.

By , Claude trainer and artificial intelligence architect · Updated

How it works

  • At each turn, the whole history, with tool results, is sent back to the model; the cost of a task therefore grows faster than the number of turns.
  • The loop stops when the model answers without requesting a tool, or when a limit is reached, and it is the code, not the model, that checks these conditions.
  • Frameworks such as LangGraph or LangChain provide this loop ready-made, with the state saved between turns and breakpoints for a human.

The trap to avoid

The trap is the loop that goes round in circles, for example a tool that fails and that the model calls again endlessly with the same parameters.

Related terms

Where this is taught

Lesson content (step-by-step instructions, exercises with solutions, quizzes) is for students only, with an access code received after the first lesson.

See the full program

All glossary terms

Trial lesson · 30 min · $20

Book (new tab)