DEV Community

ContextTree
ContextTree

Posted on

I built a visual LLM canvas where every branch has its own model, prompt, and context settings

The problem I kept hitting

Every time I went deep on a topic with ChatGPT, one tangent would
poison the whole thread. You ask a follow-up question, and suddenly
your entire conversation context is contaminated with an irrelevant
detour. The LLM loses the plot.

The standard workaround? Open a new chat. Paste context manually.
Repeat. That's not a solution, that's giving up.

I wanted branches — real ones. Not tabs. Not separate threads you
manage yourself. Branches that inherit the right context automatically
and stay isolated from each other.

So I built ContextTree.

What it does

ContextTree is a node-based visual canvas for LLM conversations.
Every message is a node. Branching is a first-class action, not a
workaround.

The core invariant: a child node only inherits its direct parent
lineage — never siblings, never cousins.
No cross-contamination.

But the feature that surprised me most during development is what
each node carries independently:

  • Its own LLM model (GPT-4o on one branch, Gemini Flash on another)
  • Its own custom system prompt (scoped to that node and its children)
  • Its own advanced settings: temperature, max output tokens, history mode, last K messages, context budget in tokens, external context chunk count

This means on one canvas you can have a general assistant node, fork
into a strict legal-persona branch with a lawyer system prompt and
tight context budget, then fork again into a summarizer with low
temperature. Three personalities, zero interference, one visual graph.


The hardest design decision: context inheritance

The honest rule in the codebase:

A child node never reads parent live state — no shared LangGraph
state, no reads of the parent's current summary after the fork
moment. Each node evolves independently.

However, ancestry-scoped vector search lets a child retrieve
relevant snippets from any ancestor's history, capped at the
fork point. Branches inherit knowledge, not state.

This distinction took a while to nail. "Knowledge not state" is the
mental model that made the architecture clean. If you want hard
isolation, set SIMILAR_CONTEXT_LIMIT=0 per node.


What I'm still figuring out

  • Prompt stack order — should users be able to reorder layers?
  • Is per-node system prompt enough, or do people want per-node RAG sources pinned differently?
  • The multi-LLM branching UX — is it obvious enough what's happening?

Try it

Demo:CONTEXTTREE
Video walkthrough: https://youtu.be/AqmICcc26VI

Built solo. Early stage. Brutal feedback welcome — especially from
anyone who's built multi-agent or prompt engineering tooling.

Top comments (0)