Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:666ghj BettaFish Reflection Loop

From Leeroopedia
Knowledge Sources
Domains NLP, Information_Retrieval, LLM_Reasoning
Last Updated 2026-10-08 00:00 GMT

Overview

Iterative refinement pattern where an LLM reflects on its current output, identifies information gaps, and generates new queries to fill them, repeating until sufficient coverage is achieved.

Description

The Reflection Loop addresses the limitation of single-pass research: a single search query rarely captures all relevant information about a topic. After the initial search and summary, the reflection node examines what has been found and what is missing, then generates a targeted query to fill the gaps. This cycle repeats for a configurable number of iterations, progressively enriching the summary.

Each iteration follows: Search → Summarize → Reflect → Generate New Query. The reflection LLM is prompted to identify weaknesses in the current summary (missing data, shallow analysis, one-sided coverage) and produce a query that specifically addresses those weaknesses.

Usage

Use this principle when building research systems that need comprehensive topic coverage beyond what a single search can provide. It is especially effective when the research target has multiple facets (e.g., sentiment analysis needs both positive and negative viewpoints) or temporal aspects (e.g., historical context plus current developments).

Theoretical Basis

The reflection loop is an iterative improvement process:

s0=Summarize(Search(q0)) qi+1=Reflect(si);si+1=Summarize(Search(qi+1),si)

The loop terminates when:

  • A maximum iteration count is reached
  • The reflection determines no significant gaps remain
  • The search returns diminishing new information

Pseudo-code Logic:

# Abstract pattern (NOT real implementation)
query = first_search(paragraph)
summary = summarize(search(query))

for i in range(max_iterations):
    query = reflect(paragraph, summary)  # Identify gaps
    new_results = search(query)
    summary = summarize(new_results, summary)  # Enrich

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment