# How ADHD Implements Isolated Reasoning Processes Using Distinct Cognitive Frames

> Discover how ADHD implements isolated reasoning with unique cognitive frames. Learn how divergent and convergent thinking create parallel tracks for problem exploration without interference.

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

---

**ADHD separates divergent and convergent reasoning into independent, parallel tracks where each "frame" injects a unique system-prompt into the LLM generator, enabling isolated exploration of the same problem under diverse mental models without cross-talk or criticism.**

The ADHD repository by UditAkhourii implements a Tree-of-Thought engine that deliberately isolates reasoning processes by assigning different **cognitive frames** to parallel branches. Each frame acts as a lightweight strategy object representing a distinct perspective—such as "Hardware engineer," "10-year-old," or "Competitor"—allowing the engine to generate ideas that remain uncontaminated by other viewpoints until a deliberate convergence phase.

## Architecture of Isolated Reasoning in ADHD

### Frame Definition and Selection

The isolation mechanism begins in **[`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts)**, where the `Frame` type defines the structure of a cognitive perspective.

Each frame carries three key properties:

- **`label`** – A human-readable identifier (e.g., `"First Principles Decomposition"`)
- **`prompt`** – The custom instructions injected into the LLM context
- **`tags`** – Categories used for bias-aware selection (e.g., `["technical", "systems"]`)

The static `FRAMES` array enumerates all available perspectives. The `selectFrames` helper randomizes selection while biasing toward tags relevant to the run mode and guarantees inclusion of at least one "wild-card" frame to maintain non-determinism.

This design ensures that **no two branches share the same cognitive lens** during the critical divergence phase.

```typescript
import { selectFrames } from "./frames";

// Select 3 frames with code-centric bias for technical problems
const frames = selectFrames(3, /*codeMode=*/ true);

// Returns frames like:
// - { label: "Systems Architect", prompt: "...", tags: ["technical", "systems"] }
// - { label: "Naive Questioner", prompt: "...", tags: ["beginner", "wildcard"] }
// - { label: "Performance Engineer", prompt: "...", tags: ["technical", "optimization"] }

```

### Divergent Branch Execution

The **[`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts)** file orchestrates isolated reasoning through the `divergeBranch` function. This function receives a single frame and executes an **independent LLM call** with no access to other branches' outputs.

```typescript
// From src/engine.ts - simplified for clarity
async function divergeBranch(
  problem: string,
  context: string | undefined,
  frame: Frame,
  ideasPerFrame: number,
  model?: string
): Promise<Branch> {
  const userPrompt = `
PROBLEM:
${problem}

${context ? `CONTEXT:\n${context}\n\n` : ""}FRAME — ${frame.label}:
${frame.prompt}

Generate ${ideasPerFrame} ideas under this frame.`;

  const raw = await callLLM({
    model,
    systemPrompt: DIVERGE_SYSTEM,  // Universal divergent instructions
    userPrompt                     // Frame-specific context injected here
  });
  // Parse JSON response into isolated ideas for this frame only
}

```

**Critical isolation properties:**

- Each branch receives only the **original problem description** as shared state
- The `DIVERGE_SYSTEM` prompt contains no information about other frames
- No inter-branch communication or scoring occurs during generation
- Ideas from one frame cannot influence another frame's output

## Running Complete Isolated Reasoning Cycles

To execute a full run with isolated reasoning processes, integrate frame selection with the main engine:

```typescript
import { selectFrames } from "./frames";
import { runEngine } from "./engine";

// Configure isolated reasoning with 3 cognitive frames
const frames = selectFrames(3, true);

// Execute parallel divergent reasoning, then converge
const result = await runEngine({
  problem: "How can we reduce latency for user-profile lookups?",
  context: undefined,
  frames,               // Isolated reasoning contexts
  ideasPerFrame: 5,     // 5 ideas × 3 frames = 15 diverse starting points
});

```

The engine automatically:

1. **Spawns** isolated branches for each selected frame
2. **Gathers** raw ideas without cross-pollination
3. **Scores** and **clusters** results only after all branches complete
4. **Deepens** promising clusters through additional frame-driven expansion

This **delayed convergence** mirrors human brainstorming where participants first generate independently before sharing and refining.

## Comparison: Frame-Driven vs. Standard Chain-of-Thought

| Aspect | Standard CoT | ADHD Frame-Driven Isolation |
|--------|-----------|----------------------------|
| **Perspective variety** | Single, continuous reasoning path | Multiple parallel cognitive frames |
| **Cross-talk prevention** | N/A (sequential) | Enforced by architectural separation |
| **Idea diversity** | Limited by consistency bias | Guaranteed by conflicting frame prompts |
| **Convergence timing** | Immediate, step-by-step | Explicit, post-divergence phase |

The frame-based approach specifically addresses **premature pruning**—the tendency of LLMs to abandon unconventional ideas when evaluating during generation. By deferring all evaluation until after isolated generation completes, ADHD preserves ideas that might otherwise be self-censored.

## Key Source Files for Isolated Reasoning

- **[`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts)** – `Frame` type definition, `FRAMES` catalog, and `selectFrames` selection logic with tag-based bias and wild-card guarantees
- **[`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts)** – Tree-of-Thought orchestration including `divergeBranch`, scoring, clustering, and deepening phases
- **[`src/types.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/types.ts)** – Data structures: `Branch`, `Idea`, `Score`, `Cluster`
- **[`src/llm.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/llm.ts)** – LLM abstraction layer used by both divergent and convergent phases

## Summary

- **Isolation is architectural**: Each cognitive frame runs as a separate branch with no shared state beyond the original problem statement
- **Frame selection is strategic**: `selectFrames` randomizes, biases toward relevant tags, and ensures wild-card inclusion for unpredictability
- **Divergence precedes convergence**: All frame-generated ideas exist in isolation until explicit scoring and clustering occurs
- **Source files**: [`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts) defines frames; [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) executes isolated branches via `divergeBranch`

## Frequently Asked Questions

### What prevents frames from influencing each other during generation?

ADHD enforces isolation at the infrastructure level. The `divergeBranch` function in [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) receives a single `Frame` object and constructs a user prompt containing **only** that frame's label and instructions. The LLM call includes no references to other frames, no previous branch outputs, and no shared scratchpad. Each branch is a fresh request with identical system prompts but divergent user contexts.

### How does ADHD choose which cognitive frames to activate?

The `selectFrames` function in [`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts) implements a three-step selection: (1) shuffle all available frames for randomness, (2) sort by tag relevance when `codeMode` is enabled to prioritize technical perspectives, and (3) guarantee at least one "wild-card" frame (typically marked with `["beginner"]` or `["wildcard"]` tags). This balances domain expertise with cognitive diversity.

### Can custom frames be added for domain-specific reasoning?

Yes. The `Frame` type in [`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts) is a straightforward interface requiring only `label`, `prompt`, and `tags`. Adding a custom frame involves extending the `FRAMES` array with a new object containing domain-specific instructions. The `tags` field supports arbitrary strings, enabling filtered selection for specialized run modes beyond the built-in `codeMode` boolean.

### When does isolation end and convergence begin?

Isolation terminates after all `divergeBranch` calls complete and their `Branch` objects are collected. The `runEngine` function then transitions to scoring (where ideas compete across frames), clustering (grouping semantically similar concepts regardless of origin frame), and deepening (selected clusters may spawn new frame-driven sub-branches). This explicit phase boundary prevents premature judgment from contaminating generative diversity.