Most LLMs answer in one shot. Agents often cannot—complex tasks require multiple reasoning steps, tool calls, and the ability to catch mistakes before they propagate. Agentic reasoning loops make that possible by combining two patterns: chain of thought for structured thinking within each iteration, and self-reflection for detecting when an attempt was wrong and deciding whether to try again.
What Are Agentic Reasoning Loops?
A reasoning loop is the iterative cycle an agent runs when a single prediction is not enough. The agent observes its current context, reasons about what to do next, takes an action, and then reflects on whether the outcome was correct. If it wasn’t, the loop runs again—this time with the reflection feeding into the next reasoning step.
The key difference from single-pass prompting: the loop creates a real feedback signal. The agent’s own critique—or the result of a tool call—changes what it does next. That signal is what makes the difference between an LLM that generates a response and an agent that actually corrects its own work.
The Agentic Reasoning Cycle
(Chain of Thought)
The loop continues until reflection confirms the output is correct—or a maximum iteration budget is reached.
CoT vs Self-Reflection in the Agent Loop
The two patterns are not alternatives—they run at different points in the same cycle and address different failure modes.
CoT runs at the start of each iteration. It prevents the model from jumping to conclusions on multi-step problems—decomposing what would otherwise be a single-token guess into a traceable reasoning chain. Without it, an agent’s actions are hard to debug because there is no reasoning trace to inspect. Reference: Chain of Thought Prompting.
Self-reflection runs after an attempt. The Reflexion framework (Shinn et al. 2023) formalises this: the agent critiques its own trajectory in plain language, stores that critique as episodic memory, and uses it to guide the next iteration. It is the signal that decides whether the loop continues. Related: ReAct Prompting.
Python: A Minimal Reasoning Loop
The example below implements both patterns using two sequential API calls per iteration—one for CoT reasoning, one for self-reflection. The loop runs until the reflection step returns CORRECT or the iteration ceiling is reached.
1import anthropic 2 3client = anthropic.Anthropic() 4 5def reasoning_step(problem, reflection=""): 6 """CoT phase — generate a step-by-step reasoning trace.""" 7 prefix = f"Previous reflection:\n{reflection}\n\n" if reflection else "" 8 msg = client.messages.create( 9 model="claude-sonnet-4-6", max_tokens=400, 10 messages=[{"role": "user", "content": ( 11 f"{prefix}Problem: {problem}\n\n" 12 "Think step by step, then end with: ANSWER: <result>" 13 )}] 14 ) 15 return msg.content[0].text 16 17def reflect(problem, reasoning): 18 """Self-reflection phase — evaluate the reasoning trace.""" 19 msg = client.messages.create( 20 model="claude-sonnet-4-6", max_tokens=200, 21 messages=[{"role": "user", "content": ( 22 f"Problem: {problem}\n\nAgent reasoning:\n{reasoning}\n\n" 23 "Is this correct? Start with CORRECT or INCORRECT, then explain." 24 )}] 25 ) 26 text = msg.content[0].text 27 return text, text.strip().upper().startswith("CORRECT") 28 29# ── Agentic reasoning loop — max 3 iterations ─────────────── 30problem = "A train does 120 km in 2 h, then 80 km in 1 h. Average speed?" 31reflection = "" 32 33for attempt in range(1, 4): 34 print(f"\n── Attempt {attempt} ──") 35 reasoning = reasoning_step(problem, reflection) 36 reflection, converged = reflect(problem, reasoning) 37 print(f"Reasoning:\n{reasoning}\nReflection:\n{reflection}") 38 if converged: 39 print(f"\nLoop converged after {attempt} attempt(s).") 40 break
What the loop does: Each iteration fires two API calls—one thinking, one judging. If the reflection step returns CORRECT, the loop stops. Otherwise, the critique becomes the reflection argument on the next reasoning call—giving the agent a memory of its own mistakes. In production, the reflection step is often replaced by a tool result or external verifier.
When Each Pattern Earns Its Place
Chain of thought earns its place any time a task requires more than one logical step: math reasoning, multi-hop question answering, code generation, query planning. Without it, the agent commits to an answer before working through the sub-steps—and when that answer is wrong, there is no trace to diagnose. CoT does not guarantee correctness; it makes errors visible and debuggable.
Self-reflection decides whether the loop continues at all. Without it, an agent either stops after one attempt regardless of quality, or runs a fixed iteration count with no signal about whether additional attempts are helping. The two patterns are not interchangeable—CoT is the thinking, reflection is the judgment. You can also explore tree-of-thought reasoning when a single reasoning chain is not enough and multiple branches need to be evaluated before committing.
Key Takeaways
- An agentic reasoning loop is an iterative cycle—observe, reason, act, reflect—that repeats until the agent converges or an iteration ceiling is reached.
- Chain of thought runs at the start of each iteration and generates explicit reasoning steps before the agent acts, making errors traceable.
- Self-reflection runs after an attempt and produces a verbal critique that feeds into the next iteration as memory—the core idea behind the Reflexion framework.
- The two patterns are not alternatives: CoT prevents bad answers, self-reflection detects them and triggers a corrective loop.
- Always cap iteration count. Without a maximum budget, a self-reflection loop that never converges will run indefinitely and accumulate inference cost.
Conclusion
Agentic reasoning loops are what separate a reactive LLM call from an agent that genuinely self-corrects. Chain of thought structures the thinking within each pass; self-reflection provides the judgment signal that determines whether the loop should continue. Together they produce agents that can catch and fix their own mistakes—something no amount of prompt engineering on a single call achieves. From here, the natural extensions are the ReAct pattern—which weaves actions directly into the reasoning trace—and memory-augmented agents that persist reflection history across sessions rather than resetting it on every loop.