Even the best AI makes mistakes. But the AI is often smart enough to fix its own mistakes if you ask it to. This is the Self-Correction pattern.
Instead of one prompt, use three:
If you need JSON and the AI returns invalid JSON, don't crash. Send the error back to the AI: "Your previous response was not valid JSON. Here is the error: `SyntaxError: Unexpected token`. Please try again." The AI will almost always fix the bracket or comma immediately.
Q: "What is 'Self-Reflection' in Agentic workflows?"
Architect Answer: "Self-reflection is where the AI maintains a 'Internal Monologue.' It records its own logic: 'I tried to use the Customer API but it returned 0 results. Perhaps the customer ID is wrong. I will try searching by email instead.' This ability to 'Pivot' based on its own failed attempts is what makes an **Autonomous Agent** much more powerful than a simple chatbot."