reflection
Installation
SKILL.md
Reflection
Reflection (also known as Self-Correction or Self-Refinement) gives an agent the ability to look at its work and ask, "Is this correct?" or "Can this be better?". Instead of accepting the first draft, the agent acts as its own critic, identifying flaws and generating an improved version. This significantly boosts performance on reasoning and coding tasks.
Use Cases
- Code Repair: Creating code -> Running it -> Reading the error -> Fixing the code.
- Writing Polish: Drafting an email -> Critiquing tone and clarity -> Rewriting.
- Safety Check: Generating a response -> Checking for policy violations -> Regenerating if unsafe.
Implementation Pattern
def reflection_workflow(task):
# Step 1: Draft
draft = llm_call(f"Write a draft for: {task}")