Demystifying OpenClaw: How Agents, RAG, Memory, and Skills Power AI Automation

OpenClaw is an open‑source AI agent platform that integrates core concepts such as Agents, Retrieval‑Augmented Generation, Memory, Function Calling, and the proprietary Skills protocol, offering a four‑layer architecture, configurable workspaces, SQLite‑backed persistence, and practical deployment guidance while highlighting security best practices.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
Demystifying OpenClaw: How Agents, RAG, Memory, and Skills Power AI Automation

Overview

OpenClaw (originally Clawdbot/Moltbot) is an open‑source AI agent framework released in November 2025. It provides a runtime and gateway that runs continuously between messaging platforms and toolchains, enabling autonomous agents to perceive, reason, and act.

Layer 1 – Core Brain: Agent

An Agent follows the classic Observe‑Plan‑Act loop:

Observe : parse user intent and current state.

Plan : decompose the task and select required tools.

Act : invoke the chosen tool(s) and collect results.

Loop : repeat until the task is complete.

Each Agent runs in its own workspace containing configuration files that make the Agent transparent and auditable:

AGENTS.md   # Agent responsibilities and tool permissions
SOUL.md     # System prompt and persona
TOOLS.md    # Whitelist/blacklist of tools
IDENTITY.md # Identity shown on different channels
USER.md     # User preferences and priors
MEMORY.md   # Memory documents (RAG sources)

Layer 2 – Memory System

The Memory subsystem supplies persistent recall and is built on SQLite.

Short‑term memory : stores raw text of recent conversation turns.

Long‑term memory : a background mini‑model compresses history into summaries and extracts entity features (e.g., “user is a programmer in Shanghai”), storing them in a SQLite table.

Memory queries use a hybrid “vector + keyword” strategy. The core retrieval logic first tries the native sqlite‑vec extension; if unavailable it falls back to a JavaScript cosine‑similarity implementation.

async function searchMemory(queryVector, limit = 5) {
  try {
    // Fast path: native vector search
    return await db.all(`
      SELECT c.text, vec_distance_cosine(v.embedding, ?) AS dist
      FROM chunks_vec v
      JOIN chunks c ON c.id = v.id
      ORDER BY dist ASC LIMIT ?
    `, [queryVector, limit]);
  } catch (err) {
    // Safe fallback: compute in JS
    const allChunks = await db.all("SELECT text, embedding FROM chunks");
    return allChunks
      .map(chunk => ({ ...chunk, dist: cosineSimilarity(queryVector, JSON.parse(chunk.embedding)) }))
      .sort((a, b) => a.dist - b.dist)
      .slice(0, limit);
  }
}

Layer 3 – Knowledge Layer (RAG)

Retrieval‑Augmented Generation (RAG) mitigates the “knowledge freeze” of large models by fetching up‑to‑date information before generation. The workflow is:

User asks a question.

The system searches a local knowledge base (vectorised Markdown files stored in SQLite) for relevant chunks.

The retrieved chunks are appended to the original query.

The model generates an answer based on both the query and the retrieved context.

Layer 4 – Tool Layer

Function Call

Function Calling lets the model output a structured request (function name + parameters) that the developer executes. Example output:

{
  "function": "get_weather",
  "parameters": { "city": "北京" }
}

The developer then calls the real API and feeds the result back to the model.

Model Context Protocol (MCP)

MCP is a standardised tool‑calling protocol proposed by Anthropic. OpenClaw deliberately does not implement MCP for three reasons:

Security & privacy – multi‑model collaboration could leak data.

Technical flexibility – avoiding a fixed protocol keeps rapid iteration possible.

Resource optimisation – fewer dependencies reduce latency.

Instead, OpenClaw uses its own Skills mechanism.

Layer 5 – Process Layer (Skills)

Skills encode complete workflows (e.g., "memory → web_search → browser → file") and answer the question of when and how to use tools. Built‑in Skills include: memory: persistent user preferences. web_search: fetch real‑time internet results. browser: open pages and extract content. file: create, read, or modify local files.

Installation is a single command via the ClawHub registry:

clawhub install memory   # install memory skill
clawhub install browser  # install browser control skill

The registry hosts over a thousand Skills covering office automation, code management, data processing, and more.

Overall Architecture

Gateway layer : normalises inbound/outbound messages from platforms such as Telegram, Feishu, DingTalk, etc.

Reasoning layer : connects to large models and runs the Observe‑Plan‑Act cycle.

Memory & State layer : SQLite‑backed persistent memory.

Skills & Execution layer : invokes Skills to perform concrete actions.

Typical Execution Flow

User sends “Help me organise my desktop files” via a messaging app.

Gateway forwards the message to the Agent.

Agent decides to call the file Skill.

Skill performs file operations and returns a result.

Memory records the operation for future reference.

Agent replies “Files have been organised and images moved to Pictures.”

Security Recommendations

Run the Agent with limited privileges – use a spare PC, VM, or dedicated system account.

Never expose API keys in Git repositories or screenshots.

For long‑running deployments, prefer Docker or a VPS to isolate permissions.

Treat the Agent as a potential data‑leak vector; never assume it is a simple file‑transfer bot.

Open Source Resources

GitHub repository: https://github.com/openclaw

Alibaba Cloud one‑click deployment guide: https://www.aliyun.com/activity/ecs/clawdbot

RAGopen-sourceAI AgentFunction CallingMemorySkillsOpenClaw
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.