{"slug": "thoughtdag-editing-llm-context-via-graphs", "title": "ThoughtDAG: Editing LLM Context via Graphs", "summary": "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.", "body_md": "# ThoughtDAG: Editing LLM Context via Graphs\n\nI built a prototype called ThoughtDAG to make this state actually editable.\n\n## Context as a Graph\n\nInstead 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.\n\nIf you delete an edge and hit regenerate, that entire branch is pruned from the model's memory instantly.\n\n## The Logic Behind the DAG\n\nI 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:\n\n**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.\n\nIt's essentially a visual, human-controlled representation of the model's short-term memory.\n\n## Technical Stack & Local Setup\n\nThe 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.\n\nThe build is pretty straightforward for anyone wanting to dive into the code:\n\n- React / TypeScript\n- React Flow (for the canvas)\n- Zustand (state management)\n- Vercel AI SDK\n\n```\n# Project is MIT licensed\n# Repo: https://github.com/chenxiachan/thoughtdag\n```\n\nI'm currently weighing whether manual context control is actually a productivity win or if most people would prefer delegating this to [RAG](/en/tags/rag/) or agents. But for complex prompt engineering, having a \"kill switch\" for specific context branches feels way more reliable.\n\n[Next Claude Code: Handling High-Stakes Domain Knowledge →](/en/threads/3700/)", "url": "https://wpnews.pro/news/thoughtdag-editing-llm-context-via-graphs", "canonical_source": "https://promptcube3.com/en/threads/3715/", "published_at": "2026-07-26 14:46:11+00:00", "updated_at": "2026-07-26 15:12:03.294763+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "large-language-models"], "entities": ["ThoughtDAG", "Ollama", "OpenAI", "React", "TypeScript", "React Flow", "Zustand", "Vercel AI SDK"], "alternates": {"html": "https://wpnews.pro/news/thoughtdag-editing-llm-context-via-graphs", "markdown": "https://wpnews.pro/news/thoughtdag-editing-llm-context-via-graphs.md", "text": "https://wpnews.pro/news/thoughtdag-editing-llm-context-via-graphs.txt", "jsonld": "https://wpnews.pro/news/thoughtdag-editing-llm-context-via-graphs.jsonld"}}