【Harness:落地实战】16、从“只会说”到“能干活”:OpenClaw落地,手动Harness的架构与实现深度解析

从"只会说"到"能干活":OpenClaw落地,手动Harness的架构与实现深度解析

摘要 :2026年初,一只名为OpenClaw的"龙虾"席卷了全球技术社区,在GitHub上创造了开源软件历史的星标纪录。它为什么能火?本质上,OpenClaw是Harness Engineering (驾驭工程)的一次教科书级实现------它将大语言模型从单纯的"文字生成器"推进到了可以实际执行任务的系统组件。本文将从Harness的视角深度拆解OpenClaw的架构设计:它如何实现记忆层、约束层、工具层、可观测性层和编排层五大Harness组件?它的配置文件config.yaml如何成为Harness的工程载体?它为什么是"手动Harness"的典型代表?它的局限在哪里?最后,文章将提供完整的部署指南和最小权限配置方案,帮助你快速上手这只"龙虾"。


📑 目录

  1. OpenClaw定位:轻量Harness落地产品
  2. OpenClaw核心架构图与5大Harness组件对应关系
  3. OpenClaw如何实现5大Harness组件
    • 3.1 记忆层(Memory)
    • 3.2 约束层(Constraint)
    • 3.3 工具层(Tool)
    • 3.4 可观测性层(Observability)
    • 3.5 编排层(Orchestration)
  4. OpenClaw的Harness局限:手动配置、短期记忆、无自进化能力
  5. [配置文件解析:config.yaml = Harness载体](#配置文件解析:config.yaml = Harness载体)
  6. 与标准Harness对比:差异点与适配场景
  7. OpenClaw部署与最佳实践
    • 7.1 本地部署
    • 7.2 Docker部署
    • 7.3 最小权限配置实践
  8. 总结与展望

1. OpenClaw定位:轻量Harness落地产品

OpenClaw于2025年11月由PSPDFKit创始人Peter Steinberger创建,最初以Clawdbot名字对外亮相。它的核心定位是:运行在你本地设备上、真正执行任务的AI智能体框架

与传统聊天AI不同,OpenClaw能够直接操作计算机系统:整理文件、发邮件、写代码、运行程序,真正实现"AI替你干活"。同时,它支持WhatsApp、Telegram、Slack等超过12个主流平台接入,后端可灵活适配Claude、GPT-4o或本地Ollama模型,不绑定任何云服务商。
#mermaid-svg-066NFEh6tGIY3cyI{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-066NFEh6tGIY3cyI .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-066NFEh6tGIY3cyI .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-066NFEh6tGIY3cyI .error-icon{fill:#552222;}#mermaid-svg-066NFEh6tGIY3cyI .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-066NFEh6tGIY3cyI .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-066NFEh6tGIY3cyI .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-066NFEh6tGIY3cyI .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-066NFEh6tGIY3cyI .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-066NFEh6tGIY3cyI .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-066NFEh6tGIY3cyI .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-066NFEh6tGIY3cyI .marker{fill:#333333;stroke:#333333;}#mermaid-svg-066NFEh6tGIY3cyI .marker.cross{stroke:#333333;}#mermaid-svg-066NFEh6tGIY3cyI svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-066NFEh6tGIY3cyI p{margin:0;}#mermaid-svg-066NFEh6tGIY3cyI .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-066NFEh6tGIY3cyI .cluster-label text{fill:#333;}#mermaid-svg-066NFEh6tGIY3cyI .cluster-label span{color:#333;}#mermaid-svg-066NFEh6tGIY3cyI .cluster-label span p{background-color:transparent;}#mermaid-svg-066NFEh6tGIY3cyI .label text,#mermaid-svg-066NFEh6tGIY3cyI span{fill:#333;color:#333;}#mermaid-svg-066NFEh6tGIY3cyI .node rect,#mermaid-svg-066NFEh6tGIY3cyI .node circle,#mermaid-svg-066NFEh6tGIY3cyI .node ellipse,#mermaid-svg-066NFEh6tGIY3cyI .node polygon,#mermaid-svg-066NFEh6tGIY3cyI .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-066NFEh6tGIY3cyI .rough-node .label text,#mermaid-svg-066NFEh6tGIY3cyI .node .label text,#mermaid-svg-066NFEh6tGIY3cyI .image-shape .label,#mermaid-svg-066NFEh6tGIY3cyI .icon-shape .label{text-anchor:middle;}#mermaid-svg-066NFEh6tGIY3cyI .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-066NFEh6tGIY3cyI .rough-node .label,#mermaid-svg-066NFEh6tGIY3cyI .node .label,#mermaid-svg-066NFEh6tGIY3cyI .image-shape .label,#mermaid-svg-066NFEh6tGIY3cyI .icon-shape .label{text-align:center;}#mermaid-svg-066NFEh6tGIY3cyI .node.clickable{cursor:pointer;}#mermaid-svg-066NFEh6tGIY3cyI .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-066NFEh6tGIY3cyI .arrowheadPath{fill:#333333;}#mermaid-svg-066NFEh6tGIY3cyI .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-066NFEh6tGIY3cyI .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-066NFEh6tGIY3cyI .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-066NFEh6tGIY3cyI .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-066NFEh6tGIY3cyI .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-066NFEh6tGIY3cyI .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-066NFEh6tGIY3cyI .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-066NFEh6tGIY3cyI .cluster text{fill:#333;}#mermaid-svg-066NFEh6tGIY3cyI .cluster span{color:#333;}#mermaid-svg-066NFEh6tGIY3cyI div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-066NFEh6tGIY3cyI .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-066NFEh6tGIY3cyI rect.text{fill:none;stroke-width:0;}#mermaid-svg-066NFEh6tGIY3cyI .icon-shape,#mermaid-svg-066NFEh6tGIY3cyI .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-066NFEh6tGIY3cyI .icon-shape p,#mermaid-svg-066NFEh6tGIY3cyI .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-066NFEh6tGIY3cyI .icon-shape .label rect,#mermaid-svg-066NFEh6tGIY3cyI .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-066NFEh6tGIY3cyI .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-066NFEh6tGIY3cyI .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-066NFEh6tGIY3cyI :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} OpenClaw的核心能力
Harness
"从只会说"
"到能干活"

截至2026年4月,OpenClaw在GitHub上已获得超过35万星标和超过7万fork,成为2026年初最受关注的AI Agent项目之一。OpenClaw的爆红标志着AI产业的竞争重心已经从模型参数竞争全面转向Agent Harness(代理驾驭系统/执行外壳)的构建。

那么,OpenClaw和Harness究竟是什么关系? Harness是围绕模型的"操作系统",负责将模型的智力转化为实际生产力;而OpenClaw则是Harness Engineering的一次教科书级实现。如果说Prompt Engineering是"如何让模型更好地理解需求",Context Engineering是"让AI看什么",那么Harness Engineering就是"构建怎样的运行环境"。OpenClaw正是这三者层层递进的产物。


2. OpenClaw核心架构图与5大Harness组件对应关系

OpenClaw采用**"网关先行"的分层架构**。下图展示了OpenClaw的完整架构:
#mermaid-svg-AJ7WV9SPagNUoV7z{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-AJ7WV9SPagNUoV7z .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-AJ7WV9SPagNUoV7z .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-AJ7WV9SPagNUoV7z .error-icon{fill:#552222;}#mermaid-svg-AJ7WV9SPagNUoV7z .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-AJ7WV9SPagNUoV7z .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-AJ7WV9SPagNUoV7z .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-AJ7WV9SPagNUoV7z .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-AJ7WV9SPagNUoV7z .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-AJ7WV9SPagNUoV7z .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-AJ7WV9SPagNUoV7z .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-AJ7WV9SPagNUoV7z .marker{fill:#333333;stroke:#333333;}#mermaid-svg-AJ7WV9SPagNUoV7z .marker.cross{stroke:#333333;}#mermaid-svg-AJ7WV9SPagNUoV7z svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-AJ7WV9SPagNUoV7z p{margin:0;}#mermaid-svg-AJ7WV9SPagNUoV7z .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-AJ7WV9SPagNUoV7z .cluster-label text{fill:#333;}#mermaid-svg-AJ7WV9SPagNUoV7z .cluster-label span{color:#333;}#mermaid-svg-AJ7WV9SPagNUoV7z .cluster-label span p{background-color:transparent;}#mermaid-svg-AJ7WV9SPagNUoV7z .label text,#mermaid-svg-AJ7WV9SPagNUoV7z span{fill:#333;color:#333;}#mermaid-svg-AJ7WV9SPagNUoV7z .node rect,#mermaid-svg-AJ7WV9SPagNUoV7z .node circle,#mermaid-svg-AJ7WV9SPagNUoV7z .node ellipse,#mermaid-svg-AJ7WV9SPagNUoV7z .node polygon,#mermaid-svg-AJ7WV9SPagNUoV7z .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-AJ7WV9SPagNUoV7z .rough-node .label text,#mermaid-svg-AJ7WV9SPagNUoV7z .node .label text,#mermaid-svg-AJ7WV9SPagNUoV7z .image-shape .label,#mermaid-svg-AJ7WV9SPagNUoV7z .icon-shape .label{text-anchor:middle;}#mermaid-svg-AJ7WV9SPagNUoV7z .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-AJ7WV9SPagNUoV7z .rough-node .label,#mermaid-svg-AJ7WV9SPagNUoV7z .node .label,#mermaid-svg-AJ7WV9SPagNUoV7z .image-shape .label,#mermaid-svg-AJ7WV9SPagNUoV7z .icon-shape .label{text-align:center;}#mermaid-svg-AJ7WV9SPagNUoV7z .node.clickable{cursor:pointer;}#mermaid-svg-AJ7WV9SPagNUoV7z .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-AJ7WV9SPagNUoV7z .arrowheadPath{fill:#333333;}#mermaid-svg-AJ7WV9SPagNUoV7z .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-AJ7WV9SPagNUoV7z .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-AJ7WV9SPagNUoV7z .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-AJ7WV9SPagNUoV7z .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-AJ7WV9SPagNUoV7z .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-AJ7WV9SPagNUoV7z .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-AJ7WV9SPagNUoV7z .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-AJ7WV9SPagNUoV7z .cluster text{fill:#333;}#mermaid-svg-AJ7WV9SPagNUoV7z .cluster span{color:#333;}#mermaid-svg-AJ7WV9SPagNUoV7z div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-AJ7WV9SPagNUoV7z .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-AJ7WV9SPagNUoV7z rect.text{fill:none;stroke-width:0;}#mermaid-svg-AJ7WV9SPagNUoV7z .icon-shape,#mermaid-svg-AJ7WV9SPagNUoV7z .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-AJ7WV9SPagNUoV7z .icon-shape p,#mermaid-svg-AJ7WV9SPagNUoV7z .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-AJ7WV9SPagNUoV7z .icon-shape .label rect,#mermaid-svg-AJ7WV9SPagNUoV7z .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-AJ7WV9SPagNUoV7z .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-AJ7WV9SPagNUoV7z .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-AJ7WV9SPagNUoV7z :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 基础设施层
Harness核心
网关层
用户交互层
WhatsApp/Telegram/飞书/微信
Web UI / CLI / macOS App
Gateway Control Plane

消息路由·安全边界·状态管理
Channel Adapters

平台抽象·身份认证·访问控制
Agent Runtime

执行循环+工具调用+记忆管理
Skills系统

SKILL.md驱动的能力扩展
Memory System

MEMORY.md + 文件记忆
Sandbox

容器隔离+权限管控
本地文件系统
LLM API

Claude/GPT-4o/Ollama
ClawHub

技能市场

与Harness标准组件(记忆层、约束层、工具层、可观测性层、编排层五大组件)的对应关系如下:

Harness组件 OpenClaw对应实现 实现层级
记忆层(Memory) MEMORY.md + 文件索引 + memory_search工具 Agent Runtime
约束层(Constraint) Docker沙箱 + 工具白名单 + 权限校验 Sandbox + Gateway
工具层(Tool) Skills(SKILL.md) + MCP协议 Skills系统
可观测性层(Observability) 请求染色 + 执行轨迹 + 审计日志 Gateway + Agent Runtime
编排层(Orchestration) Agent Loop + 消息路由 + 子Agent调度 Gateway Control Plane

3. OpenClaw如何实现5大Harness组件

3.1 记忆层(Memory)

OpenClaw的记忆系统采用Markdown文件驱动的分层存储。具体设计如下:
#mermaid-svg-E74gVSMu17toppl2{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-E74gVSMu17toppl2 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-E74gVSMu17toppl2 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-E74gVSMu17toppl2 .error-icon{fill:#552222;}#mermaid-svg-E74gVSMu17toppl2 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-E74gVSMu17toppl2 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-E74gVSMu17toppl2 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-E74gVSMu17toppl2 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-E74gVSMu17toppl2 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-E74gVSMu17toppl2 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-E74gVSMu17toppl2 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-E74gVSMu17toppl2 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-E74gVSMu17toppl2 .marker.cross{stroke:#333333;}#mermaid-svg-E74gVSMu17toppl2 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-E74gVSMu17toppl2 p{margin:0;}#mermaid-svg-E74gVSMu17toppl2 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-E74gVSMu17toppl2 .cluster-label text{fill:#333;}#mermaid-svg-E74gVSMu17toppl2 .cluster-label span{color:#333;}#mermaid-svg-E74gVSMu17toppl2 .cluster-label span p{background-color:transparent;}#mermaid-svg-E74gVSMu17toppl2 .label text,#mermaid-svg-E74gVSMu17toppl2 span{fill:#333;color:#333;}#mermaid-svg-E74gVSMu17toppl2 .node rect,#mermaid-svg-E74gVSMu17toppl2 .node circle,#mermaid-svg-E74gVSMu17toppl2 .node ellipse,#mermaid-svg-E74gVSMu17toppl2 .node polygon,#mermaid-svg-E74gVSMu17toppl2 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-E74gVSMu17toppl2 .rough-node .label text,#mermaid-svg-E74gVSMu17toppl2 .node .label text,#mermaid-svg-E74gVSMu17toppl2 .image-shape .label,#mermaid-svg-E74gVSMu17toppl2 .icon-shape .label{text-anchor:middle;}#mermaid-svg-E74gVSMu17toppl2 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-E74gVSMu17toppl2 .rough-node .label,#mermaid-svg-E74gVSMu17toppl2 .node .label,#mermaid-svg-E74gVSMu17toppl2 .image-shape .label,#mermaid-svg-E74gVSMu17toppl2 .icon-shape .label{text-align:center;}#mermaid-svg-E74gVSMu17toppl2 .node.clickable{cursor:pointer;}#mermaid-svg-E74gVSMu17toppl2 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-E74gVSMu17toppl2 .arrowheadPath{fill:#333333;}#mermaid-svg-E74gVSMu17toppl2 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-E74gVSMu17toppl2 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-E74gVSMu17toppl2 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-E74gVSMu17toppl2 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-E74gVSMu17toppl2 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-E74gVSMu17toppl2 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-E74gVSMu17toppl2 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-E74gVSMu17toppl2 .cluster text{fill:#333;}#mermaid-svg-E74gVSMu17toppl2 .cluster span{color:#333;}#mermaid-svg-E74gVSMu17toppl2 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-E74gVSMu17toppl2 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-E74gVSMu17toppl2 rect.text{fill:none;stroke-width:0;}#mermaid-svg-E74gVSMu17toppl2 .icon-shape,#mermaid-svg-E74gVSMu17toppl2 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-E74gVSMu17toppl2 .icon-shape p,#mermaid-svg-E74gVSMu17toppl2 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-E74gVSMu17toppl2 .icon-shape .label rect,#mermaid-svg-E74gVSMu17toppl2 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-E74gVSMu17toppl2 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-E74gVSMu17toppl2 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-E74gVSMu17toppl2 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Agent上下文
检索机制
记忆存储
MEMORY.md

主记忆文件
memory/*.md

分类记忆文件
会话级缓存
关键词检索
语义检索

memory_search工具
全文检索
动态上下文组装

OpenClaw将记忆存储在Markdown文件中而非关系数据库,这是其轻量化设计 的核心体现。Agent启动时会扫描MEMORY.mdmemory/*.md目录,将内容作为记忆上下文注入LLM的System Prompt中。memory_search工具提供了语义检索能力,Agent在执行任务前可以主动搜索相关记忆。

相比标准Harness的局限:标准Harness记忆层支持向量数据库存储、混合检索(语义+关键词+全文)、记忆清洗、水位管理等高级特性。OpenClaw的记忆系统缺乏:

  • 向量化存储:无法高效进行大规模语义检索
  • 记忆压缩:短期记忆无法平滑过渡到长期记忆
  • 跨会话记忆融合:不同会话之间的记忆缺乏统一的融合机制
  • 记忆清洗:无去重、时效过滤等质量保障机制

3.2 约束层(Constraint)

OpenClaw的约束层通过多层安全机制实现:
#mermaid-svg-BfAMGZXKeMmrvLLC{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-BfAMGZXKeMmrvLLC .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-BfAMGZXKeMmrvLLC .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-BfAMGZXKeMmrvLLC .error-icon{fill:#552222;}#mermaid-svg-BfAMGZXKeMmrvLLC .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-BfAMGZXKeMmrvLLC .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-BfAMGZXKeMmrvLLC .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-BfAMGZXKeMmrvLLC .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-BfAMGZXKeMmrvLLC .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-BfAMGZXKeMmrvLLC .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-BfAMGZXKeMmrvLLC .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-BfAMGZXKeMmrvLLC .marker{fill:#333333;stroke:#333333;}#mermaid-svg-BfAMGZXKeMmrvLLC .marker.cross{stroke:#333333;}#mermaid-svg-BfAMGZXKeMmrvLLC svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-BfAMGZXKeMmrvLLC p{margin:0;}#mermaid-svg-BfAMGZXKeMmrvLLC .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-BfAMGZXKeMmrvLLC .cluster-label text{fill:#333;}#mermaid-svg-BfAMGZXKeMmrvLLC .cluster-label span{color:#333;}#mermaid-svg-BfAMGZXKeMmrvLLC .cluster-label span p{background-color:transparent;}#mermaid-svg-BfAMGZXKeMmrvLLC .label text,#mermaid-svg-BfAMGZXKeMmrvLLC span{fill:#333;color:#333;}#mermaid-svg-BfAMGZXKeMmrvLLC .node rect,#mermaid-svg-BfAMGZXKeMmrvLLC .node circle,#mermaid-svg-BfAMGZXKeMmrvLLC .node ellipse,#mermaid-svg-BfAMGZXKeMmrvLLC .node polygon,#mermaid-svg-BfAMGZXKeMmrvLLC .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-BfAMGZXKeMmrvLLC .rough-node .label text,#mermaid-svg-BfAMGZXKeMmrvLLC .node .label text,#mermaid-svg-BfAMGZXKeMmrvLLC .image-shape .label,#mermaid-svg-BfAMGZXKeMmrvLLC .icon-shape .label{text-anchor:middle;}#mermaid-svg-BfAMGZXKeMmrvLLC .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-BfAMGZXKeMmrvLLC .rough-node .label,#mermaid-svg-BfAMGZXKeMmrvLLC .node .label,#mermaid-svg-BfAMGZXKeMmrvLLC .image-shape .label,#mermaid-svg-BfAMGZXKeMmrvLLC .icon-shape .label{text-align:center;}#mermaid-svg-BfAMGZXKeMmrvLLC .node.clickable{cursor:pointer;}#mermaid-svg-BfAMGZXKeMmrvLLC .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-BfAMGZXKeMmrvLLC .arrowheadPath{fill:#333333;}#mermaid-svg-BfAMGZXKeMmrvLLC .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-BfAMGZXKeMmrvLLC .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-BfAMGZXKeMmrvLLC .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-BfAMGZXKeMmrvLLC .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-BfAMGZXKeMmrvLLC .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-BfAMGZXKeMmrvLLC .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-BfAMGZXKeMmrvLLC .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-BfAMGZXKeMmrvLLC .cluster text{fill:#333;}#mermaid-svg-BfAMGZXKeMmrvLLC .cluster span{color:#333;}#mermaid-svg-BfAMGZXKeMmrvLLC div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-BfAMGZXKeMmrvLLC .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-BfAMGZXKeMmrvLLC rect.text{fill:none;stroke-width:0;}#mermaid-svg-BfAMGZXKeMmrvLLC .icon-shape,#mermaid-svg-BfAMGZXKeMmrvLLC .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-BfAMGZXKeMmrvLLC .icon-shape p,#mermaid-svg-BfAMGZXKeMmrvLLC .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-BfAMGZXKeMmrvLLC .icon-shape .label rect,#mermaid-svg-BfAMGZXKeMmrvLLC .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-BfAMGZXKeMmrvLLC .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-BfAMGZXKeMmrvLLC .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-BfAMGZXKeMmrvLLC :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 身份验证
通过
容器隔离
通过
拒绝
拒绝
拒绝
拒绝
用户请求
Gateway访问控制
工具白名单检查
沙箱隔离
权限校验
执行
阻断+审计日志

核心安全机制包括:

  1. 容器化沙箱 :Agent工具执行被隔离在Docker容器内,通过workspaceAccess参数精细控制工作区权限(none/ro/rw)。这是OpenClaw与其他Agent框架最显著的安全差异,也是OWASP平台对比指南中认定的"最强安全模型"。

  2. 工具白名单:通过配置禁用shell等高风险工具。国家互联网应急中心推荐企业用户"启用工具白名单,禁用shell"。

  3. 网络隔离:支持白名单域名的网络策略控制。

  4. 审计日志:完整记录所有敏感操作,支持事后审计追溯。

相比标准Harness的局限:虽然OpenClaw的安全模型在同类型产品中已属优秀,但标准Harness的约束层支持更精细的四层纵深防御体系(工具开关→MCP过滤→子Agent权限裁剪→系统级沙箱)。OpenClaw缺乏:

  • 动态权限调整:权限策略需要人工修改配置文件重新加载
  • 细粒度约束规则:如"超过100美元的支出必须经用户确认"这类基于业务语义的约束
  • 可编程Guardrail:无法自定义复杂的约束判断逻辑

3.3 工具层(Tool)

OpenClaw的工具系统是其最受关注的设计创新 。工具定义走JSON Schema标准,每个工具有明确的description、parameters和required字段。核心设计理念是:工具描述即协议------这不仅是给开发者看的注释,更是给模型看的行为规范。

yaml 复制代码
# OpenClaw 工具定义示例(SKILL.md格式)
---
name: memory_search
description: 语义搜索 MEMORY.md + memory/*.md,在回答关于过往工作、决策、日期等问题前必须调用
parameters:
  - name: query
    type: string
    description: 搜索查询关键词,如"用户偏好"、"上次决策"
required:
  - query
---
# 具体实现逻辑...

Anthropic的研究表明,工具描述的质量对任务完成率的影响甚至超过了模型版本的差异:从Claude 3 Haiku换到Claude 3.5 Sonnet,任务成功率提升15%;而将工具描述从一句话扩展为带示例的完整说明,任务成功率提升22%。

OpenClaw通过ClawHub技能市场 实现了工具生态的规模化。ClawHub是OpenClaw的官方技能注册中心,角色类似于npm之于Node.js。每个技能的核心是一个SKILL.md文件,用Markdown写成,包含YAML前置元数据和自然语言指令。截至2026年3月,ClawHub收录了超过13,000个Skills,累计下载量超150万次。

3.4 可观测性层(Observability)

OpenClaw的可观测性设计围绕**"全链路可追溯"**展开:
#mermaid-svg-cEtr8nLUqDiOcQdj{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-cEtr8nLUqDiOcQdj .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-cEtr8nLUqDiOcQdj .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-cEtr8nLUqDiOcQdj .error-icon{fill:#552222;}#mermaid-svg-cEtr8nLUqDiOcQdj .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-cEtr8nLUqDiOcQdj .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-cEtr8nLUqDiOcQdj .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-cEtr8nLUqDiOcQdj .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-cEtr8nLUqDiOcQdj .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-cEtr8nLUqDiOcQdj .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-cEtr8nLUqDiOcQdj .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-cEtr8nLUqDiOcQdj .marker{fill:#333333;stroke:#333333;}#mermaid-svg-cEtr8nLUqDiOcQdj .marker.cross{stroke:#333333;}#mermaid-svg-cEtr8nLUqDiOcQdj svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-cEtr8nLUqDiOcQdj p{margin:0;}#mermaid-svg-cEtr8nLUqDiOcQdj .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-cEtr8nLUqDiOcQdj .cluster-label text{fill:#333;}#mermaid-svg-cEtr8nLUqDiOcQdj .cluster-label span{color:#333;}#mermaid-svg-cEtr8nLUqDiOcQdj .cluster-label span p{background-color:transparent;}#mermaid-svg-cEtr8nLUqDiOcQdj .label text,#mermaid-svg-cEtr8nLUqDiOcQdj span{fill:#333;color:#333;}#mermaid-svg-cEtr8nLUqDiOcQdj .node rect,#mermaid-svg-cEtr8nLUqDiOcQdj .node circle,#mermaid-svg-cEtr8nLUqDiOcQdj .node ellipse,#mermaid-svg-cEtr8nLUqDiOcQdj .node polygon,#mermaid-svg-cEtr8nLUqDiOcQdj .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-cEtr8nLUqDiOcQdj .rough-node .label text,#mermaid-svg-cEtr8nLUqDiOcQdj .node .label text,#mermaid-svg-cEtr8nLUqDiOcQdj .image-shape .label,#mermaid-svg-cEtr8nLUqDiOcQdj .icon-shape .label{text-anchor:middle;}#mermaid-svg-cEtr8nLUqDiOcQdj .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-cEtr8nLUqDiOcQdj .rough-node .label,#mermaid-svg-cEtr8nLUqDiOcQdj .node .label,#mermaid-svg-cEtr8nLUqDiOcQdj .image-shape .label,#mermaid-svg-cEtr8nLUqDiOcQdj .icon-shape .label{text-align:center;}#mermaid-svg-cEtr8nLUqDiOcQdj .node.clickable{cursor:pointer;}#mermaid-svg-cEtr8nLUqDiOcQdj .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-cEtr8nLUqDiOcQdj .arrowheadPath{fill:#333333;}#mermaid-svg-cEtr8nLUqDiOcQdj .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-cEtr8nLUqDiOcQdj .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-cEtr8nLUqDiOcQdj .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-cEtr8nLUqDiOcQdj .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-cEtr8nLUqDiOcQdj .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-cEtr8nLUqDiOcQdj .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-cEtr8nLUqDiOcQdj .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-cEtr8nLUqDiOcQdj .cluster text{fill:#333;}#mermaid-svg-cEtr8nLUqDiOcQdj .cluster span{color:#333;}#mermaid-svg-cEtr8nLUqDiOcQdj div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-cEtr8nLUqDiOcQdj .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-cEtr8nLUqDiOcQdj rect.text{fill:none;stroke-width:0;}#mermaid-svg-cEtr8nLUqDiOcQdj .icon-shape,#mermaid-svg-cEtr8nLUqDiOcQdj .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-cEtr8nLUqDiOcQdj .icon-shape p,#mermaid-svg-cEtr8nLUqDiOcQdj .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-cEtr8nLUqDiOcQdj .icon-shape .label rect,#mermaid-svg-cEtr8nLUqDiOcQdj .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-cEtr8nLUqDiOcQdj .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-cEtr8nLUqDiOcQdj .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-cEtr8nLUqDiOcQdj :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 可视化层
存储层
采集层
请求染色

Trace ID
执行轨迹记录
审计事件
ElasticSearch
本地文件
SLS/S3
Web Dashboard
审计大盘
运维观测大盘

阿里云日志服务(SLS)已支持一键接入OpenClaw的日志,提供开箱即用的安全审计与运维观测闭环。OpenClaw支持请求染色机制------为每个请求分配唯一的Trace ID,关联所有Agent执行环节的数据。

相比标准Harness的局限 :标准Harness的可观测性层不仅包含指标、日志、链路追踪三大支柱,还支持归因分析 (从百万级Token轨迹中快速定位根因)和成本可观测性(Token消耗追踪、实时预算告警)。OpenClaw在这方面相对薄弱,缺乏:

  • 细粒度的Token成本分摊
  • 自动归因分析能力
  • 实时预算告警机制

3.5 编排层(Orchestration)

编排层是OpenClaw的"心脏"------管理Agent执行循环、消息路由、任务调度和错误恢复。
#mermaid-svg-d1ByFNm5VVEeG79Z{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-d1ByFNm5VVEeG79Z .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-d1ByFNm5VVEeG79Z .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-d1ByFNm5VVEeG79Z .error-icon{fill:#552222;}#mermaid-svg-d1ByFNm5VVEeG79Z .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-d1ByFNm5VVEeG79Z .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-d1ByFNm5VVEeG79Z .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-d1ByFNm5VVEeG79Z .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-d1ByFNm5VVEeG79Z .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-d1ByFNm5VVEeG79Z .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-d1ByFNm5VVEeG79Z .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-d1ByFNm5VVEeG79Z .marker{fill:#333333;stroke:#333333;}#mermaid-svg-d1ByFNm5VVEeG79Z .marker.cross{stroke:#333333;}#mermaid-svg-d1ByFNm5VVEeG79Z svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-d1ByFNm5VVEeG79Z p{margin:0;}#mermaid-svg-d1ByFNm5VVEeG79Z defs #statediagram-barbEnd{fill:#333333;stroke:#333333;}#mermaid-svg-d1ByFNm5VVEeG79Z g.stateGroup text{fill:#9370DB;stroke:none;font-size:10px;}#mermaid-svg-d1ByFNm5VVEeG79Z g.stateGroup text{fill:#333;stroke:none;font-size:10px;}#mermaid-svg-d1ByFNm5VVEeG79Z g.stateGroup .state-title{font-weight:bolder;fill:#131300;}#mermaid-svg-d1ByFNm5VVEeG79Z g.stateGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-svg-d1ByFNm5VVEeG79Z g.stateGroup line{stroke:#333333;stroke-width:1;}#mermaid-svg-d1ByFNm5VVEeG79Z .transition{stroke:#333333;stroke-width:1;fill:none;}#mermaid-svg-d1ByFNm5VVEeG79Z .stateGroup .composit{fill:white;border-bottom:1px;}#mermaid-svg-d1ByFNm5VVEeG79Z .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px;}#mermaid-svg-d1ByFNm5VVEeG79Z .state-note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-d1ByFNm5VVEeG79Z .state-note text{fill:black;stroke:none;font-size:10px;}#mermaid-svg-d1ByFNm5VVEeG79Z .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-svg-d1ByFNm5VVEeG79Z .edgeLabel .label rect{fill:#ECECFF;opacity:0.5;}#mermaid-svg-d1ByFNm5VVEeG79Z .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-d1ByFNm5VVEeG79Z .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-d1ByFNm5VVEeG79Z .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-d1ByFNm5VVEeG79Z .edgeLabel .label text{fill:#333;}#mermaid-svg-d1ByFNm5VVEeG79Z .label div .edgeLabel{color:#333;}#mermaid-svg-d1ByFNm5VVEeG79Z .stateLabel text{fill:#131300;font-size:10px;font-weight:bold;}#mermaid-svg-d1ByFNm5VVEeG79Z .node circle.state-start{fill:#333333;stroke:#333333;}#mermaid-svg-d1ByFNm5VVEeG79Z .node .fork-join{fill:#333333;stroke:#333333;}#mermaid-svg-d1ByFNm5VVEeG79Z .node circle.state-end{fill:#9370DB;stroke:white;stroke-width:1.5;}#mermaid-svg-d1ByFNm5VVEeG79Z .end-state-inner{fill:white;stroke-width:1.5;}#mermaid-svg-d1ByFNm5VVEeG79Z .node rect{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-d1ByFNm5VVEeG79Z .node polygon{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-d1ByFNm5VVEeG79Z #statediagram-barbEnd{fill:#333333;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-cluster rect{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-d1ByFNm5VVEeG79Z .cluster-label,#mermaid-svg-d1ByFNm5VVEeG79Z .nodeLabel{color:#131300;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-cluster rect.outer{rx:5px;ry:5px;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-state .divider{stroke:#9370DB;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-state .title-state{rx:5px;ry:5px;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-cluster.statediagram-cluster .inner{fill:white;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-cluster.statediagram-cluster-alt .inner{fill:#f0f0f0;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-cluster .inner{rx:0;ry:0;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-state rect.basic{rx:5px;ry:5px;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#f0f0f0;}#mermaid-svg-d1ByFNm5VVEeG79Z .note-edge{stroke-dasharray:5;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-note rect{fill:#fff5ad;stroke:#aaaa33;stroke-width:1px;rx:0;ry:0;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-note rect{fill:#fff5ad;stroke:#aaaa33;stroke-width:1px;rx:0;ry:0;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-note text{fill:black;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram-note .nodeLabel{color:black;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagram .edgeLabel{color:red;}#mermaid-svg-d1ByFNm5VVEeG79Z #dependencyStart,#mermaid-svg-d1ByFNm5VVEeG79Z #dependencyEnd{fill:#333333;stroke:#333333;stroke-width:1;}#mermaid-svg-d1ByFNm5VVEeG79Z .statediagramTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-d1ByFNm5VVEeG79Z :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 循环
终止条件
解析会话
组装上下文
LLM推理
工具调用
结果处理
继续执行

OpenClaw的执行循环包含四个核心步骤:

  1. 解析会话:确定由哪个会话处理请求
  2. 组装上下文:为模型组装上下文(记忆、工具定义、对话历史)
  3. LLM推理:调用模型生成决策
  4. 工具执行:调用相应技能完成操作

OpenClaw的**网关(Gateway)**是整个系统的核心枢纽,本质上是一个WebSocket服务器,默认运行在本地18789端口。它扮演的角色类似于"总控台":所有来自外部平台的请求先经过Gateway统一调度分发给后端的Agent处理。


4. OpenClaw的Harness局限:手动配置、短期记忆、无自进化能力

OpenClaw是一个教科书级的手动Harness实现,但"手动"恰恰也是它的核心局限。

4.1 手动配置驱动,无自动优化

OpenClaw的所有能力(工具权限、模型配置、安全策略等)都通过config.yaml文件手动配置。这意味着:

  • 无法根据历史数据自动调整策略
  • 工具白名单更新需要重启服务
  • 无法自学习用户行为模式

4.2 短期记忆为主,长期记忆薄弱

OpenClaw的记忆主要依赖会话内的上下文窗口,缺乏向量数据库等长期记忆存储基础设施。AWS博客指出,OpenClaw使用记忆和Skill管理机制不当会导致Token爆炸问题------Agent内存积累越来越多消耗大量Token,既不解决问题也让成本倍增。

4.3 无自进化能力

OpenClaw缺乏自改进闭环机制。无法:

  • 从失败案例中学习并自动调整配置
  • 基于用户反馈优化提示词
  • 动态调整记忆检索策略

这正是标准Harness自改进规范所强调的核心能力:Harness的设计目标是让AI能够从错误中学习、从反馈中成长。OpenClaw在这方面仍有较大差距。


5. 配置文件解析:config.yaml = Harness载体

OpenClaw的config.yaml是Harness能力的工程化载体。所有五大组件的配置都通过这个文件进行。

5.1 三层配置体系

OpenClaw设计了一套三层配置体系:

  1. 默认配置:内置的默认值
  2. 用户配置~/.openclaw/config.yaml
  3. 环境变量:运行时覆盖

5.2 核心配置参数详解

yaml 复制代码
# ~/.openclaw/config.yaml

# ========== 1. 模型配置 ==========
ai:
  default_model: "claude-3.5-sonnet"
  providers:
    - name: "anthropic"
      api_key: "${ANTHROPIC_API_KEY}"  # 环境变量
      model: "claude-3.5-sonnet"
    - name: "openai"
      api_key: "${OPENAI_API_KEY}"
      model: "gpt-4o"
    - name: "ollama"
      url: "http://localhost:11434"
      model: "llama3"

# ========== 2. 工具层配置 ==========
skills:
  enabled: true
  allowed_skills:  # 工具白名单
    - memory_search
    - read_file
    - write_file
    - browser_navigate
    # - execute_shell  # 默认禁用
  disallowed_skills:
    - execute_shell
    - delete_file
    - modify_system

# ========== 3. 记忆层配置 ==========
memory:
  memory_file: "~/openclaw/MEMORY.md"
  memory_dir: "~/openclaw/memory"
  max_turns_per_session: 50
  auto_compress: false  # 手动Harness无自动压缩

# ========== 4. 约束层配置 ==========
security:
  sandbox:
    enabled: true
    type: "docker"  # docker / none
    workspaceAccess: "ro"  # none / ro / rw
    network: "restricted"
    whitelist_domains:
      - "api.anthropic.com"
      - "api.openai.com"
  permissions:
    require_user_confirm: true  # 高危操作需用户确认
    max_file_operations_per_min: 10
    max_network_requests_per_min: 50

# ========== 5. 可观测性配置 ==========
observability:
  logging:
    level: "info"
    json_format: true
  tracing:
    enabled: true
    trace_sampling_rate: 0.1
  audit:
    enabled: true
    audit_log_path: "~/.openclaw/logs/audit.log"

# ========== 6. 编排层配置 ==========
orchestration:
  max_loop_iterations: 10
  timeout_seconds: 60
  retry:
    max_attempts: 3
    backoff_seconds: 2

5.3 配置管理最佳实践

  1. 环境变量优先:API Key等敏感信息使用环境变量,不要硬编码在配置文件中
  2. 版本控制配置 :将config.yaml纳入版本控制,敏感信息通过环境变量注入
  3. 配置验证 :使用openclaw doctor命令验证配置文件的有效性

6. 与标准Harness对比:差异点与适配场景

维度 OpenClaw(手动Harness) 标准Harness
记忆系统 文件驱动(Markdown),无向量化 向量数据库+SQLite+FTS5,混合检索
约束机制 容器沙箱+工具白名单,静态 四层纵深防御,动态权限
工具生态 ClawHub市场,Skill即Markdown MCP协议+工具注册表
可观测性 基础日志+审计,手动排查 指标+日志+链路+成本,归因分析
优化能力 手动配置,无自进化 自动化GEPA进化闭环
适用团队 个人开发者、中小团队 企业级生产环境
部署复杂度 低(一行命令) 高(需定制集成)
安全等级 中(需手动加固) 高(默认安全策略)

适配场景建议

  • OpenClaw适合:个人AI助理、快速原型验证、非关键业务自动化、轻量级技能探索
  • 标准Harness适合:企业级生产环境、高合规要求场景(金融/医疗)、多租户大规模部署、需要自进化能力的长周期任务

7. OpenClaw部署与最佳实践

7.1 本地部署

bash 复制代码
# 1. 安装Node.js环境
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

# 2. 克隆项目
git clone https://github.com/openclaw/openclaw.git
cd openclaw

# 3. 安装依赖
npm install

# 4. 创建配置目录
mkdir -p ~/.openclaw

# 5. 复制配置文件模板
cp config.example.yaml ~/.openclaw/config.yaml

# 6. 编辑配置文件
vim ~/.openclaw/config.yaml

# 7. 启动Gateway
npm run gateway

# 8. 运行Agent
npm run agent

7.2 Docker部署(推荐)

yaml 复制代码
# docker-compose.yml
version: '3.8'
services:
  openclaw:
    image: openclaw/openclaw:latest
    container_name: openclaw
    ports:
      - "18789:18789"  # Gateway端口
    volumes:
      - ~/.openclaw:/app/.openclaw           # 配置目录
      - ~/openclaw_memory:/app/memory        # 记忆文件目录
      - /var/run/docker.sock:/var/run/docker.sock  # Docker沙箱(可选)
    environment:
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
    restart: unless-stopped

部署命令:

bash 复制代码
docker-compose up -d

7.3 最小权限配置实践

yaml 复制代码
# 生产环境最小权限配置模板
security:
  sandbox:
    enabled: true
    type: "docker"
    workspaceAccess: "ro"           # 只读工作区
    network: "restricted"           # 受限网络
    resource_limits:
      cpu: "0.5"
      memory: "512Mi"
      pids_limit: 20
  
  permissions:
    require_user_confirm: true      # 所有操作需人工确认
    allowed_paths:
      - "/app/memory/*"             # 仅允许记忆目录
      - "/tmp/openclaw/*"           # 临时目录
    allowed_domains:                # 白名单域名
      - "api.openai.com"
      - "api.anthropic.com"
    max_execution_time: 30          # 单次执行30秒超时
  
  skills:
    allowlist:                      # 只允许必要的技能
      - memory_search
      - read_file
      - browser_navigate
    disallowlist:                   # 显式禁止高危技能
      - execute_shell
      - delete_file
      - modify_system

8. 总结与展望

OpenClaw作为轻量Harness落地的典型代表,用简练的设计实现了Agent运行所需的核心能力,其意义在于让AI从"会说"进化到"能做"。但它也是手动的------所有能力都需要人工配置,缺乏自动化闭环和自进化机制。

核心要点回顾

维度 实现 强度
记忆层 Markdown文件驱动 ⭐⭐⭐
约束层 Docker沙箱+工具白名单 ⭐⭐⭐⭐
工具层 SKILL.md+ClawHub生态 ⭐⭐⭐⭐⭐
可观测性 日志+审计+染色 ⭐⭐⭐
编排层 Gateway+Agent Loop ⭐⭐⭐⭐
自动化 手动配置 ⭐⭐
自进化

未来演进方向 :OpenClaw已在逐步补强安全加固------v2026.3.22版本一次性修复了十余项安全漏洞,包括环境变量注入攻击、Unicode零宽字符伪装命令审批等高危问题。官方也建议用户全量Docker运行以实现沙箱隔离,这是迈向企业级安全的关键一步。可以预见,OpenClaw将从"爆火的龙虾"进化为"可靠的生产级Agent基础设施"。


参考资料

版权声明:本文为CSDN博主原创,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

如果觉得本文对你有帮助,请点赞、收藏、关注,支持后续更多干货!

相关推荐
jkyy20141 小时前
AI营养师:全周期膳食智能陪伴,构建机构营养服务差异化壁垒
大数据·人工智能·健康医疗
大模型最新论文速读1 小时前
06-02 · LLM 最新论文速览
论文阅读·人工智能·深度学习·机器学习·自然语言处理
搜佛说1 小时前
sfsDb 和 SQLite、InfluxDB “硬碰硬”的底层性能与技术架构对比
jvm·架构·sqlite
Bingorl1 小时前
机器学习之KNN算法
人工智能·算法·机器学习
Coder小相1 小时前
LangChain 1.0 第六篇 - 从Prompt模板到角色设计
人工智能·agent·ai编程
Ada's1 小时前
【智能体系统AgentOS】核心21:VLA和WMA
人工智能
kcuwu.1 小时前
FastText文本分类全流程实战技术博客
人工智能·分类·数据挖掘
Agilex松灵机器人1 小时前
IsaacLab机械臂数据采集教程:实现松灵7轴机械臂键盘控制与遥操作!
人工智能·仿真·具身智能·isaaclab·松灵机器人·松灵机械臂
oort1231 小时前
VLStream 全开源可私有化的AI视频平台 真能解决传统项目的痛点吗? 太实用了
人工智能·开源·音视频