Building AI Agents with ZeroLock
This guide teaches you how to build AI agents that work together without conflicts. Whether you're new to AI agents or just new to ZeroLock, start here.
What are AI Agents?
AI agents are autonomous programs that use large language models (LLMs) to make decisions and take actions. Think of them as smart workers that can:
- Research topics and summarize findings
- Review code and suggest improvements
- Process data and generate reports
- Execute multi-step workflows
The challenge? When multiple agents work on the same task or shared data, they step on each other's toes.
The Problem ZeroLock Solves
Imagine two AI agents both trying to update the same document:
Agent A reads document → "Hello"
Agent B reads document → "Hello"
Agent A writes → "Hello World"
Agent B writes → "Hello Everyone" ← Agent A's change is LOST!This is called a race condition. Without coordination, agents:
- Lose updates: One agent's work gets overwritten
- Duplicate work: Multiple agents process the same task
- Create conflicts: Agents make contradictory decisions
- Read stale data: Agents act on outdated information
ZeroLock prevents all of these problems.
Learning Path
Follow this path from your first agent to production-ready systems:
Step 1: Core Concepts (Start Here)
Learn the three fundamental patterns every ZeroLock agent uses:
| Example | What You'll Learn | Time |
|---|---|---|
| Hello ZeroLock | Prevent lost updates with version checking | 5 min |
| Task Queue | Ensure each task is processed exactly once | 10 min |
| Shared Notepad | Append data without conflicts | 5 min |
Start with Quickstart Examples →
Step 2: Add Your AI Framework
Integrate ZeroLock with your preferred AI framework:
| Framework | What You'll Build |
|---|---|
| LangGraph | Research team with coordinated findings |
| CrewAI | Crew with ZeroLock-powered tools |
| AutoGen | Group chat with turn coordination |
| LlamaIndex | Distributed RAG with parallel indexing |
Step 3: Real-World Applications
Build production-style multi-agent systems:
| Application | Agents Working Together |
|---|---|
| PR Review Platform | 3 reviewers analyzing code in parallel |
| Codebase Migrator | Agents updating files concurrently |
| Deep Research Desk | Researchers gathering and synthesizing data |
| Support Desk (Gemini) | Three LLM agents claim tickets, share a refund budget and need approval to reply (full walkthrough) |
Step 4: Advanced Patterns
Master sophisticated coordination techniques:
| Pattern | When You Need It |
|---|---|
| Task Claiming | Processing queues with many workers |
| File Locking | Exclusive access to resources |
| Approval Gates | Human-in-the-loop for critical actions |
Before You Start
Prerequisites
- Python 3.11+ installed
- ZeroLock gateway running:
# Clone the repository
git clone https://github.com/shalwin04/zlock.git
cd zlock
# Install dependencies
pnpm install
# Start the gateway
cd packages/gateway && pnpm devYou should see:
ZeroLock Gateway running at http://localhost:8080Running Any Example
Every example follows the same pattern:
# 1. Make sure gateway is running (see above)
# 2. Navigate to the example
cd examples/quickstart/01-hello-zerolock
# 3. Run it
python main.pyHow Examples Are Structured
Each example shows:
- The Problem: What goes wrong WITHOUT coordination
- The Solution: How ZeroLock fixes it
- The Code: Working implementation you can copy
- The Output: What you should see when it runs
This side-by-side comparison helps you understand exactly what ZeroLock is doing and why.
Key Concepts Reference
| Term | Simple Explanation |
|---|---|
| Agent | A program that uses an LLM to make decisions |
| Shard | A piece of shared data (like a variable all agents can access) |
| Version | A number that increments each time data changes |
| OCC | "Try to save, retry if someone else saved first" |
| CRDT | "Add data without conflicts" |
| Task Claiming | "Only one agent can own this task" |
Next Step
Ready to build your first coordinated agent?
