My coding agent's memory hit 22 GB in git. The bug? One line per message. A developer building Roam, a tool that syncs coding-agent sessions across machines via a private git repo, traced a 22 GB repository and failed GitHub pushes to per-message headings that rewrote on every capture, making every line of a 9 MB diary file appear changed and forcing git to store 1,425 full copies. The fix removed the message-count suffix from headings and split each session into append-only chunk files, cutting stored growth from over 10x to under 2x in a 15-capture test, and a related JavaScript substring-retention bug in search was fixed by copying strings, dropping index build memory from over 4 GB to 1.2 GB in 78 seconds. So I build this tool called Roam. It saves my coding agent sessions OpenCode, Claude Code, Codex, whatever I'm using that day into a private git repo, so when I switch from my PC to my laptop I can just pick up where I left off. That's the whole idea. Two weeks ago my sync just stopped. I went and checked the repo behind it. 22 GB. GitHub was timing out on every single push. And see, I don't have 22 GB of conversations. Nobody does. So where did it come from? That's what this post is about, and how I fixed it. Every project had one diary file, LOG.md . Each agent session was a section inside it, and every message in the session had a heading like this: 3/57 user Meaning message 3 of 57. Every time Roam captured the session again when the agent goes idle, or every 10 minutes , it rewrote that whole section with the latest transcript. Now, git doesn't store "the lines that changed". It stores the whole file version every time. Usually that's fine, files are small, git compresses, nobody cares. Two things stacked on top of each other. First, the file was big. One of my long running projects had a diary of around 9 MB. Second, every capture changed every heading. When message 58 comes in, 3/57 becomes 3/58 . And 4/57 becomes 4/58 . Every heading in the session changes, every single time. So even git's compression can't save you, because the whole 9 MB file is "different" on every save. This is what I actually measured on my relay: | Size of one project's diary | ~9 MB | | Full copies of it stored in git | 1,425 | | Copies stored in one single day | 296 | | Total repo size | 22 GB | Then GitHub started rejecting pushes with timeouts HTTP 408 . And the worst part? My tool kept saying "saved", because the local commit worked. The push didn't. So sync was silently dead for two days before I even noticed. That one's on me. That "of 57" part was honestly just decoration. Nobody needed it. Remove it and a message heading never changes once it's written: 3 user Tiny change. But now old lines are byte for byte the same between captures, which is exactly what git wants. Instead of rewriting one big file, every session gets its own folder now: sessions/