Turn a goal into actions that can be checked
Planning turns a goal into manageable steps; ReAct is the observable decide → act → observe pattern that lets a model choose the next action using fresh evidence; reflection evaluates a result and changes the approach when the evidence shows a problem. These are control strategies, not access to a model's hidden chain-of-thought.
What You Will Learn
- Choose among plan-first, stepwise ReAct, and reflection strategies.
- Evaluate observable actions and evidence instead of hidden reasoning.
- Use verifier results to revise a plan only when needed.
- Stop on success, no progress, exhausted budgets, or required escalation.
Planning, acting, and checking are different jobs
A plan states intended steps before they run. ReAct chooses one action, observes real evidence, and then chooses again. Reflection or an evaluator checks whether the result meets explicit criteria and may request a bounded revision. These techniques can be combined, but every extra loop adds latency and cost.
Do not treat private chain-of-thought as evidence. Production traces should record observable decisions, selected tools, validated arguments, tool results, verifier scores, and stop reasons. Those are the artifacts a developer can test and a reviewer can audit.
Match the control strategy to the task
Plan, act, observe and decide whether to continue
Decompose the goal into a short plan when dependencies are known, or begin with one safe step when the environment is uncertain.
Choose one typed, permitted action from the current evidence.
Execute the action and record the observable result as an observation.
Compare the observation with success criteria; continue the plan, replan after feedback, or use a verifier/reflection pass.
Stop when evidence is sufficient, progress has stalled, a budget is reached, or human help is required.
Instructional figure
Planning, ReAct, and reflection in one bounded loop
What happens before, during, and after an agent action?
Worked Example: A bounded ReAct trace uses observations to revise once
The required output is a two-field product brief: current price and warranty period. The runtime permits four tool steps and logs only observable goals, actions, results, verifier decisions, and budget—not hidden reasoning.
- Step 1 searches approved source A. Its catalog entry supplies the $640 price but no warranty. The verifier compares the observation with the two required fields and reports one gap.
- Step 2 changes action rather than repeating the failed search: it queries approved warranty source B. Record W-92 supplies a two-year warranty, so the verifier now finds both claims supported.
- The agent stops with one step still available because success—not budget exhaustion—is the correct terminal condition. If it proposed the identical source A query again, a no-progress rule would stop or escalate the run.
What the result means: The useful reasoning evidence is the change in validated action after a named evidence gap, followed by a verifier pass and explicit stop reason. More looping would add cost without improving the answer.
Observable trajectory for a product brief
Instructional figure
An observable ReAct trajectory ends on evidence—not hidden reasoning
How does a missing field cause one revised action and then a verified stop?
A Realistic Example: A comparison that changes its plan after new evidence
The agent lists the product facts it must verify, searches an approved source, and discovers that prices use different currencies. It adds a currency lookup, validates the converted values, and writes the comparison only when every required claim has evidence.
Read the Mechanism in Code
Use the label and note to understand what this block represents before reading each line.
for step_number in range(MAX_STEPS):
decision = planner.next_action(goal, evidence)
if decision.is_final and verifier.supports(decision.answer, evidence):
return decision.answer
observation = execute_validated(decision.tool_call)
evidence.append(observation)
if no_progress(evidence):
return escalate("The plan is not gaining new evidence")Hands-On Runnable Python Lab: Track Evidence Gaps and Remaining Actions
Use a four-action ceiling and two approved observations: a catalog price of $640 and a warranty page stating two years. The example exposes decisions and facts, not private chain-of-thought.
- Initially both price and warranty are missing, so query the catalog.
- After receiving price=640, the verifier still identifies a warranty gap.
- Query the warranty source and test both conditions against the accumulated evidence.
- Stop at action 2 with remaining=2. An unsupported case stops when evidence cannot be improved or the action limit is reached.
Evidence increases while the available action budget decreases
Green cells count known required fields; purple cells count actions left. A successful run stops with two actions unspent.
observations = [
("catalog", {"price_usd": 640}),
("warranty page", {"warranty_years": 2}),
]
required = {"price_usd", "warranty_years"}
evidence = {}
limit = 4
for step, (source, facts) in enumerate(observations, start=1):
if step > limit:
break
missing_before = sorted(required - evidence.keys())
before = dict(evidence)
evidence.update(facts)
missing_after = sorted(required - evidence.keys())
print(f"action {step}: {source}; missing before={missing_before}")
print(f" missing after={missing_after}; remaining={limit - step}")
if evidence == before:
print("STOP: no progress")
break
if not missing_after:
passed = evidence["price_usd"] <= 700 and evidence["warranty_years"] >= 2
print("verifier:", "PASS" if passed else "FAIL")
print("STOP: criteria checked")
break
else:
print("STOP: approved observations exhausted")
action 1: catalog; missing before=['price_usd', 'warranty_years']
missing after=['warranty_years']; remaining=3
action 2: warranty page; missing before=['warranty_years']
missing after=[]; remaining=2
verifier: PASS
STOP: criteria checkedWhat This Run Shows
- The missing-field list changes from two fields to one to none, making progress directly observable.
- The verifier checks constraints, not just the presence of text. A $900 price would produce FAIL even with both fields present.
- Remaining budget is recorded alongside each observation, so a reviewer can see exactly why the run stopped.
A trajectory helps diagnose whether failure came from planning, a tool, missing evidence or an incorrect final synthesis. Evaluate these stages separately instead of scoring only the final paragraph.
From the Exercise to an Application
Experiment: Change warranty_years from 2 to 1.
The evidence is complete but the verifier returns FAIL. This distinction matters: obtaining all requested facts is not the same as satisfying the user’s requirements.
Summary / Key Takeaways
- Planning decomposes work, ReAct adapts one action at a time using observations, and reflection checks whether the current result should be revised.
- Plan-first approaches fit tasks with known dependencies; stepwise action is useful when the environment changes as the agent works.
- Observable actions, tool results, evidence, and verifier outputs are what a production system should evaluate—not hidden chain-of-thought.
- New observations can justify replanning; a good plan is not a rigid script.
- Reflection is useful when success criteria can be checked, but unlimited self-review loops can waste tokens and reinforce weak behavior.
- Stop rules should include success, no measurable progress, step/time/cost limits, and cases that require human help.
- More reasoning steps are not automatically better; the value of extra planning or reflection must be measured.
Verified Further Reading
These primary research papers and current official specifications support the concepts and implementation guidance in this lesson. The explanations, analogies, exercises, and code above remain original teaching material.