Using Git as an Agent State Layer
Square_Light1441 · reddit · 2026-07-19
The author stopped maintaining separate databases for AI agents, opting to use Git directly to handle state, history, and rollbacks.
Core Design
- Every session / subagent / turn is a Git structure: sessions and subagents map to branches, turns map to commits
- Traceable and forkable: rewinding to any commit allows continuing on a new branch without losing original history
- Concurrency-friendly: uses git plumbing to write objects and commits directly, avoiding working tree/lock contention
- Workspace separation: actual project files live in another repo, using git worktree to provide independent checkouts for different subagents
Why This Approach
- Auditing and debugging are inherently traceable; every decision can be diffed, signed, and reviewed
- Vector indexes are simply derived from the Git log; if broken, they can be rebuilt, as they aren't the source of truth
- History isn't "flattened" by summaries; deduplication and compression happen only when reading context
- Models are routed via LiteLLM and tools attached via MCP, avoiding lock-in to a single model or closed format
The author hopes this framework will be stress-tested by real projects, targeting single-agent, multi-agent pipelines, coding assistants, and long-term autonomous workflows.
Related event: Using Git as a State Layer for AI Agents(2 posts)→
More from coding & agent
- HeyGen adds a media-sourcing skill for coding agents with 75k images and 10k tracks — HeyGen · 2026-07-22
- Agent search bottlenecks are now about variance, not raw latency — rohanpaul_ai · 2026-07-22
- LangSmith adds tracing for Pipecat, LiveKit, OpenAI Realtime, and Gemini Live — LangChain · 2026-07-22
- An MCP server signs every AI agent tool call into a verifiable Merkle chain — Funky_Chicken_22 · 2026-07-22
- Annotated transcript of a Claude Code team interview is now available — trq212 · 2026-07-22
- Claude Code skill uses 10 Markdown rules to make outputs ADHD-friendly — alex_verem · 2026-07-22