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 →