core Estimated learning time: 6 h

9.2 Agent loops: ReAct, planning, reflection

You can implement an agent loop without a framework.

Before:08. Large Language Models

ReAct, plan-and-execute and reflection are the core loop patterns, and implementing one without a framework teaches what every framework hides: the prompt scaffold, the parsing, the termination logic. It sits early in the module because the loop is the agent. The unbounded loop is the failure with an invoice attached — an agent that cannot tell it is stuck will happily retry forever, which is why step limits and termination conditions are part of the pattern, not an option.

Work through these

  • ReAct: reason, act, observe

    The loop that thinks, acts and observes the result before thinking again. It is the simplest agent pattern and it is enough for a surprising number of tasks.

  • Plan-and-execute and task decomposition

    Producing a plan first and then carrying it out, which handles longer tasks and copes badly with surprises. Breaking a task into steps is itself a skill the model can be poor at.

  • Reflection, critique and self-correction

    Having the agent review and correct its own work, which helps on some tasks and produces confident revisions of correct answers on others. Measuring rather than assuming is the advice.

  • Termination conditions and step limits

    A loop without a stopping rule runs until something else stops it, usually a budget. Termination conditions and step limits are the first thing to write, not the last.

Sign in to keep your progress.

Free resources

Links last checked 29 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.