← AI Agents path

πŸ€– Using AI & AI Agents

Chapter 15 of 24

πŸͺž Chapter 15: Metacognition in Agents

Thinking about thinking: self-reflection, planning, corrective RAG, code as tool

Metacognition is "thinking about thinking": the agent evaluates and adjusts its own reasoning. It can reflect on past choices ("I prioritized cost; I might have missed direct flights"), adapt strategy from feedback ("When the user says β€˜too crowded,’ I should change my ranking method"), and correct errors (check availability before suggesting a hotel). Techniques include planning with clear steps, corrective RAG (retrieve, then evaluate and correct), and using code or SQL as tools with schema-aware reasoning.

Metacognition: reflect β†’ adjust flow

Agent makes a choice (e.g. recommend cheapest hotel)
↓
Reflect: "Was that right? User said quality matters."
↓
Adjust strategy (e.g. switch to "best quality" next time)
↓
New recommendation (or re-query with updated criteria)

Metacognition: thinking about thinking

1

Self-reflection β€” Agent assesses its own choices: "I picked the cheapest flight; I might be missing direct options. Let me re-check."

2

Adaptation β€” Notices patterns: "When the user says β€˜too crowded,’ I should change how I rank attractions, not just remove one."

3

Error correction β€” Learns from failure: "Last time that hotel was fully booked; I’ll check availability before suggesting."

Example: Hotel recommendation

Agent first picks the cheapest hotel. User feedback: "bad" (e.g. quality too low). The agent reflects, switches strategy to "highest_quality," and recommends again. That reflection-and-adjust loop is metacognition in action.