How the ADHD Architecture Addresses Premature Convergence in AI Reasoning

ADHD (Adaptive Divergence‑Heavy Design) prevents premature convergence by strictly separating idea generation and evaluation into two isolated phases: parallel divergent branches that never share state, followed by a single critic phase that scores and selects only after all ideas exist.

The premature convergence problem plagues many AI reasoning pipelines—once a language model produces an initial plausible answer, subsequent reasoning tends to anchor on that first output, shutting down exploration of better alternatives. The open-source ADHD architecture (UditAkhourii/adhd) solves this through a hard architectural boundary between generation and evaluation implemented in src/engine.ts. This article examines exactly how that two-phase design eliminates early-lock-in.

The Core Two-Phase Split: Divergence Then Convergence

ADHD's prevention strategy rests on a simple but rigid rule: convergence happens after divergence, never during. The engine enforces this through completely separated computational phases.

Phase 1: Divergence (ADHD-Mode)

In the first phase, the system selects cognitive frames and spawns an independent LLM query for each frame. Crucially, as noted in the engine source:

// src/engine.ts#L4-L6
// Each branch runs in complete isolation—no shared KV-cache,
// no cross-branch visibility, no ranking hints.

This hard wall between branches means:

  • Each generator call uses a fresh, stateless Agent SDK session
  • The DIVERGE_SYSTEM prompt forbids evaluation or hedging
  • Branches output raw JSON ideas only, with no quality assessments

The isolation is mechanically enforced rather than merely suggested. In src/engine.ts#L61-L70, every branch receives the same system prompt instruction: generate, do not evaluate.

Phase 2: Convergence (Critic Mode)

Only after all branches complete does a single critic call score, cluster, and deepen the top-K ideas. The engine explicitly states this sequencing in src/engine.ts#L12-L13:

// "Convergence happens after divergence, never during."

Because evaluation runs after generation, the critic's rankings cannot influence any branch's output. This eliminates the feedback loops that normally cause premature convergence in single-pass or interleaved reasoning systems.

Mechanical Isolation: How the Engine Enforces Separation

Stateless Parallel Queries with System Prompt Switching

The architecture uses distinct system prompts to mechanically reorient model behavior rather than relying on instruction-following alone.

For generation (src/engine.ts#L61-L70):

const raw = await callLLM({
  model,
  systemPrompt: DIVERGE_SYSTEM,  // "You are in DIVERGENT mode..."
  userPrompt,
});

The DIVERGE_SYSTEM prompt strictly requires JSON-only output and prohibits any evaluation language.

For evaluation (src/engine.ts#L71-L89):

const raw = await callLLM({
  model,
  systemPrompt: SCORE_SYSTEM,   // "You are in CONVERGENT mode..."
  userPrompt,
});

The SCORE_SYSTEM prompt explicitly requests structured scoring across dimensions including novelty, viability, and fit—dimensions the generator was forbidden from considering.

Controlled Concurrency via Semaphore

To keep divergence tractable without sacrificing isolation, src/engine.ts#L49-L52 implements a semaphore:

import pLimit from 'p-limit';
const limit = pLimit(concurrency);  // default: 4 simultaneous branches

This caps resource usage while preserving the statelessness guarantee—each concurrent branch still operates in complete isolation from others.

The Three-Step Critic Pipeline: Structured Down-Selection

The convergence phase isn't a single evaluation call. It's a deliberately sequential pipeline that prevents premature commitment:

Step Function Purpose
1. Score scoreIdeas Quantitative assessment across multiple dimensions
2. Cluster clusterIdeas Group by underlying angle to detect superficial variation
3. Deepen deepenIdea Expand only top-K ideas that survived both filters

This structure ensures only ideas that pass quantitative scrutiny receive additional computation. The generator never sees partial scores or intermediate rankings that could bias exploration.

Trap Detection and Exclusion

The scoring system in src/engine.ts#L80-L86 specifically flags traps—common failure patterns like hidden costs or premature abstractions:

// From SCORE_SYSTEM prompt excerpt:
// "Flag trap indicators: hidden operational costs, 
//  over-engineering, solution-problem mismatch"

Trapped ideas are excluded from the shortlist before the deepening step, preventing the final focused pass from reinforcing problematic directions.

Practical Implementation

To invoke the complete diverge-then-converge cycle:

import { run } from "./src/engine.js";

await run({
  problem: "Design a low‑latency server‑less data pipeline",
  framesPerRun: 5,      // 5 diverse cognitive frames
  ideasPerFrame: 6,     // 6 raw ideas per frame
  topK: 3,              // Deepen only top 3 after scoring
  concurrency: 4,       // Parallel isolation ceiling
  stripAnchors: true,   // Remove incidental tech-stack anchors first
});

This single call executes the full pipeline: parallel branch spawning with DIVERGE_SYSTEM, then sequential scoreIdeas → clusterIdeas → deepenIdea using SCORE_SYSTEM.

Key Architectural Files

File Role
src/engine.ts Core orchestrator: defines the two-phase loop, isolates branches with DIVERGE_SYSTEM/SCORE_SYSTEM, implements the three-step critic pipeline
src/llm.ts Wrapper around the Claude Agent SDK; provides callLLM used by both phases
src/frames.ts Supplies cognitive frames that re-pose the problem for each divergent branch
documentation/how-it-works.md Documents the architectural rationale for phase separation (L5-L18)

Summary

  • Hard phase boundary: Generation and evaluation never interleave, enforced by src/engine.ts architecture
  • Mechanical isolation: Stateless sessions, no shared KV-cache, distinct system prompts prevent cross-branch influence
  • Structured convergence: Score → cluster → deepen pipeline ensures quantitative filtering before resource commitment
  • Trap awareness: Explicit detection of hidden costs and premature abstractions excludes flawed directions early

Frequently Asked Questions

How does ADHD differ from simple temperature sampling or majority voting?

Temperature sampling and majority voting operate within a single inference pass or aggregate identical prompts. ADHD's divergence phase uses cognitive frames (src/frames.ts) to re-pose the problem from fundamentally different angles, and the isolation guarantee means each frame explores without knowledge of others. The critic phase then performs model-driven selection rather than statistical aggregation, enabling deeper analysis of why ideas differ.

Can the critic phase itself introduce premature convergence?

The design specifically constrains the critic: it operates only on fully generated ideas, cannot request regeneration, and the deepening step is capped at topK ideas. The three-step pipeline (score, then cluster, then deepen) prevents the critic from over-investing in early high scorers before seeing the full distribution. As implemented in src/engine.ts, the critic selects but does not generate.

Why use separate system prompts instead of instruction tuning?

System prompt switching provides runtime behavioral reorientation without model retraining. The DIVERGE_SYSTEM and SCORE_SYSTEM prompts in src/engine.ts#L61-L89 mechanically enforce different output constraints—JSON-only generation versus structured scoring—making the phase boundary inspectable and version-controllable.

What happens if all divergent branches produce poor ideas?

The scoring system (src/engine.ts#L80-L86) includes trap detection that flags common failure modes. If no ideas pass the viability threshold, the pipeline returns the scored set without deepening, signaling that the frame selection or problem formulation needs revision. The architecture fails explicitly rather than converging on mediocrity.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →