Agent Reasoning

Four reasoning strategies — ReAct, plan-and-execute, reflection, decomposition — the difference between an agent that lunges and an agent that thinks.

▶ Watch this reel

What you'll learn

  1. ReAct
  2. Plan-and-execute
  3. Reflection & self-critique
  4. Task decomposition

Remember this

ReAct

Plan-and-execute

Reflection

Task decomposition

Code: Hybrid reasoning: plan milestones, ReAct within, reflect at the end

async def run_hybrid(goal: str):
    # 1 · PLAN — global view, machine-readable steps
    plan = await llm(PLAN_PROMPT, goal=goal,
                     schema="list[{step, depends_on, verify_by}]")
    await human_review(plan)                       # checkpoint

    for step in topological_order(plan):
        # 2 · EXECUTE — ReAct within the milestone
        artifact = await react_loop(
            f"{goal}\nCurrent step: {step.step}",
            tools=tools_for(step), max_iters=8)

        # 3 · VERIFY per step — the plan's own verification hook
        if not verify(step.verify_by, artifact):
            plan = await replan(plan, failed=step, state=artifact)

    # 4 · MACRO-REFLECTION — durable lessons into memory
    lessons = await llm("What worked? What failed? Rules for next time?",
                        transcript=full_history())
    memory.store(goal_domain(goal), lessons)
    return collect_artifacts(plan)