A progressive AI Agent building tutorial covering 18 steps to implement a lightweight OpenClaw (pickle-bot) from scratch, featuring tool calling, multi-agent collaboration, and production-grade capabilities.
Positioning#
This project is a progressive AI Agent building tutorial designed for developers, guiding users from a basic chat loop to a lightweight OpenClaw (reference implementation name: pickle-bot) through 18 independently runnable steps. It addresses the core problem that existing AI Agent frameworks are overly encapsulated, making it difficult for developers to understand underlying design patterns and architecture evolution logic.
Four Major Phases#
Phase 1: Foundational Agent Capabilities (Steps 0–6)#
- 00-chat-loop — Basic chat loop
- 01-tools — Integrate Read/Write/Bash tools
- 02-skills — Declarative skill extension via
SKILL.md - 03-persistence — Conversation state persistence
- 04-slash-commands — Slash command-based session control
- 05-compaction — History message compaction and summarization to maintain context window
- 06-web-tools — Internet access capability
Phase 2: Event-Driven Architecture (Steps 7–10)#
- 07-event-driven — Event-driven architecture refactoring, decoupling from CLI
- 08-config-hot-reload — Configuration file hot-reload without restart
- 09-channels — Multi-channel support (e.g., mobile and external platforms)
- 10-websocket — WebSocket interface for programmatic interaction
Phase 3: Autonomous & Multi-Agent (Steps 11–15)#
- 11-multi-agent-routing — Intelligent multi-agent routing and dispatch
- 12-cron-heartbeat — Cron jobs and heartbeat mechanism for autonomous task execution
- 13-multi-layer-prompts — Multi-layer prompt context injection
- 14-post-message-back — Agent-initiated proactive messaging to users
- 15-agent-dispatch — Agent collaboration and scheduling in complex scenarios
Phase 4: Production-Grade Features (Steps 16–17)#
- 16-concurrency-control — System concurrency control mechanism
- 17-memory — Long-term memory system implementation
Architecture & Implementation Highlights#
- Architecture Evolution Path: From single-thread CLI chat loop → event-driven architecture → multi-agent system → production-grade deployment, using a stepwise refactoring design.
- Unified LLM Access Layer: Leverages LiteLLM for unified multi-provider API calls, supporting OpenAI, Anthropic, Google Gemini, MiniMax, Qwen, Grok, Z.ai, and more.
- Skill Declaration Mechanism: Moves away from hardcoding, using
SKILL.mdfiles to dynamically inject skills into agents in a declarative manner. - Web Service Layer: Uses FastAPI to expose WebSocket endpoints; the repository includes a TypeScript-based
web/frontend directory (4.9% of codebase). - Instructional Simplification: Compared to the full pickle-bot, the tutorial version intentionally omits template variable substitution (
{{variable}}) and full REST API endpoints to focus on core Agent logic teaching.
Getting Started#
git clone https://github.com/czl9707/build-your-own-openclaw.git
cd build-your-own-openclaw
cp default_workspace/config.example.yaml default_workspace/config.user.yaml
# Edit config.user.yaml and fill in your LLM API key
Navigate step directories sequentially (00 to 17), each containing runnable code and a README.md detailing key components and design decisions. The configuration system uses YAML format with core fields including provider, model, api_key, api_base, temperature, etc.
Unconfirmed Information#
- "OpenClaw" Reference: The tutorial title mentions "OpenClaw" but the repository does not clarify whether it refers to an independent open-source project or commercial product. Based on the pickle-bot reference implementation, it may be an AI Agent product/framework concept designed by the author.
- Dependency Version Requirements: The README does not specify minimum Python version or third-party library version requirements.
- Release Status: No GitHub Releases have been published; development continues on the main branch.