Agents Need Clones
Here at DoltHub, we're fond of saying:
Agents need Branches. Dolt is the only SQL database with branches. Dolt is the database for Agents.
We think this is true and the good folks at Cursor agree with us.
But as we use coding agents more, we need to refine this statement. Agents don't just need branches. Branches help agents a lot. Agents also need clones. Dolt is the only SQL database with clones. This article will explain.
Branches vs Clones
I wrote a whole article way back in 2022 about the difference betweens clones and branches. I'll summarize it here but if you need more, please read the original article.
Branches
A branch is an isolated copy of your database that shares the same storage on disk. Branches are part of the same Dolt database. Thus, branches must share the same server.
Branch operations are initiated by commands like dolt branch
, dolt checkout
, and dolt merge
or their SQL equivalent procedures. You create a branch with dolt branch <branch name>
or dolt checkout -b <branch name>
. You switch branches using dolt checkout <branch name>
. You merge branches using dolt merge <branch name>
.
Branch operations all happen locally within the same database. Unlike Git, you can serve multiple branches at the same time from the same Dolt SQL server. This means that often Dolt users ignore clones altogether and just run a single Dolt server and use branches for write isolation. This mode of operation is like "MySQL with branches".
Clones
A clone is a completely separate copy of your database that shares the same commit history as another copy. A clone usually resides on a completely separate server from other copies. Clones can coordinate and communicate. To communicate with other clones, a intermediary is required. This intermediary is called a remote. The DoltHub website hosts remotes. Clones can be completely isolated from each other. This allows you to have thousands of independent clones across thousands of servers.
Clone operations are initiated with commands like dolt clone
, dolt remote
, dolt fetch
, dolt push
, and dolt pull
or their SQL equivalent procedures. To create a clone from a remote, you run dolt clone <remote url>
. If you already have a Dolt database and want to make it available on a remote, you first dolt remote add <remote name> <remote url>
and then dolt push <remote name> <branch name>
. If you want to sync your clone with a remote copy, you run dolt pull <remote name> <branch name>
. If you want your clone changes available on the remote, you run dolt push <remote name> <branch name>
.
The most familiar Git workflow is a clone-based workflow. You clone a Git repository from GitHub to your laptop, make changes, and then push your changes up to GitHub. GitHub provides a change review user interface called a Pull Request that facilitates merging changes from multiple clones together. Dolt and DoltHub support the same workflow.
Never Trust an Agent
As we're all learning rather quickly, agents do bad things.
If you use a coding agent you've probably seen benign cases of agents betraying your trust. For instance, a colleague here at DoltHub watched in horror as Claude Code deleted his .git
directory. This was destructive and he basically had to delete the Git clone and start over. On the less-destructive side, most of us have seen agents get lost and write nonsense code. This is acceptable because the agent is working on a Git clone and branch. Worst case, you just delete the branch.
We're starting to see larger scale rogue agent stories. Rogue agents are the new "oops, I thought I ran that delete in the test environment." This rogue agent story went viral a few weeks back, prompting the CEO of Replit to issue a public mea culpa.
This type of story will scare people away from deploying agents to their fullest possible potential unless there is a solution to the rogue agent problem. CEOs really hate having to publicly apologize for an engineering failure.
You really want to keep agents in an isolated, controlled environment where their mistakes are not that costly. Never trust an agent.
Agents Need Clones
There will be more stories of rogue agents as agents are deployed more widely doing more operations on production environments. We need a way to prevent agents from doing bad things but still give them enough freedom to be productive. You've hear of trust but verify? We need trust but isolate.
Agentic Coding Workflow
As we've observed first hand with coding agents, both Git branches and clones provide write isolation. Branches require using the same Git repository on the same server. Clones can be even more isolated, allowing writes to be done on multiple isolated containers or servers. The Git model is one of the reason coding agents work. Agents can write code in the comfy isolation of a clone and branch, separate from the copy you're working on yourself.
We think coding agents work because of the combination of a capable AI model, version control, and automated verification.
Our coding agent workflow here at DoltHub is to make a separate clone of the Git repository we want the agent to work on. Some engineers even put this clone in an isolated Docker container on their machine so the agent can't get at the main filesystem. A branch is then created on that clone for the agent to work on. The agent is then started in the root directory of the clone and works on the branch. If the agent does good work, the branch is pushed to GitHub and a Pull Request is created. If the agent can't accomplish the task, the branch is deleted and the clone is recycled for the next task. This approach let's the coding agent operate safely in isolation. This approach scales to many clones and branches on the same machine.
A Database with Clones
What if there was a technology that allowed for clones and branches on structured data rather than files? Could this technology provide the appropriate write isolation for agents to operate on more systems beyond code? Almost every software system is backed by a database of some sort. Could a version controlled database be the answer for agent write isolation? I think the answer is a resounding yes.
The good news is, we've been building this technology at DoltHub for the passed seven years. Dolt is the only SQL database that supports branches and clones. You can even get a Pull Request workflow out of the box with DoltHub or DoltLab, or you can build your own with Dolt's version control primitive. Dolt allows other agent types to have the same write-isolated workflow as coding agents.
Complete Write Isolation
As we've seen with agentic coding workflows, clones, especially on their own container or server, provide complete write isolation for an agent. The gold standard for security is an air-gapped network. With Dolt, you can even have your agents work on a clone in air-gapped network and manually transfer the changes when deemed safe upon automated or human review.
Can't I just achieve the same write isolation with a raw copy? The advantage of a clone over over a raw copy is that changes the agent makes can be diffed against the main copy for review. If the changes are good, the changes can be pushed and merged into the main copy, much like code being pushed and merged on GitHub. As mentioned before, you can use a Pull Request user interface DoltHub provides or build your own using Dolt primitives.
More Agents in Parallel
Another advantage of clones is parallelism. If agents are operating on the same copy, even on branches, the number of agents that can operate in parallel is limited to the resources available on a single host. Clones allow you to horizontally scale the resources available to agents while still retaining diff and merge functionality. This is akin to the way Git and GitHub allow thousands of developers to contribute to the same Git repository by having them all develop on their own laptops.
Conclusion
Never trust an agent. Agents need to operate in isolated environments to save them from themselves. But the changes agents make still must be reviewed and merged into the main copy. Clones are perfect for this. Git clones work well for code in files. Dolt clones enable isolated agentic writes for many more use cases. Dolt is the database for agents. Curious to learn more? Stop by our Discord and just ask.