tawjih Splits Every Prompt Node Into Human, Machine and Reading Sides, and Only One Gets Sent

Yesterday a solo dev shipped tawjih, a single-file Python tool (standard library only, Python 3.11+) for managing LLM knowledge as trees of small Markdown files. Step 2 is the twist: the model never sees most of what you wrote. Most tools in this space try to stuff more into the context window. This one deliberately keeps almost everything out of it.

What’s new

Every node in a tawjih tree has three sides. The human side holds your own notes and explanations, the stuff you’d write for a teammate or for future you. The machine side holds the instructions and optional Python code meant for the LLM. The reading side holds verbatim passages pulled from books or research, each with its citation attached. Trees go up to 6 levels deep, from general at the top down to the individual part at the bottom.

Picture a tree about code review. The top node might be “review a pull request,” and a leaf six levels down might be “check error handling in async functions.” Each node is a small Markdown file, so you can open it in any editor, diff it in git and fix one piece without touching the rest. That is a big change from one giant system prompt that nobody dares edit.

The twist

Build time and run time are strictly separated. At build time you distill the human and reading sides into the machine side. At run time, only the machine side goes to the model. Your personal notes and the raw book passages never touch the context window.

Think about what that buys you. You can keep a long, messy quote from a research paper on the reading side as your evidence, and the model only receives the tight instruction you distilled from it. Your prompts stay short and cheap. Your sources stay intact and citable. There are no RAG chunks, no vector database and no framework to install. Just files and one script.

Mini-workflow

  1. 📚 Deposit a UTF-8 book or research text, then run filter. The LLM classifies passages against your tree and writes a reviewable JSON report. You read the report before anything is saved, so nothing sneaks in.
  2. ✅ Run accept to append the approved quotes to the reading sides of the matching nodes.
  3. ✍️ Distill human and reading into the machine side by hand, or with edit assisted by a model. Hand-writing gives you the tightest result. Model assistance is faster when a node has a lot of source material.
  4. 🔀 Wire nodes from different trees into a workflow using plain words, in English or Arabic:

python tawjih.py produce review 1.1 TO 1.2 IF error / 1.1 TO 1.3 IF NOT error / 1.2 AND 1.3 TO 2.1 --input "..." --backend ollama

Read that example as a story. Node 1.1 runs first. If its output mentions an error, it goes to 1.2. If not, it goes to 1.3. Then 1.2 and 1.3 join and feed node 2.1. The whole flow fits on one line.

The DSL covers piping (A TO B), branching (A TO B AND C), joining (B AND C TO D), conditions (IF word / IF NOT word), model-picked routing (A AMONG B C D) and chaining (A TO D THROUGH B C). Because the steps are plain words, you can sketch a workflow on paper and type it almost as written.

Pro tips

  • Start with the dry backend. It shows you the exact prompts before you spend a single token. Read them like the model would. If a prompt feels vague to you, it will feel vague to the model too. There is also a manual mode where you paste prompts into any web UI and paste answers back, which is handy if you only have a chat subscription and no API key.
  • Every response is cached by the SHA-256 of provider, model and exact prompt. If a long run dies halfway, --resume skips finished steps, and --resume --redo <step> regenerates just the one bad step. That means a flaky network at step 9 of 10 costs you one call, not ten.
  • Each run writes a JSON audit trail in history/ with the digests of the machine sides used, so you can reproduce it later. If a result looks different next week, compare digests first. You will quickly see whether a node changed or the model drifted.
  • Keep machine sides small. If one grows past a screen or two, split the node into children. That is what the 6 levels are for.

Honest caveats

It’s v0.5.1 and experimental. Code steps run through exec, so --allow-code is opt-in. Leave it off until you’ve read every code block in the nodes you’re running. The network backends have only been tested against a local mock server, so expect rough edges with real providers. The license is CC BY-NC-SA 4.0, so non-commercial use only. The author is asking for feedback, especially from people running local Ollama models.

If you like the idea of keeping your thinking and your prompts in separate files, grab it from GitHub (AlmodinyMk/LLM-tawjih-Model-building) and run a dry pass on one small tree. Start with three nodes, not thirty. Tell the author what breaks 🏴‍☠

I built tawjih (LLM-tawjih-Model-building): A zero-dependency, single-file Python tool to manage LLM knowledge in 3-sided trees and run branching workflows across them
by u/Basic_You_2402 in PromptEngineering

Scroll to Top