一键导入
agentic-reflection
Reflection pattern for quality-critical outputs using generate-critique-refine cycles. Requires clear evaluation criteria and acceptable latency.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Reflection pattern for quality-critical outputs using generate-critique-refine cycles. Requires clear evaluation criteria and acceptable latency.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | agentic-reflection |
| description | Reflection pattern for quality-critical outputs using generate-critique-refine cycles. Requires clear evaluation criteria and acceptable latency. |
[!TIP] TL;DR: Use this pattern when output quality matters more than response speed, AND evaluation criteria are clear. The agent generates, critiques, and refines until quality thresholds are met. Key Principle: "Critic independence is critical. If the critic mirrors the generator too closely, it tends to agree rather than evaluate."
The reflection pattern is grounded in the expectation that first-pass outputs are often incomplete or flawed, and that iterative self-critique and refinement improves final quality enough to justify the added cost.
┌─────────────────────────────────────────────────────┐
│ REFLECTION CYCLE │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Generate│───▶│ Critique│───▶│ Refine │ │
│ │ "First │ │ "What's │ │ "Fixed │ │
│ │ draft" │ │ wrong?" │ │ version"│ │
│ └─────────┘ └─────────┘ └─────────┘ │
│ │ │ │ │
│ ◀──────────────┴──────────────┘ │
│ (iterate until quality met) │
└─────────────────────────────────────────────────────┘
When to use: Apply this pattern when:
BOTH conditions must be met.
| Good Criteria | Bad Criteria |
|---|---|
| "Valid SQL query that returns expected columns" | "Good code" |
| "Contract with all required fields filled" | "Professional document" |
| "Passes linting + unit tests + integration tests" | "Clean output" |
| "Mathematically equivalent to specification" | "Correct answer" |
Without clear criteria, the critic produces vague or misleading feedback.
| High Error Cost (use reflection) | Low Error Cost (skip reflection) |
|---|---|
| Deployed production code | Development exploration |
| Client-facing documents | Internal scratchpads |
| Regulatory submissions | Drafts for internal review |
| Financial transactions | High-throughput batch processing |
This is the most important design choice in reflection patterns:
Generator: GPT-4
Critic: Same GPT-4, slightly different prompt
→ Tendency: Agree rather than evaluate
→ Result: Minimal improvement, wasted cycles
Generator: GPT-4
Critic: Different model (e.g., Claude), OR
Same model but different framing/context, OR
Rule-based validator for specific criteria
→ Result: Genuine evaluation, meaningful improvement
MAX_ITERATIONS = 3 # Prevent infinite loops
For iteration in 1..MAX_ITERATIONS:
1. Generate output
2. Evaluate against criteria
3. If PASSED → return output
4. If FAILED → generate critique
5. Refine based on critique
6. Loop
If MAX_ITERATIONS reached without PASS:
→ return best effort OR escalate to human
| Signal | Cause | Fix |
|---|---|---|
| Critique cycles don't improve output | Evaluation criteria unclear | Define sharper, verifiable criteria |
| Critique cycles don't improve output | Critic too aligned with generator | Use different model/framing for critic |
| Same errors persist | Critique not actionable | Make critique specific to criteria |
| Signal | Cause | Fix |
|---|---|---|
| Cycles continue without end | No stopping condition | Define max iterations |
| Quality doesn't improve | Criteria not achievable | Revise criteria or accept current state |
def reflection_loop(generator, critic, criteria, max_iterations=3):
best_output = None
best_score = -1
for i in range(max_iterations):
output = generator.generate()
score = critic.evaluate(output, criteria)
if score > best_score:
best_output = output
best_score = score
if score >= threshold:
return output # Quality met
critique = critic.critique(output, criteria)
generator.refine(critique)
return best_output # Best effort after max iterations
Reflection adds well to other patterns:
| Base Pattern | + Reflection | Use When |
|---|---|---|
| ReAct | + Quality at each step | Quality critical at each stage |
| Planning | + Checkpoint validation | Quality gates between stages |
| Multi-Agent | + Specialist critique | Domain-specific quality checks |
run_agem_cycle — Generation phaseget_cohomology — Check generator/critic alignment (should be LOW for independence)spawn_agem_agent — Spawn independent critic agentadvanced-reasoning — Deep critique reasoningmcp-logic — Formal verification of generated outputshipai-montague — Track belief evolution through refinementconscience-servitor — Ethical evaluation for sensitive outputs1. Define quality criteria (must be verifiable)
2. Set max reflection iterations (typically 2-3)
3. Initialize generator and critic (ensure independence)
4. LOOP:
a. Generate output
b. Evaluate against criteria
c. If PASSED → return
d. If FAILED → critique
e. Refine generator based on critique
f. If max iterations → return best effort
## Reflection Task Definition
**Task**: [What needs to be generated]
**Quality Matters**: [YES/NO]
**Speed Matters**: [YES/NO - if YES, don't use reflection]
**Latency Acceptable**: [YES/NO]
### Quality Criteria (verifiable):
1. [Criterion 1] - [how to verify]
2. [Criterion 2] - [how to verify]
3. [Criterion N] - [how to verify]
### Generator: [model/prompt]
### Critic: [different model/framing for independence]
### Max Iterations: [N]
### Pass Threshold: [score/value]
### Escalation Triggers:
- [Max iterations reached] → human review OR accept best effort
- [Criteria impossible to meet] → revise criteria
| Question | Answer | Use Reflection? |
|---|---|---|
| Quality matters more than speed? | YES | ✓ |
| Clear evaluation criteria exist? | YES | ✓ |
| Both conditions met? | YES | → Use Reflection |
| Either condition NO? | NO | → Skip Reflection |
arXiv paper discovery — select top 3 significant papers, research via subagents, ingest to wiki, deliver report.
Daily raw file ingestion pipeline — process files from raw/ into structured wiki knowledge, verify frontmatter and links, archive to Clippings/. Schedule: 06:30 AM.
Daily Zettelkasten insight generation — run CLI insight engine, create wiki pages for confidence>=0.7 insights, integrate to wiki. Schedule: 06:00 AM.
Daily global news curator — RSS discovery, significance filtering, clippings archive + synthesis wiki delivery, deliver headlines report. Schedule: 07:30 AM.
Wiki synthesis agent operational sheet — cross-domain bridges, concept advancement, evidence evaluation
Daily wiki quality audit anchored in wiki-indexing-theory.md — HITS authority scoring, GAAC cluster validation, tag taxonomy compliance, reciprocal link enforcement. Schedule: 08:50 AM.