How ADHD's Architecture Differs from Chain-of-Thought (CoT) and Tree-of-Thought (ToT)
ADHD uses isolated parallel threads with no shared context and distinct generator-critic phases, while CoT uses a single linear thread and ToT uses a shared-context search tree.
Unlike standard reasoning pipelines, the ADHD (Adaptive Divergent-Heavy Design) architecture deliberately breaks from both Chain-of-Thought and Tree-of-Thought patterns. As implemented in UditAkhourii/adhd, it enforces isolation over search, frames over step-variation, and mechanical separation over single-pass reasoning. This article explains how ADHD's architecture differs from CoT and ToT at the implementation level.
Thread Model: Parallel Isolation vs. Shared Context
The most fundamental architectural difference lies in how branches execute.
Chain-of-Thought: Single Linear Thread
CoT produces one uninterrupted reasoning sequence. The entire thought chain occupies a single context window, with each step building on all previous tokens.
Tree-of-Thought: One Tree, Shared Session
ToT expands a tree structure but keeps it within one shared context. Branches are explored depth-first or breadth-first, yet all nodes remain visible to each other during traversal.
ADHD: N Parallel, Isolated Threads
In src/engine.ts, the diverge phase spawns N completely separate LLM calls:
// From src/engine.ts lines 52-63
const divergePromises = frames.map(frame =>
divergeBranch({
problem: reframedProblem,
frame: frame,
// Each branch gets its own isolated query()
})
);
await Promise.all(divergePromises);
Each divergeBranch invokes callLLM() independently. No branch can reference another's output—the isolation is mechanical, not promised.
Context Sharing: None vs. Full Visibility
| Approach | Context Behavior | Risk |
|---|---|---|
| CoT | Full shared history | Premature anchoring on early steps |
| ToT | Entire tree visible | Solutions converge on explored paths |
| ADHD | Zero shared context | Higher token usage, but guaranteed divergence |
The stripAnchors option in src/engine.ts (Phase 0) explicitly removes incidental implementation details before divergence begins. This prevents any "priming" that could bias parallel branches.
Generator-Critic Split: Mechanical Separation
CoT and ToT use the same model instance for generation and evaluation, alternating in a single session. ADHD enforces two distinct phases with opposite system prompts.
Generator Phase (Phase 1: Diverge)
// Generator prompt in src/frames.ts
system: "You are a creative generator exploring diverse angles..."
Critic Phase (Phase 2: Score + Cluster)
// Critic prompt—opposite stance
system: "You are a critical evaluator assessing viability..."
These are separate API calls in src/engine.ts lines 85-99. The critic cannot see the generator's reasoning traces—only the final idea outputs.
Cognitive Frames vs. Next-Step Variation
ToT branches by varying the next move in a sequence. ADHD branches by varying the entire framing of the problem.
Frames are defined in src/frames.ts as "vantage operators":
- "Think like a hardware engineer optimizing for throughput"
- "Approach this as a security researcher looking for attack surfaces"
- "Reframe as a UX designer optimizing for cognitive load"
Each frame re-poses the complete problem from its vantage point. The frame selection happens before any generation:
// src/engine.ts - frame selection before parallel execution
const frames = selectFrames(problem, framesPerRun, codeMode);
True Parallelism: Concurrent API Calls
ToT's tree traversal is mostly sequential—branches expand one after another to fit context limits. ADHD executes concurrency parallel calls simultaneously:
await run({
problem: "Design a low-latency data pipeline for real-time analytics",
framesPerRun: 5, // 5 parallel generator calls
ideasPerFrame: 6, // 6 ideas per frame
concurrency: 4, // 4 concurrent LLM requests
});
The Promise.all(divergePromises) pattern in src/engine.ts implements this without blocking.
Architectural Phases in src/engine.ts
| Phase | Function | CoT/ToT Equivalent |
|---|---|---|
| 0. Reframe | Strip anchors, normalize problem | N/A |
| 1. Diverge | divergeBranch() × N frames |
Single generation |
| 2. Score + Cluster | scoreIdeas(), clusterIdeas() |
Same-pass evaluation |
| 3. Deepen | deepenIdea() on top-K |
Continuation |
The deepen phase (lines 97-108) applies another isolated LLM call: "connecting the dots" without exposing other branches' reasoning.
When to Use Each Architecture
| Architecture | Best For | Avoid When |
|---|---|---|
| CoT | Math, deterministic logic, verifiable steps | Novel problems requiring creative leaps |
| ToT | Planning, puzzles, explicit search spaces | Context limits prevent full tree storage |
| ADHD | Open-ended design, interdisciplinary ideation, escaping local optima | Tight token budgets or single-answer problems |
Summary
- Isolation, not search: ADHD's parallel branches share zero context, enforced by separate
query()calls insrc/engine.ts - Frames, not steps: Branches stem from cognitive vantage points in
src/frames.ts, not next-move variations - Mechanical split: Generator and critic are distinct LLM invocations with opposite system prompts—no single-pass alternation
- True concurrency:
Promise.all()executes frames simultaneously, not sequentially
Frequently Asked Questions
What makes ADHD's isolation "mechanical" rather than just a prompt instruction?
The isolation is enforced at the API level. Each frame triggers a separate callLLM() invocation in src/engine.ts, writes to its own response variable, and cannot access sibling branches' outputs. This is architectural, not instructional—unlike CoT/ToT where a prompt might say "consider alternatives" but all alternatives live in one shared context.
Can ADHD use the same model for both generator and critic phases?
Yes, though the implementation permits different models. The key requirement is separate invocations. In src/llm.ts, the wrapper accepts distinct system prompts per call. Using the same model with different prompts still satisfies the mechanical split because the generator's context window is closed before the critic begins.
Why does ADHD strip anchors before diverging?
Anchors are incidental implementation details that prematurely constrain thinking—e.g., "using our current Python stack." The stripAnchors phase in src/engine.ts removes these to ensure frames operate on the pure problem structure. Without this, even isolated branches might converge on similar solutions because they were primed with identical constraints.
Is ADHD slower than CoT or ToT due to multiple API calls?
Latency depends on concurrency settings. With concurrency: 4 or higher, Phase 1 (divergence) completes in roughly the time of one slowest LLM call plus overhead. CoT can be faster for simple problems but requires sequential reasoning. ToT's depth-first exploration often exceeds ADHD's wall-clock time for equivalent branch counts because it cannot parallelize within context limits.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →