Skip to content
Memory · stored traces by similarity to the new problemCopyable · memory helpedthreshold ≈ 0.8Unrelatedcosine 0.12Same subjectcosine 0.22Method bandcosine 0.72Paraphrasecosine 0.95Identicalcosine 1.000.00.20.40.60.81.0cosine similarity
All posts

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.

Research9 min readPavan C Shekar

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.

One question, one repoIllustrative
question 1741d08eeroot commit
Aa1c4e900.41failed_A
B7be10d40.82success_best
C3d92f1a0.38failed_C
De50b7c20.29failed_D
memory branchf2a8d03saves a lesson for next time
Open a commit

Click any commit to see what is inside it. Each node holds four small files, and the scores and tags decide which branch wins.

thought.mdscores.jsontrace.jsonlmetadata.json
An illustration with made-up scores and hashes.
Fig. 1. One question as one repository: four scored commits, one per answer option, the best tagged success_best, and a lesson saved to the memory branch; click a commit to see what it holds.

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
Fig. 2. Our mapping from reasoning concepts to git objects: nothing here is new to git, and the only new part is deciding that a thought deserves a commit.

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.

Session repository · one per problemquestionroot commitoption Afailed_Aoption Bsuccess_bestoption Cfailed_Coption Dfailed_Dmaster branch · this session’s treeMemory branch · long-liveddistillessonCheck units beforechoosing an option.earlier lessonsno answers insidegit fetch + git mergeanother agent’s memorySession repository · one per problemquestionroot commitoption Afailed_Aoption Bsuccess_bestoption Cfailed_Coption Dfailed_Dmaster · this session’s treedistilMemory branch · long-livedlessonCheck units beforechoosing an option.earlier lessonsno answers insidefetch + mergeanother agent’s memory
Fig. 3. Each problem gets its own repository whose master branch holds that session’s reasoning tree, while a long-lived memory branch keeps distilled, answer-free lessons that another repository can fetch and merge 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.

  1. 01BranchA depth-1 tree with four children. For multiple-choice questions the children are the answer options A to D.In gitone branch per option
  2. 02ThinkEach child runs a ReAct loop of up to three steps, with a calculator, sympy and a linear-programming solver.In gittrace.jsonl
  3. 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 gitgit notes + tag
  4. 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 gitgit commit
Step 04 / 04Commit: recorded as git commit
Fig. 4. The four steps for a multiple-choice question, each with the git object that records it, from one branch per answer option to a commit of four small files per node.

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.

ReproducibilityLeakage auditIncident reviewShared memoryRepeat questions
Re-open the exact state the agent was in
git checkout · git bundle

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.

A typical session · illustration
YouWhy did the agent choose option B on question 17?
Command$ git log --oneline
Outputa3f9c21 B: refine with unit check 7be10d4 B: first pass 41d08ee question 17
Command$ git checkout 7be10d4 && cat thought.md
OutputHEAD is now at 7be10d4 B: first pass Option B follows if the process is isothermal; checking against the given pressure ratio.
What you learnEvery node is a commit, so the agent's state at that step can be restored and read as written.
What we measured
Bit-identicalrandom-seed re-runs in our audit
4 filesper node: thought, scores, trace and metadata
git bundlepackages a session as one reproducible artefact
Keep in mindWe re-ran with fixed random seeds and matched bit for bit. Our wall-clock budgets were measured with a single seed.
Fig. 5. Five jobs, each with the git command behind it; the sessions are illustrations, and the facts under them are measurements from our experiments.

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.

0.72cosine similarity between the stored trace and the new problem
threshold ≈ 0.8
No reliable effectNearest tier we measured: Method band
7B model32B model
Identicalcosine 1.00
+12.0*+28.5*
Paraphrasecosine 0.95
+13.5*+22.5*
Method bandcosine 0.72
-4.1-3.6
Same subjectcosine 0.22
-2.5+0.5
Unrelatedcosine 0.12
-2.5+1.0
Fig. 6. Change in MATH accuracy, in percentage points, by how similar the stored trace was to the new problem: memory helped for identical problems and close paraphrases, and starred values have confidence intervals that exclude zero.2

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.

Citation
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

  1. Cosine similarity measures how close two things are, where 1.00 means identical.↩
  2. Qwen2.5-7B-Instruct and Qwen2.5-32B-Instruct (AWQ int4).↩

References

  1. 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
  2. Yao, S., et al. (2023). Tree of Thoughts: Deliberate Problem Solving with Large Language Models. NeurIPS 2023. arxiv.org/abs/2305.10601
  3. Zhou, A., et al. (2024). Language Agent Tree Search Unifies Reasoning, Acting, and Planning in Language Models. ICML 2024. arxiv.org/abs/2310.04406
  4. Yao, S., et al. (2023). ReAct: Synergizing Reasoning and Acting in Language Models. ICLR 2023. arxiv.org/abs/2210.03629
  5. 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
Next postRetrying isn’t the same as learning why you failed