cd /news/developer-tools/thoughtdag-editing-llm-context-via-g… · home topics developer-tools article
[ARTICLE · art-74373] src=promptcube3.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

ThoughtDAG: Editing LLM Context via Graphs

A developer built ThoughtDAG, a prototype that replaces the standard scrollable LLM chat history with a directed acyclic graph (DAG) on an infinite canvas, making context fully editable. Each Q&A exchange becomes a node, and edges define the prompt: crawling ancestors to sequence message history, with operations like branching, merging, and pruning. The tool is local-first, uses IndexedDB, supports Ollama or any OpenAI-compatible API, and is MIT-licensed on GitHub at https://github.com/chenxiachan/thoughtdag.

read1 min views1 publishedJul 26, 2026
ThoughtDAG: Editing LLM Context via Graphs
Image: Promptcube3 (auto-discovered)

I built a prototype called ThoughtDAG to make this state actually editable.

Context as a Graph #

Instead of a scrollable list, every Q&A exchange is a node on an infinite canvas. The edges aren't just for show—they define the prompt. When you trigger a request from a specific node, ThoughtDAG crawls the incoming graph, collects the ancestors, and sequences them into the message history sent to the LLM.

If you delete an edge and hit regenerate, that entire branch is pruned from the model's memory instantly.

The Logic Behind the DAG #

I avoided making this an "autonomous agent" because I want manual control over the reasoning chain. Using a Directed Acyclic Graph (DAG) allows for three specific manual operations:

Branching: Testing an alternative angle without polluting the main path.Merging: Pulling insights from two different research branches into one new prompt.Pruning: Cutting out the "hallucination" or the detour before asking a follow-up.

It's essentially a visual, human-controlled representation of the model's short-term memory.

Technical Stack & Local Setup #

The tool is local-first, using IndexedDB for storage so there's no need for accounts. It supports Ollama for local inference or any OpenAI-compatible API.

The build is pretty straightforward for anyone wanting to dive into the code:

  • React / TypeScript
  • React Flow (for the canvas)
  • Zustand (state management)
  • Vercel AI SDK

I'm currently weighing whether manual context control is actually a productivity win or if most people would prefer delegating this to RAG or agents. But for complex prompt engineering, having a "kill switch" for specific context branches feels way more reliable.

Next Claude Code: Handling High-Stakes Domain Knowledge →

── more in #developer-tools 4 stories · sorted by recency
── more on @thoughtdag 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/thoughtdag-editing-l…] indexed:0 read:1min 2026-07-26 ·