OpenClaw Reference Architecture
A reference implementation of the OpenClaw autonomous agent architecture on ChatBotKit - demonstrating how an AI agent can bootstrap its own identity, memory, and capabilities from three persistent files at the start of every session.
One of the most compelling uses of ChatBotKit is as a meta-tool for experimenting with emerging agentic architectures. Rather than locking you into a single agent design, the platform lets you compose resources - bots, skillsets, abilities, and files - into any architectural pattern you want to explore. This blueprint does exactly that: it models the core OpenClaw architecture, a design pattern for building autonomous, stateful AI agents with persistent identity and memory.
What Is OpenClaw?
OpenClaw is an agentic architecture that defines three foundational primitives every autonomous agent should carry:
- Soul - an immutable identity file that defines the agent's values, personality, and core directives. It shapes every response the agent gives and is never overwritten.
- Memory - a mutable working-memory file where the agent persists accumulated facts, decisions, and conversational context across sessions. Without memory, every conversation starts from zero. With it, the agent builds continuity over time.
- Tools - a capability registry file where the agent records custom instructions, macros, and extended skills it has learned or created. As the agent encounters new situations, it appends to this file, effectively growing its own toolbox.
ChatBotKit as an Agentic Architecture Lab
This blueprint illustrates how ChatBotKit can serve as a research and prototyping environment for studying and modeling AI agent behaviours. Because the platform exposes files, abilities, skillsets, and bots as first-class composable resources, you can instantiate well-known agentic patterns - AutoGPT-style loops, ReAct cycles, OpenClaw-style persistence - and observe how different models respond to the same architectural constraints.
The OpenClaw pattern is particularly interesting because it surfaces emergent agent behaviours: agents that load their own Soul develop a more consistent persona across sessions; agents that maintain Memory start prioritising tasks based on historical context; agents that build their Tools registry begin to self-extend their capabilities without human instruction. ChatBotKit makes it straightforward to swap in different models - Claude, GPT-4, Gemini - and directly compare how each one interprets and operates within the same architectural scaffold.
Bootstrap Sequence
The agent follows a strict four-step initialisation sequence on every session start, before responding to the user:
- List files - calls
[SYSTEM] List Agent Filesto discover the IDs of all file resources in the blueprint. This step is always first because file IDs must be looked up dynamically, not hardcoded. - Load Soul - calls
[SYSTEM] Load Agent File by IDwith the Soul file ID to restore its identity and core directives. - Load Memory - calls
[SYSTEM] Read Agent Memoryto restore working memory from the previous session - past context, learned facts, and ongoing tasks. - Load Tools - calls
[SYSTEM] Load Agent File by IDwith the Tools file ID to discover any custom instructions or macros it has accumulated.
Only after completing all four steps does the agent engage with the user. This sequencing ensures the agent is fully contextualised before it speaks.
Persistence Model
The three-file model creates a clean separation of concerns:
- Soul is read-only. Identity should not drift. The agent reads it but may never write to it.
- Memory is read-write via dedicated system abilities. At the end of every meaningful conversation, the agent writes the complete updated memory back. This full-replace approach avoids partial-write corruption.
- Tools is append-only by convention. When the agent discovers a new macro or skill, it appends to the registry. Existing entries are not modified.
Why This Matters
Most deployed AI agents are stateless - each conversation is independent and the agent has no memory of what happened before. The OpenClaw architecture challenges that assumption. By giving the agent files it owns and controls, you get an agent that accumulates knowledge, maintains consistent identity, and extends its own capabilities over time. ChatBotKit provides the infrastructure - file storage, ability templates, permission controls - so you can focus entirely on observing and tuning the agent behaviour itself.
Backstory
Common information about the bot's experience, skills and personality. For more information, see the Backstory documentation.
Skillset
This example uses a dedicated Skillset. Skillsets are collections of abilities that can be used to create a bot with a specific set of functions and features it can perform.
[SYSTEM] List Agent Files
SYSTEM ABILITY — CALL THIS FIRST ON EVERY SESSION START. Lists all file resources in the current blueprint and returns their IDs and names. Use the returned IDs to load Soul and Tools via [SYSTEM] Load Agent File by ID. Do not skip this step.[SYSTEM] Load Agent File by ID
SYSTEM ABILITY — READ-ONLY. Loads the full content of any file by its ID. Use this to read the Soul and Tools files after discovering their IDs via [SYSTEM] List Agent Files. Strictly read-only — cannot modify file content.[SYSTEM] Read Agent Memory
SYSTEM ABILITY — Reads the current content of the agent's Memory file. Call this during the bootstrap sequence to restore working memory from the previous session. The Memory file is the sole source of persistent context between conversations.[SYSTEM] Write Agent Memory
SYSTEM ABILITY — Writes updated content to the agent's Memory file. Call this at the end of every meaningful conversation to persist new facts, decisions, and context for future sessions. Always write the complete updated memory — partial writes will overwrite existing content.
Terraform Code
This blueprint can be deployed using Terraform, enabling infrastructure-as-code management of your ChatBotKit resources. Use the code below to recreate this example in your own environment.
A dedicated team of experts is available to help you create your perfect chatbot. Reach out via or chat for more information.