GitOfThoughts: version-controlled reasoning
Reasoning you can replay, diff and merge. We were building tree-search reasoning systems and kept asking where an agent should keep its memory. So we tried git. Here is the story, and what we found.
We have been building ReTreVal[1], our tree-search framework, and exploring different ways to do tree search and test-time scaling. Along the way, one component kept coming back: memory. What should an agent remember from the problems it has already worked on, and where should it keep it?
We tried the simple things first. We gave the agent markdown files and similar notes that analysed each failure, stored them, and passed them back in through the context. Those experiments are in our earlier work. They taught us a lot, and they left us with a new question: why not use git?
Git is well established. Developers have used it for a very long time to track, version and store code, and it already has the vocabulary we kept reaching for: branches for alternatives, commits for steps, and merges for combining what two lines of work found.
So we tried it. GitOfThoughts saves an agent’s reasoning tree in an ordinary git repository, with one commit for each scored thought (Fig. 1). This post walks through what that looks like and what we found. The figures are interactive, so feel free to click around.
Click any commit to see what is inside it. Each node holds four small files, and the scores and tags decide which branch wins.
Why not use git as memory?
We tested this with ReTreVal-style tree search, an approach to test-time scaling, and git fits it well because it has branches, merges and more. So git might work natively with any tree-search-style algorithm or framework, such as Tree of Thoughts[2] and LATS[3]. Tracking an agent’s entire reasoning trace in git could be a reliable approach, and for agent memory architectures, we think git is a direction worth exploring.
The heart of GitOfThoughts is a translation table (Fig. 2). For each piece of an agent’s reasoning, we picked the git object that already does the same job. A scored thought becomes a commit, and the commit hash is its identity. A refinement is a child commit, so the parent link shows which thought it improved. The combined score goes into git notes, and the validation outcome becomes a tag.
- Scored reasoning nodecommit
- Node identitySHA-1 commit hash
- Refinement of a thoughtcommit parent edge
- Combined scoregit notes
- Validation outcometag: success_* / failed_*
- Exploration pathbranch
- Session vs. cross-sessionmaster vs. memory branch
- Keyword retrievalgit log --grep
- Content retrievalgit log -S (pickaxe)
- Cross-agent mergegit fetch + git merge
- Reproducible artefactgit bundle
- Signed tracegit commit -S
With that table in place, git already does three useful things well.
- Replay it
- Open the exact step an agent was on, and read it as it wrote it.
- Diff it
- Compare a right answer with a wrong one, line by line.
- Merge it
- Combine two agents’ lessons and see where they disagree.
Two choices in the table deserve a closer look (Fig. 3). First, every problem gets its own short-lived repository, and its master branch holds that session’s reasoning tree. Sessions stay separate, so each one can be searched or shared on its own. Second, a long-lived memory branch keeps the short, answer-free lessons an agent wants to remember, so experience can travel from one session to the next and be fetched or merged like code.
Branch, think, score, commit
Let us follow one question through the system. Click a step, or press play, to watch it unfold. The tree in Fig. 1 shows the same process in miniature.
- 01BranchA depth-1 tree with four children. For multiple-choice questions the children are the answer options A to D.In git
one branch per option - 02ThinkEach child runs a ReAct loop of up to three steps, with a calculator, sympy and a linear-programming solver.In git
trace.jsonl - 03Score and validateEach node gets a combined score. The best child is validated and tagged success or failed, and one re-expansion is allowed.In git
git notes + tag - 04CommitA hook writes four files per node (thought, scores, trace, metadata) and commits them with a structured message, so nothing is lost when the run ends.In git
git commit
A few details, in case you would like to reproduce this. For multiple-choice questions, we grow a tree one level deep with four children, one per answer option. In our experiments, this option-aware branching was the largest single lever on accuracy. Each child then runs a ReAct[4] loop, which alternates between thinking and calling a tool, for up to three steps. The tools are a calculator, sympy and a linear-programming solver. Web search is off in benchmark mode.
Every node then gets a combined score: 0.6 × local + 0.4 × cross. Later, when an agent looks back at past nodes, it ranks them by score, outcome tag and recency, weighted 0.7, 0.2 and 0.1. If the best child fails validation, we allow one more round of expansion, and we pass along a typed description of the failure.
Five jobs a reasoning trail might make easier
Once reasoning lives in git, a few useful jobs come down to one-line commands. Pick a job in Fig. 5 and watch its command run. We wrote the sessions to show the idea, while the numbers beside them are measurements from our paper.
Rewind to any reasoning step instead of guessing what the agent was thinking, and hand the whole trail to someone else as a single file.
What these five have in common is that none of them needed a new tool. Each is a command that engineers already know, pointed at a repository that happens to contain reasoning instead of code.
Memory helped when the past trace was nearly a copy
Interestingly, in our experiments memory only helped when a previous trace was highly similar to the problem in front of us. We call this the copyability threshold, and it sits at a cosine similarity of around 0.8 or above.1 Move the slider in Fig. 6 to pick a similarity, and it shows the nearest tier we measured, on 200 hard MATH problems.
The pattern was clear. Memory helped when the stored problem was identical or a close paraphrase. Below a cosine of roughly 0.8, where the stored item shared a method but was not a near-copy, we saw no clear effect in our runs, including at 32B.
A word of care. We tested this with small models, Qwen2.5-7B and 32B, so we see it as what we observed in this case, not a general finding. Git and memory may work well with other architectures, frameworks and agents, and especially with much more powerful frontier and open models. As those models keep improving, this could generalise better.
What git adds over databases, JSONL and markdown
Agent memory is usually kept in markdown files, logs or a database, and we have tried several of these in our research. Git gives us four things on top.
- Commits
- Each step is saved with a message, so memory has a history you can read.
- Diff
- See exactly what changed between two memories, or between a right and a wrong line of reasoning.
- Three-way merge
- Combine two agents’ memories from their common starting point, so only real disagreements need your attention.
- Conflicts and resolution
- When two lessons disagree, git stops and asks for a decision, instead of quietly keeping both.
In our functional test, this showed up clearly. We injected five contradictory lessons. Git surfaced all five as merge conflicts, while plain concatenation kept all five silently, with no warning.
There is a human advantage too. Engineers have used git for a long time, so they can use the commands they already know, like git fetch, checkout, commit and tag. They can fix traces and memory the same way they fix code.
Traces worth keeping
We have tested git for memory. But tracking every important reasoning step, and the traces around it, captures high-signal data, and we think that could be useful well beyond memory.
This may matter more as AI systems move toward recursive self-improvement. Git-tracked traces could be used to fine-tune models, to build better agent scaffolding, for tracing and debugging, and for other downstream tasks. We have not tested these yet, and we find them a promising direction.
Read more, and tell us what you think
The paper[5] has the full method, the benchmarks and the audit we drew on here. All numbers in this post are from the paper. The terminal sessions, scores and commit hashes in the figures are illustrations.
Shekar, P. C., Abhishek H S, and Krishnan, A. GitOfThoughts: Version-Controlled Reasoning and Agent Memory You Can Replay, Diff, and Merge. arXiv:2606.14470.
Earlier work: Abhishek HS, Shekar, P. C., Jain, A., and Krishnan, A. ReTreVal: Reasoning Tree with Validation and Cross-Problem Memory for Large Language Models. arXiv:2601.02880.Thank you for reading. GitOfThoughts is research from QpiAI, and we would be grateful for your thoughts, questions and ideas.
Notes
References
- Abhishek HS, Shekar, P. C., Jain, A., and Krishnan, A. ReTreVal: Reasoning Tree with Validation and Cross-Problem Memory for Large Language Models. arXiv:2601.02880. arxiv.org/abs/2601.02880
- Yao, S., et al. (2023). Tree of Thoughts: Deliberate Problem Solving with Large Language Models. NeurIPS 2023. arxiv.org/abs/2305.10601
- Zhou, A., et al. (2024). Language Agent Tree Search Unifies Reasoning, Acting, and Planning in Language Models. ICML 2024. arxiv.org/abs/2310.04406
- Yao, S., et al. (2023). ReAct: Synergizing Reasoning and Acting in Language Models. ICLR 2023. arxiv.org/abs/2210.03629
- Shekar, P. C., Abhishek H S, and Krishnan, A. GitOfThoughts: Version-Controlled Reasoning and Agent Memory You Can Replay, Diff, and Merge. arXiv:2606.14470. arxiv.org/abs/2606.14470