How the ADHD Deepen Phase Connects Sibling Ideas: A Code-Level Breakdown

The deepen phase connects sibling ideas by feeding up to 12 related leaf concepts into the LLM prompt alongside the focused idea, enabling the model to recombine, hybridize, or extend concepts into child ideas that stitch previously isolated branches into a unified design space.

The UditAkhourii/adhd repository implements a creative reasoning loop where the deepen phase serves as the critical third pass designed to "connect the dots" between divergence-phase outputs. By examining the prompt construction in src/engine.ts and the rendering pipeline in src/render.ts, this article explains exactly how the deepen phase connects sibling ideas to produce richer, structurally linked design suggestions.

What Is the Deepen Phase?

The deepen phase is the third pass of the ADHD loop and follows the focus step. Its primary purpose is to synthesize connections between the best-scoring ideas generated during divergence. According to the project documentation in documentation/how-it-works.md, this phase exposes a focused idea to its siblings—other leaf nodes from the divergence phase—so the LLM can perform recombination rather than operating in isolation.

Gathering and Filtering Sibling Ideas

Inside src/engine.ts, the deepenIdea function builds a prompt that includes a dedicated SIBLING IDEAS section. The engine filters out the current idea to prevent self-reference, limits the list to avoid context bloat, and formats each sibling as a concise bullet point.

As shown in lines 72-77 of src/engine.ts, the filtering logic specifically checks s.id !== idea.id, slices the first 12 siblings, and maps them to - <text> entries:

// Inside src/engine.ts – building the prompt for deepenIdea
const userPrompt = `PROBLEM:
${problem}

FOCUS IDEA:
${idea.text}
${idea.rationale ? `(${idea.rationale})` : ""}

SIBLING IDEAS (use for recombination if useful):
${siblings
  .filter((s) => s.id !== idea.id)
  .slice(0, 12)
  .map((s) => `- ${s.text}`)
  .join("\n")}

Output JSON:
{
  "sketch": "...",
  "childIdeas": [{ "text": "...", "rationale": "..." }]
}`;

This 12-sibling ceiling provides the model with a bounded catalog of related concepts sufficient for cross-pollination without exhausting the context window.

The Prompt Structure That Enables Recombination

The full prompt assembled in src/engine.ts (lines 66-84) contains four distinct sections: the original PROBLEM, the FOCUS IDEA being deepened, the filtered SIBLING IDEAS catalog, and strict JSON output instructions. By placing sibling ideas immediately after the focused concept, the prompt explicitly instructs the LLM to treat them as recombination material.

The requested JSON output forces the model to return a sketch string and a childIdeas array. This structured response ensures the engine can parse the results deterministically and integrate them back into the idea tree.

Linking Child Ideas Back to the Tree

Once the LLM returns its JSON response, the engine does not treat the child ideas as orphaned outputs. In src/engine.ts (lines 100-107), each child idea is assigned the parentId of the original focused idea and a deeper depth value. This structural linking means children remain attached to the branch being deepened while carrying conceptual DNA from the sibling context that informed their creation.

This parent-child relationship allows the system to trace every deepened concept back to its origin, preserving the hierarchical integrity of the design space.

Rendering Connected Branches

The connections become visible in the final report. In src/render.ts (lines 71-73), the deepened branches are rendered as integrated insights rather than isolated fragments. The renderer processes these deeper nodes to show how sibling recombination produced coherent design paths, presenting them as the "connected dots" that tie previously separate branches together.

Integration in the Main Run Loop

The run function in src/engine.ts (lines 97-108) orchestrates the end-to-end deepen phase. After the focus phase identifies the top-K candidates, the engine invokes deepenIdea for each and aggregates the responses under the deepened field of the final output.

// Example of handling the deepened result after run()
const result = await run({ problem, framesPerRun: 5, ideasPerFrame: 6, topK: 3 });
for (const d of result.deepened) {
  console.log("Deepened sketch:", d.sketch);
  console.log("Generated child ideas:");
  d.childIdeas.forEach((c) => console.log("- ", c.text));
}

This aggregation ensures that consumers of the RunEvent receive both the original focused ideas and their deepened, sibling-informed extensions in a single structured payload.

Summary

  • The deepen phase connects sibling ideas by injecting up to 12 filtered sibling concepts into the LLM prompt via the deepenIdea function in src/engine.ts.
  • The SIBLING IDEAS section primes the model to recombine, hybridize, or extend the focused idea using cross-branch context from the divergence phase.
  • Returned child ideas inherit a parentId and deeper depth, preserving structural links within the idea tree.
  • The run function aggregates deepened outputs under the deepened field, while src/render.ts visualizes these as integrated branches that unify the design space.

Frequently Asked Questions

How many sibling ideas does the deepen phase include in the prompt?

The engine includes a maximum of 12 sibling ideas. In src/engine.ts lines 72-77, the deepenIdea function filters out the current idea with s.id !== idea.id, applies .slice(0, 12), and formats each remaining sibling as - <text>. This limit balances contextual breadth with token constraints.

What JSON structure does the deepen phase expect from the LLM?

The prompt explicitly requests a JSON object containing a sketch string and a childIdeas array. Each element in childIdeas includes text and rationale fields. The engine parses this structure to extract narrative explanations and structured child concepts for integration into the idea tree.

How are child ideas linked back to the original idea tree?

In src/engine.ts lines 100-107, each generated child idea is assigned the parentId of the focused idea being deepened and its depth value is incremented. This ensures the new concepts remain structurally attached as descendants rather than disconnected leaves.

Where does the final output store the deepened results?

The run function in src/engine.ts lines 97-108 collects deepened results and places them in the deepened array of the final output. This field contains the sketches and child ideas for each top-K idea that underwent the deepen phase, making the connected sibling context available to downstream consumers and the renderer.

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 →