# How ADHD's Two-Phase Diverge-Focus Loop Prevents Premature Convergence

> Discover how ADHD's unique two-phase diverge-focus loop prevents premature convergence by isolating divergent branches and applying a critic-based filter for deeper idea exploration.

- Repository: [Udit Akhouri/adhd](https://github.com/UditAkhourii/adhd)
- Tags: deep-dive
- Published: 2026-08-19

---

**ADHD prevents premature convergence by enforcing strict isolation between parallel divergent branches during Phase 1, then applying a separate critic-based convergence filter before deepening any ideas in Phase 2.**

The UditAkhourii/adhd repository implements a novel reasoning architecture that treats "parallel divergent ideation" as a structured two-phase workflow. Unlike standard chain-of-thought or tree-of-thought approaches that risk early anchoring, ADHD's two-phase diverge-focus loop prevents premature convergence through deliberate cognitive isolation and deferred evaluation. This design ensures the model explores a wide solution space before committing to any specific direction.

## Phase 1: Isolated Divergence

The first phase of the loop generates **N isolated branches**, each operating under a distinct cognitive frame defined in [`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts). 

In [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts), each branch executes a single LLM call using the **DIVERGE** system prompt (lines 61-69). Crucially, the implementation at lines 52-63 ensures that **branches never see the output of any other branch**. Because these isolated executions share no KV-cache or message history, the model cannot be anchored by its own earlier outputs. This architectural choice eliminates the "first-answer-bias" that typically drives premature convergence in sequential reasoning approaches.

## Phase 2: Focus and Deepening

After divergence completes, the system enters the focus phase. Here, the **critic** evaluates all generated ideas for novelty, viability, and potential traps.

Only the top-K ideas survive this filtering and proceed to deepening. In [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) at lines 97-100, the selected ideas undergo a **DEEPEN** pass using a specialized system prompt (lines 15-21) that forces the model into focus mode. This prompt structure requires expanding promising concepts into concrete sketches, identified risks, first steps, and sub-ideas. Because deepening occurs only after the critic has filtered the initial batch, the algorithm avoids investing computational resources in refining low-quality or obvious solutions.

## Design Mechanisms Against Premature Convergence

### Strict Branch Isolation

The complete isolation of divergent branches during Phase 1 prevents the model from "following its own trail." By prohibiting cross-branch visibility, the system in [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) ensures that each of the N parallel frames explores the solution space without contamination from sibling outputs. This maintains search breadth throughout the initial generation stage.

### The Critic as a Convergence Gate

Rather than allowing the model to recursively refine its first promising idea, ADHD inserts a **separate critic pass** between divergence and deepening. This scoring and clustering step provides an unbiased assessment that filters out low-novelty or trapped ideas before any expansion occurs. The convergence decision is therefore based on a comparative analysis of the full candidate set, not on the initial appeal of a single trajectory.

### Non-Obvious Selection Criteria

At lines 87-95 in [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts), the selection logic deliberately surfaces surprising ideas by maximizing a weighted combination of **novelty and viability** rather than raw score alone. This "non-obvious pick" mechanism ensures that the ideas selected for deepening are those most likely to break out of conventional patterns, further protecting against premature convergence on obvious solutions.

## Implementation in the Codebase

The core two-phase logic resides in [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts), which orchestrates the transition from parallel divergence to selective deepening. The [`src/llm.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/llm.ts) module handles low-level `callLLM` invocations for both phases, while [`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts) defines the cognitive frames that give each divergent branch its unique perspective. Users interact with this workflow through [`src/cli.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/cli.ts), which exposes the diverge-focus cycle via command-line options.

```bash

# Run with default 5 parallel frames, 6 ideas per frame

npx adhd run --problem "Add offline support to the web app"

```

```bash

# Increase divergence breadth to 10 branches

npx adhd run --problem "Add offline support to the web app" --frames 10

```

```bash

# View only the deepening results

npx adhd run --problem "Add offline support to the web app" --only-deepen

```

These commands trigger the full two-phase workflow: first spawning isolated divergent branches, then scoring, selecting, and deepening only the most promising candidates.

## Summary

- **ADHD's two-phase diverge-focus loop** explicitly separates idea generation from idea evaluation to maintain search breadth.
- **Branch isolation** in [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) (lines 52-63) prevents KV-cache contamination and first-answer bias by ensuring parallel branches share no state.
- **Deferred deepening** ensures resources are spent only on ideas that survive a rigorous critic pass evaluating novelty and viability.
- **Non-obvious selection** at lines 87-95 prioritizes surprising, high-potential concepts over safe, conventional answers.

## Frequently Asked Questions

### What is the diverge-focus loop in ADHD?

The diverge-focus loop is a structured reasoning pattern implemented in [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) that alternates between **Phase 1** (generating isolated ideas in parallel) and **Phase 2** (selecting and deepening the most promising candidates). This loop treats divergence and convergence as distinct, sequential operations rather than interleaved processes.

### How does branch isolation prevent premature convergence?

By executing each divergent branch as a separate LLM call with no shared message history or KV-cache (as enforced in [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) lines 52-63), the system prevents the model from anchoring on its own early outputs. This isolation eliminates the feedback loops that typically cause chain-of-thought or tree-of-thought systems to converge too quickly on suboptimal solutions.

### What criteria does ADHD use to select ideas for deepening?

ADHD selects ideas using a weighted scoring function that maximizes both **novelty** and **viability** rather than raw completion scores. According to the logic at [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) lines 87-95, this "non-obvious pick" deliberately surfaces surprising ideas that have passed the critic's evaluation for traps and feasibility.

### Where is the two-phase logic implemented in the codebase?

The core two-phase workflow is implemented in **[`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts)**, which coordinates the **DIVERGE** and **DEEPEN** prompts. Supporting modules include **[`src/llm.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/llm.ts)** for LLM interactions, **[`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts)** for cognitive frame definitions, and **[`src/cli.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/cli.ts)** for user-facing command options. Architectural documentation is available in [`documentation/how-it-works.md`](https://github.com/UditAkhourii/adhd/blob/main/documentation/how-it-works.md).