Skip to main content

🧠 AgentGit: The "Save Button" for AI Agents

Give your LLM the power to Undo.

AgentGit is a version control library designed for AI Agents (not just humans). It allows Agents to snapshot their own memory, recover from hallucinations, and manage their own state safely.

"Seamlessly integrates with OpenAI, Anthropic, LangChain, and OpenClaw."

🚀 Why?

Most Agents are fragile. If they write bad data to memory.md or state.json, it's permanent. AgentGit solves this by giving the Agent a Tool to save its work.

  • Auto-Save: Agent learns something new? -> commit()
  • Auto-Fix: Agent detects a mistake? -> checkout()

📦 Installation

pip install agent-git

🤖 Usage: The "AI-Native" Way

Don't run manual commands. Give the tools to your bot.

1. Integration with OpenAI / Anthropic

AgentGit comes with pre-built tool definitions. Just import and pass them to your model.

import openai
from agent_git import AgentGit, get_llm_tools

# 1. Initialize Memory
memory = AgentGit(root_dir="./agent_workspace")
memory.init()

# 2. Get the Tools (JSON Schema is built-in!)
tools = get_llm_tools() 

# 3. Give them to the Agent
response = openai.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Update my user profile to say I love Python."}],
    tools=tools  # <--- Agent can now call 'agent_git_commit' itself!
)

2. Integration with OpenClaw / Claude Code

AgentGit includes a Skill Definition that teaches autonomous agents how to use it.

from agent_git import get_skill_text

print(get_skill_text())
# Output:
# # Skill: AgentGit (Memory Version Control)
# Use this skill to save/restore memory states...
# - agent_git_commit(message, files)
# ...

⚡ What the Agent Does

Once equipped, your Agent handles the rest:

  1. The Agent Writes Memory:

    Agent: "I will update user_preferences.json."

  2. The Agent Commits (Automatically):

    Agent: "Calling agent_git_commit(message='Updated user preference', files=['user_preferences.json'])."

  3. The Agent Fixes Hallucinations:

    User: "Wait, I didn't say that!" Agent: "My apologies. Calling agent_git_checkout(commit_hash='PREVIOUS_HASH') to restore the correct state."

🛠 Manual CLI (For Humans)

You can still inspect what your Agent is doing:

# See the Agent's save history
agent-git log

# [93a8571] 🤖: Learned about Blender
# [a1b2c3d] 🤖: Updated project roadmap

🔮 Roadmap

  • LangChain Middleware: Auto-commit on every AgentFinish event.
  • AutoGPT Plugin: Drop-in persistence layer.
  • Remote Sync: Push agent memory to private GitHub repos.

Built by Moustapha Moussa for the Open Source AI Community.

Release files for agent-git 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for agent-git 0.2.0
File Interpreter ABI Platform
agent_git-0.2.0-py3-none-any.whl Python 3 none any Details

Release files / agent_git-0.2.0-py3-none-any.whl

Download URL agent_git-0.2.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa4e17269b4e89e9b4e4226df42be8bc658d8cffd0a0c68b6482725cca6199ea
BLAKE2b-256 checksum
How to use checksums
5a496ec774821d92040392870bc0d3cadf1c5852834d2a2daa77e7415c2d7df6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page