feat: 替换为 Sean Matthew 文章原文 (raw content)
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
| 日期 | 时间 | 服务器 | 备份文件 | 状态 |
|
||||
| ---------- | ----- | -------- | ----------------------------------- | ---- |
|
||||
| 2026-03-24 | 22:00 | Mac Mini | openclaw-macmini-20260324220009.tar | ✅ 成功 |
|
||||
| 2026-03-24 | 22:00 | Ubuntu2 | openclaw-ubuntu2-20260324220009.tar | ✅ 成功 |
|
||||
| 2026-03-20 | 06:19 | Mac Mini | openclaw-macmini-20260320061934.tar | ✅ 成功 |
|
||||
| 2026-03-20 | 06:19 | Ubuntu2 | openclaw-ubuntu2-20260320061935.tar | ✅ 成功 |
|
||||
| 2026-03-20 | 06:18 | Mac Mini | openclaw-macmini-20260320061855.tar | ✅ 成功 |
|
||||
|
||||
203
openclaw/xinghui/3-essential-tools-for-openclaw-raw.md
Normal file
203
openclaw/xinghui/3-essential-tools-for-openclaw-raw.md
Normal file
@@ -0,0 +1,203 @@
|
||||
# 3 Essential Tools for OpenClaw
|
||||
|
||||
**Source**: https://x.com/_sean_matthew/status/2028902126005653889
|
||||
**Author**: Sean Matthew (Verified)
|
||||
**Published**: March 4, 2026 at 2:35 AM
|
||||
**Views**: 6,484 | **Reposts**: 13 | **Likes**: 76 | **Bookmarks**: 113
|
||||
|
||||
---
|
||||
|
||||
For the last few weeks, I've been running OpenClaw on a dedicated Mac Mini as my personal AI agent. It's got access to Telegram, my calendar, task manager, my YouTube channel, my Obsidian vault, and many other useful things. But even after wiring up all those integrations, I still found there were three big gaps.
|
||||
|
||||
Because here's the thing: out of the box, OpenClaw can't send emails, can't remember what you worked on last week (at least not very well), and can't reliably browse the web.
|
||||
|
||||
What I will show you below are three tools that fix all of that, plus the exact prompts you can paste into Claude Code to set each one up in minutes.
|
||||
|
||||
I have a full video walkthrough of this setup on YouTube, which you can access here: https://www.youtube.com/watch?v=QvfqAMUJTT4
|
||||
|
||||
---
|
||||
|
||||
## Before You Start
|
||||
|
||||
Make sure you have OpenClaw installed. On whatever machine you're running it, open a Terminal and run this:
|
||||
|
||||
```bash
|
||||
cd ~/.openclaw
|
||||
```
|
||||
|
||||
This puts you in the OpenClaw workspace folder. Launch Claude Code, Codex, or whatever coding agent you like from this directory. All of the following steps assume you're in this directory.
|
||||
|
||||
---
|
||||
|
||||
## Side Note: Why Not Use OpenClaw Itself Here?
|
||||
|
||||
You might be wondering: why not just have OpenClaw install its own skills and tools? It can absolutely do that, and I use it that way frequently. But just as often, I use Claude Code as the background architect of my OpenClaw. There's a reason why I have the Claude Max plan, and I like to use it to its fullest. But as you probably know, Anthropic has [cracked](https://www.theregister.com/2026/02/20/anthropic_clarifies_ban_third_party_claude_access/) [down](https://www.reddit.com/r/ClaudeAI/comments/1r8ecyq/anthropic_bans_oauth_tokens_from_consumer_plans/) on people using their Claude subscriptions with OpenClaw, basically making API keys the only truly "safe" path for now. So in almost all cases, you're paying per-token to run OpenClaw, whether that's through Anthropic, OpenAI, OpenRouter, or whatever provider you're using.
|
||||
|
||||
So, to answer the question above, I use Claude Code to build all of OpenClaw's systems, skills, and workflows. When OpenClaw is actually running day-to-day, it's not burning through tokens to fix faulty setups. It's executing systems that were built precisely with Claude Code.
|
||||
|
||||
---
|
||||
|
||||
## How Skills Work in OpenClaw
|
||||
|
||||
Before we get into the tools, a quick note on how OpenClaw learns new capabilities. There are two ways to add skills:
|
||||
|
||||
1. **Manually** — You teach OpenClaw how to use a tool by creating a SKILL.md file with all the instructions it needs to use the tool. You can use any agent to build this out.
|
||||
2. **ClawHub** — This is OpenClaw's skill registry, basically a repository of pre-built skills you can install. Some come from the OpenClaw creator himself, some are official skills from tool authors, and some are community-contributed.
|
||||
|
||||
A word of warning on ClawHub: There have been reports of malware being deployed on the site. Exercise caution when downloading skills (stick to official or well-known authors). All three skills in this guide come from verified sources.
|
||||
|
||||
To install ClawHub (one-time setup):
|
||||
|
||||
```bash
|
||||
npm i -g clawhub
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tool 1: AgentMail: Give Your Agent Its Own Email
|
||||
|
||||
[AgentMail](https://agentmail.to) is a Y Combinator-backed startup that built an email platform specifically for AI agents. The idea is simple: your agent gets its own real email inbox. This is not Gmail and does not come with the inherent risks of signing up for Google accounts (i.e., account banning). This is an inbox designed from the ground up for agents to send and receive emails programmatically.
|
||||
|
||||
### Create an account
|
||||
|
||||
Go to [agentmail.to](https://agentmail.to) and click "Get Started." You can sign up with Google, and it's free. There are paid plans, but the free tier is very generous and gives you up to 3 inboxes. You'll go through a simple onboarding to create your first inbox. The address will be yourname@agentmail.to. Copy this inbox name, as you'll need it in a minute.
|
||||
|
||||
### Grab your API key
|
||||
|
||||
In the AgentMail dashboard, go to the API keys section and generate your first key. Keep a copy of that handy.
|
||||
|
||||
### Paste this prompt into Claude Code
|
||||
|
||||
Use this prompt to install the AgentMail skill for Open Claw and connect your OpenClaw to all the necessary tools it needs to send and receive email through your new AgentMail inbox.
|
||||
|
||||
```markdown
|
||||
Set up AgentMail for my OpenClaw agent. The AgentMail skill docs and reference are at: https://clawhub.ai/adboio/agentmail Make sure to:
|
||||
1. The AgentMail skill is already installed via clawhub (if not installed, please do so)
|
||||
2. Configure the AGENTMAIL_API_KEY in my openclaw.json. My key is: [YOUR_KEY] under skills.entries.agentmail
|
||||
3. My agent's inbox is: [YOUR_INBOX]
|
||||
4. Install the Python SDK (pip install agentmail python-dotenv)
|
||||
5. Test sending and receiving an email
|
||||
```
|
||||
|
||||
Replace [YOUR_KEY] and [YOUR_INBOX] with the values you saved earlier. Claude Code will handle the rest.
|
||||
|
||||
### What this looks like in practice
|
||||
|
||||
In the full walkthrough video I linked above, I forwarded a newsletter I received in my personal email to my AgentMail inbox. OpenClaw picked it up and immediately pinged me on Telegram to let me know something landed in the inbox. I asked it to give me the main takeaways, and it came back with a clean summary of the entire email.
|
||||
|
||||
That's a simple personal use case: I'm forwarding invoices, newsletters, and other stuff from my day-to-day life to Jarvis (my OpenClaw agent), and it gives me summaries and action items.
|
||||
|
||||
But you could take this much further:
|
||||
|
||||
- Set up a **support inbox** where your agent handles first-line responses to customer inquiries
|
||||
- Have it **process incoming invoices** and extract key details
|
||||
- Build a **daily email digest** that your agent compiles and sends to you on Telegram
|
||||
- Route different types of emails to different agent workflows via webhooks
|
||||
|
||||
The possibilities are really endless.
|
||||
|
||||
---
|
||||
|
||||
## Tool 2: QMD: Upgrade the Agent's Memory
|
||||
|
||||
This might be the single biggest upgrade you can make to your OpenClaw. Let me explain the problem first.
|
||||
|
||||
### The problem with default memory
|
||||
|
||||
Out of the box, OpenClaw has a memory system. When you interact with it, it creates markdown files stored in a local SQLite database. Anytime you want to ask about previous work or past sessions, it uses keyword-based search to find relevant memories.
|
||||
|
||||
The problem is obvious: if you ask "hey, what did we do with XYZ last week?" but the actual conversation used different words, the keyword search fails. So your agent easily forgets things you've worked on.
|
||||
|
||||
And it gets worse over time. The more you interact with OpenClaw and the more memories you accumulate, the more bloated your queries get. You're pulling in a ton of irrelevant tokens every time you ask about history, which burns through API costs and makes your agent slower and dumber.
|
||||
|
||||
### What QMD is
|
||||
|
||||
[QMD](https://github.com/tobi/qmd) is an open-source tool built by Tobi Lutke (the CEO of Shopify). It's a local hybrid search engine for markdown files that combines three search strategies:
|
||||
|
||||
1. **Keyword search** (traditional matching, same as OpenClaw's default memory system)
|
||||
2. **Vector semantic search** (understands meaning, not just exact words)
|
||||
3. **LLM-powered re-ranker** (scores results by actual relevance)
|
||||
|
||||
The key thing: it all runs entirely on your machine. No API keys, no cloud services, no data leaving your computer. It downloads some small local models (they don't take up much space) and everything happens locally and efficiently.
|
||||
|
||||
### Setup
|
||||
|
||||
Paste this prompt into ClaudeCode to install QMD and hook it up to your OpenClaw as its memory backbone:
|
||||
|
||||
```markdown
|
||||
Set up QMD as the memory backend for my OpenClaw agent. Follow the official docs here: https://docs.openclaw.ai/concepts/memory#qmd-backend-experimental Make sure to:
|
||||
1. Install the QMD CLI
|
||||
2. Install SQLite with extension support if needed (macOS: brew install sqlite)
|
||||
3. Configure memory.backend = "qmd" in my openclaw.json
|
||||
4. Add my workspace memory files as a QMD collection
|
||||
5. Run the initial embed so models are downloaded and the index is built
|
||||
6. Verify it works by running a test query
|
||||
```
|
||||
|
||||
If I had to pick just one tool from this entire list, it's QMD. The memory upgrade is the single biggest quality-of-life improvement for OpenClaw.
|
||||
|
||||
---
|
||||
|
||||
## Tool 3: Agent-Browser: Give the Agent a Better Browser
|
||||
|
||||
[Agent-browser](https://github.com/vercel-labs/agent-browser) is a CLI tool from Vercel that gives your AI agent a real web browser. This is not just fetching and scraping HTML. This is an actual Chromium browser that can navigate pages, click on things, take screenshots, fill out forms, etc. Basically any interaction a user could have in a browser.
|
||||
|
||||
### Why agent-browser instead of Playwright?
|
||||
|
||||
If you've used Playwright with an AI agent before, you've probably noticed how token-inefficient it is. Every time Playwright interacts with a website, it generates a ton of information. Your AI agent has to process all of that, which fills up its context window and ultimately gives you a worse outcome.
|
||||
|
||||
Agent-browser takes a completely different approach. Everything Playwright can do, agent-browser can do with **93% less tokens**. That's a massive difference for an always-on agent: it means your agent can do a lot more browsing for a lot less money.
|
||||
|
||||
### Install the CLI
|
||||
|
||||
```bash
|
||||
npm install -g agent-browser
|
||||
```
|
||||
|
||||
### Paste this prompt into Claude Code
|
||||
|
||||
```markdown
|
||||
Install the agent-browser skill for my OpenClaw agent. The agent-browser SKILL.md and reference docs are at: https://github.com/vercel-labs/agent-browser/tree/main/skills/agent-browser Follow the OpenClaw skills docs here: https://docs.openclaw.ai/tools/skills Make sure to:
|
||||
1. Install the agent-browser skill into ~/.openclaw/skills/agent-browser/ so it's available to all my agents
|
||||
2. Include the SKILL.md and any reference docs from the repo
|
||||
3. Verify the skill shows up as eligible
|
||||
4. Whenever my agent needs to access the internet or browse a web page, it should use agent-browser
|
||||
```
|
||||
|
||||
This prompt pulls the agent-browser skills from GitHub, installs them on your machine, and tells OpenClaw that anytime it needs to browse the web, it should use agent-browser. Once installed, the skill is available to OpenClaw, as well as Claude Code, Codex, or any other AI agent running on that machine.
|
||||
|
||||
In the walkthrough video I linked above, I showed a simple use case for agent-browser: navigating to Hacker News and summarizing what is trending for the day. I ran it through the command line to show its speed (42s to complete the whole task) and then ran the same workflow through Telegram (which pings my OpenClaw to run the same agent-browser commands). These are relatively simple use cases, but there are ton of different directions you can take agent-browser:
|
||||
|
||||
### Advanced use cases
|
||||
|
||||
- **No-API workflows** — Any site or service that doesn't have an API, where you have to go to a web console or dashboard to interact with it, your agent can now handle that. Fill out forms, export reports, change settings, etc.
|
||||
- **Self-verifying code** — When your agent makes code changes, it can open a preview URL in an actual browser and verify the fix worked. This is a typical workflow for Playwright, but as I mentioned, agent-browser can do it much faster.
|
||||
- **Website monitoring** — Track price drops, product listings, back-in-stock alerts, job listings, or any changes on any page.
|
||||
- **Security guardrails** — This is not a use case per se, but I'll just point out that agent-browser has built-in prompt injection defenses. It's not perfect, but it provides an extra line of defense so your agent isn't getting poisoned by malicious content on the web.
|
||||
- **Electron apps** — This is brand new. Agent-browser has an Electron skill that lets it control desktop apps (e.g., Slack, Notion, VS Code, Discord). I haven't tested this one out yet, but it opens up a whole new category of automation beyond just web browsing.
|
||||
|
||||
---
|
||||
|
||||
## Recap
|
||||
|
||||
There you have it. Three tools, three simple upgrades:
|
||||
|
||||
1. **AgentMail** gives your agent its own dedicated email inbox
|
||||
2. **QMD** gives your agent real semantic memory that actually works
|
||||
3. **Agent-Browser** gives your agent a better, faster, cheaper way to browse the web
|
||||
|
||||
Each one takes only a few minutes to set up, but together they turn a basic OpenClaw install into something that actually feels like a useful assistant.
|
||||
|
||||
Start with QMD. Then hook up all three. I promise that it's worth it.
|
||||
|
||||
---
|
||||
|
||||
## Resources
|
||||
|
||||
- [AgentMail](https://agentmail.to)
|
||||
- [AgentMail skill (ClawHub)](https://clawhub.ai/adboio/agentmail)
|
||||
- [QMD](https://github.com/tobi/qmd)
|
||||
- [OpenClaw Memory Docs (QMD)](https://docs.openclaw.ai/concepts/memory#qmd-backend-experimental)
|
||||
- [Agent-Browser](https://github.com/vercel-labs/agent-browser)
|
||||
- [OpenClaw Skills Docs](https://docs.openclaw.ai/tools/skills)
|
||||
- [ClawHub](https://clawhub.ai)
|
||||
@@ -1,120 +0,0 @@
|
||||
# 3 Essential Tools for OpenClaw
|
||||
|
||||
> **来源**: [X @_sean_matthew](https://x.com/_sean_matthew/status/2028902126005653889)
|
||||
> **作者**: Sean Matthew (认证账号)
|
||||
> **发布日期**: 2026年3月4日
|
||||
> **查看**: 6,483 次 | 13 转帖 | 76 喜欢 | 113 书签
|
||||
|
||||
---
|
||||
|
||||
## 摘要
|
||||
|
||||
作者分享了三个能够显著提升 OpenClaw 能力的必备工具,帮助解决 OpenClaw 开箱即用的三个主要缺陷:无法发送邮件、无法记住上周的工作、无法可靠地浏览网页。
|
||||
|
||||
---
|
||||
|
||||
## 背景
|
||||
|
||||
作者在 Mac Mini 上运行 OpenClaw 作为个人 AI 助手,集成了 Telegram、日历、任务管理器、YouTube、Obsidian 等。但即使接入了这些服务,仍有三个大缺口:
|
||||
- 无法发送邮件
|
||||
- 不能很好地记住过去的工作
|
||||
- 不能可靠地浏览网页
|
||||
|
||||
---
|
||||
|
||||
## 三个必备工具
|
||||
|
||||
### Tool 1: AgentMail - 给 Agent 自己的邮箱
|
||||
|
||||
**是什么**: AgentMail (agentmail.to) 是一个 Y Combinator 支持的初创公司构建的 AI 专用邮件平台。Agent 有自己的真实邮箱 inbox,不是 Gmail,没有账户被封的风险。
|
||||
|
||||
**功能**:
|
||||
- Agent 可以通过 API 发送和接收邮件
|
||||
- 可以创建多个 inbox(免费版最多 3 个)
|
||||
- 地址格式:yourname@agentmail.to
|
||||
|
||||
**设置步骤**:
|
||||
1. 访问 agentmail.io 注册账号(可用 Google 登录,免费)
|
||||
2. 创建第一个 inbox
|
||||
3. 在 Dashboard 获取 API Key
|
||||
4. 使用 Claude Code 安装 AgentMail skill 并配置
|
||||
|
||||
**使用场景**:
|
||||
- 转发Newsletter让 Agent 总结
|
||||
- 处理收到的发票
|
||||
- 构建每日邮件摘要
|
||||
- 设置客服收件箱处理客户咨询
|
||||
- 通过 Webhook 将不同类型邮件路由到不同工作流
|
||||
|
||||
---
|
||||
|
||||
### Tool 2: QMD - 升级 Agent 的记忆
|
||||
|
||||
**问题**: OpenClaw 默认的内存系统使用关键词搜索,如果你问"上周我们和 XYZ 做了什么?"但实际对话用了不同的词,搜索就会失败。
|
||||
|
||||
**是什么**: QMD 是 Shopify CEO Tobi Lutke 构建的开源工具,是一个本地混合搜索引擎,结合三种搜索策略:
|
||||
1. **关键词搜索** - 传统匹配
|
||||
2. **向量语义搜索** - 理解含义,不只是精确词语
|
||||
3. **LLM 重排序器** - 根据实际相关性评分
|
||||
|
||||
**关键点**: 完全在本地运行,不需要 API Key,不使用云服务,数据不离开电脑。
|
||||
|
||||
**设置步骤**:
|
||||
1. 安装 QMD CLI
|
||||
2. 配置 `memory.backend = "qmd"` 在 openclaw.json
|
||||
3. 将工作区内存文件添加为 QMD 集合
|
||||
4. 运行初始嵌入下载模型并构建索引
|
||||
|
||||
> 作者评价:这是单个最大的生活质量提升工具。
|
||||
|
||||
---
|
||||
|
||||
### Tool 3: Agent-Browser - 给 Agent 更好的浏览器
|
||||
|
||||
**是什么**: Agent-browser 是 Vercel 的 CLI 工具,给 AI Agent 一个真正的浏览器(Chromium)。不是简单的 HTML 抓取,而是可以导航、点击、截图、填表等。
|
||||
|
||||
**为什么选 Agent-browser 而不是 Playwright**:
|
||||
- Playwright 与 AI Agent 配合时 token 效率很低
|
||||
- Agent-browser 比 Playwright **节省 93% 的 tokens**
|
||||
- 对于常驻的 Agent,这意味着更少的钱能做更多的事
|
||||
|
||||
**安装**:
|
||||
```bash
|
||||
npm install -g agent-browser
|
||||
```
|
||||
|
||||
**高级使用场景**:
|
||||
- **无 API 工作流** - 任何没有 API 的网站或服务,Agent 都能处理
|
||||
- **自验证代码** - Agent 修改代码后可以在浏览器中打开预览验证
|
||||
- **网站监控** - 追踪价格变化、产品上架、缺货提醒等
|
||||
- **安全护栏** - 内置提示注入防御
|
||||
- **Electron 应用** - 控制桌面应用(Slack、Notion、VS Code、Discord)
|
||||
|
||||
---
|
||||
|
||||
## 总结
|
||||
|
||||
三个工具,三种简单升级:
|
||||
|
||||
| 工具 | 功能 |
|
||||
|------|------|
|
||||
| AgentMail | 给 Agent 专用邮箱收件箱 |
|
||||
| QMD | 给 Agent 真正有效的语义记忆 |
|
||||
| Agent-Browser | 给 Agent 更好、更快、更便宜的网页浏览方式 |
|
||||
|
||||
每个只需几分钟设置,但一起使用能让基础的 OpenClaw 变成真正有用的助手。
|
||||
|
||||
**建议**: 从 QMD 开始,然后连接全部三个。
|
||||
|
||||
---
|
||||
|
||||
## 相关资源
|
||||
|
||||
- [AgentMail](https://agentmail.to)
|
||||
- [AgentMail Skill (ClawHub)](https://clawhub.ai/adboio/agentmail)
|
||||
- [QMD](https://github.com/tobi/qmd)
|
||||
- [OpenClaw Memory Docs (QMD)](https://docs.openclaw.ai/concepts/memory#qmd-backend-experimental)
|
||||
- [Agent-Browser](https://github.com/vercel-labs/agent-browser)
|
||||
- [OpenClaw Skills Docs](https://docs.openclaw.ai/tools/skills)
|
||||
- [ClawHub](https://clawhub.ai)
|
||||
- [YouTube 视频教程](https://www.youtube.com/watch?v=QvfqAMUJTT4)
|
||||
213
openclaw/xinghui/how-to-fix-your-openclaw-memory-raw.md
Normal file
213
openclaw/xinghui/how-to-fix-your-openclaw-memory-raw.md
Normal file
@@ -0,0 +1,213 @@
|
||||
# How to Fix Your OpenClaw's Memory
|
||||
|
||||
**Source**: https://x.com/_sean_matthew/status/2031800232569102610
|
||||
**Author**: Sean Matthew (Verified)
|
||||
**Published**: March 12, 2026 at 2:31 AM
|
||||
**Views**: 1,670 | **Reposts**: 5 | **Likes**: 41 | **Bookmarks**: 50
|
||||
|
||||
---
|
||||
|
||||
A few weeks ago, my OpenClaw stopped working. At first, I thought it was a model problem. It took me a while to figure out I was wrong.
|
||||
|
||||
Here's what happened: my agent kept forgetting important context. Skills weren't being triggered correctly. Cron jobs stopped running reliably. I kept getting context-related errors in Telegram. And the longer a session ran, the more tokens it seemed to burn.
|
||||
|
||||
This happened when I was running Kimi K2.5 as my main model. I switched over to Sonnet 4.6, and things got a little better, especially with triggering skills and calling tools. But the real problem wasn't the model. It was how OpenClaw manages memory and context behind the scenes.
|
||||
|
||||
Right around the time I was struggling with this, I saw a [post](https://x.com/i/article/2025615759771123712) from a developer named Ramya, who documented spending a week debugging her agent's memory. She was running into some of the exact same issues I was hitting. Her article helped me a ton and inspired me to completely rethink the way my OpenClaw runs. The fixes discussed here are based on what I changed in my own setup to make my OpenClaw agent, Jarvis, more stable and much cheaper to run.
|
||||
|
||||
If you'd rather watch how to do this than read about it, I have a full video walkthrough on YouTube, which you can access here: https://youtu.be/UTztjR4o7Y8
|
||||
|
||||
---
|
||||
|
||||
## Before You Start
|
||||
|
||||
If you followed my last article on the [3 Essential Tools for OpenClaw](https://x.com/_sean_matthew/status/2028902126005653889), this setup is the same. On whatever machine OpenClaw is running, open a Terminal and run:
|
||||
|
||||
```bash
|
||||
cd ~/.openclaw
|
||||
```
|
||||
|
||||
This puts you in the OpenClaw workspace folder. Launch Claude Code, Codex, or your preferred coding agent from this directory. All of the prompts below assume the agent can see your OpenClaw workspace.
|
||||
|
||||
If you're wondering why I use Claude Code instead of OpenClaw itself for this kind of work, here's the short answer: I want OpenClaw executing systems, not burning tokens to build them. Claude Code handles the engineering. OpenClaw runs the result. I covered this in more detail in the last article, so I won't repeat myself here.
|
||||
|
||||
Now, let's move on to the fixes.
|
||||
|
||||
---
|
||||
|
||||
## Fix 1: Stop Losing Important Context During Compaction
|
||||
|
||||
Here's the first thing to understand. OpenClaw has a finite context window, just like any AI agent. This is basically the agent's short-term memory. As your conversation gets longer, OpenClaw does something called compaction: it compresses older messages into a summary to make room for new ones.
|
||||
|
||||
Sounds reasonable, right? The problem is that compaction treats everything equally. That important instruction you gave 20 messages ago gets the same compression treatment as everything else, no matter how relevant. Names, numbers, exact decisions, and other important details can get lost as the compaction process distills everything into a generic summary.
|
||||
|
||||
**The rule is simple:** if it's only in the context window, it's temporary. If it's on disk, it survives.
|
||||
|
||||
The first fix is memory flush. This gives the agent a chance to write important information out to disk before compaction runs.
|
||||
|
||||
**Paste this prompt into Claude Code:**
|
||||
|
||||
```markdown
|
||||
Read the OpenClaw memory docs here: https://docs.openclaw.ai/concepts/memory Then inspect my current openclaw.json and enable memory flush under compaction. Requirements:
|
||||
1. Turn memory flush on
|
||||
2. Use a soft threshold amount that is recommended in the documentation (if none is recommended, use 4000 tokens)
|
||||
3. If the compaction block does not exist yet, create it
|
||||
4. Do not duplicate existing settings
|
||||
5. After making the change, explain in plain English what will happen before compaction runs
|
||||
```
|
||||
|
||||
That handles the first failure mode. But there's a second one: very long sessions.
|
||||
|
||||
Memory flush triggers once per compaction cycle. If you're in a really long session, like a four-hour deep work session, compaction might run multiple times, and only the first one gets the flush treatment. So you also want session pruning to aggressively clean up old context:
|
||||
|
||||
**Paste this prompt into Claude Code next:**
|
||||
|
||||
```markdown
|
||||
Read the OpenClaw session pruning docs here: https://docs.openclaw.ai/concepts/session-pruning Then inspect my openclaw.json and configure session pruning (also known as context pruning). Requirements:
|
||||
1. Use cache-ttl mode
|
||||
2. Set the TTL to whatever is recommended in the documentation (if nothing is recommended, use 4 hours)
|
||||
3. Keep the last 3 assistant messages
|
||||
4. If session/context pruning already exists, update it safely instead of creating duplicate blocks
|
||||
5. After the change, summarize the final behavior in plain English
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Fix 2: Make Retrieval Actually Work
|
||||
|
||||
Saving important information via memory flush is only half the job. Your agent also has to find this information again. And more importantly, it has to remember to look.
|
||||
|
||||
This is where a lot of setups quietly fail. The data exists somewhere on disk, but the agent never searches for it, or the default retrieval isn't good enough to surface the right result.
|
||||
|
||||
If you followed my last article, you already know about QMD: the hybrid search engine by Tobi Lutke that combines keyword matching, vector semantic search, and an LLM re-ranker. If you haven't set that up yet, go read that article first. It's the single biggest upgrade you can make to OpenClaw's memory.
|
||||
|
||||
But here's the more subtle problem I didn't cover last time: even with great search, your agent has to actually decide to search. And if the conversation doesn't trigger the right cues, it just won't look things up. The information exists. The agent doesn't use it.
|
||||
|
||||
So you need to add explicit retrieval instructions to the top of your agent's file (AGENTS.md). Think of this as a checklist: before doing anything, the agent searches for relevant context.
|
||||
|
||||
**Paste this prompt into Claude Code:**
|
||||
|
||||
```markdown
|
||||
Read the OpenClaw memory docs for QMD here: https://docs.openclaw.ai/concepts/memory#qmd-backend-experimental Then inspect my current OpenClaw setup and improve retrieval. Requirements:
|
||||
1. If I am not already using QMD as the memory backend, install and configure it
|
||||
2. Verify the memory backend is working with a test query
|
||||
3. Update the top of my AGENTS.md instructions so that before starting any task the agent:
|
||||
- searches daily logs for relevant context
|
||||
- checks a central learnings file (LEARNINGS.md) for rules related to the task
|
||||
4. Keep the boot instructions concise and operational
|
||||
5. After the changes, explain the new retrieval flow in plain English
|
||||
```
|
||||
|
||||
What this does is it grounds your OpenClaw's actions in any relevant memories that can be searched in QMD, as well as a central list of rules that guard against mistakes and reinforce other lessons learned: a LEARNINGS.md file. This was another revelation from Ramya's article: that every time the OpenClaw agent makes a mistake, you make the agent write a one-line or two-line rule in a LEARNINGS.md file to prevent the agent from making the same mistake again. This, coupled with the agent's smarter search and retrieval of memories via QMD, will make your agent much smarter and more efficient.
|
||||
|
||||
---
|
||||
|
||||
## Fix 3: The Heartbeat Cost Trap
|
||||
|
||||
This was probably the most expensive mistake in my setup, and nobody really warns you about it.
|
||||
|
||||
If you have heartbeat enabled, which you should by default, your agent wakes up every 30 minutes to check on things. You arguably need this to make your OpenClaw truly a realtime agent. But, you should also know that every single heartbeat is a full agent turn, not a lightweight ping. A full API call that carries the entire session context.
|
||||
|
||||
That means every 30 minutes, your agent re-sends your entire system prompt — AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, HEARTBEAT.md, MEMORY.md — plus all your skill metadata, plus whatever conversation history is in the session. That's potentially 10,000 to 15,000 tokens, forty-eight times a day. Even on a cheap model, that adds up fast.
|
||||
|
||||
Here's what the optimized heartbeat config looks like:
|
||||
|
||||
```json
|
||||
{
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"heartbeat": {
|
||||
"every": "30m",
|
||||
"lightContext": true,
|
||||
"model": "google/gemini-3.1-flash-lite-preview",
|
||||
"activeHours": {
|
||||
"start": "08:00",
|
||||
"end": "23:00"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The key changes, and why each one matters:
|
||||
|
||||
**lightContext: true** — This is a big one. By default, every heartbeat loads your entire system prompt. With light context enabled, the heartbeat only loads HEARTBEAT.md. That's it. All other files get skipped. Instead of sending 10,000 to 15,000 tokens on every heartbeat, you're sending maybe a few hundred tokens.
|
||||
|
||||
**Cheap model** — There's no reason to burn Opus or Sonnet tokens on a heartbeat. It's just checking whether anything needs attention. Use the cheapest model that can read a checklist. I like Gemini 3.1 Flash-Lite, but you could even use a local model, such as Qwen 3.5:9B, potentially eliminating heartbeat costs entirely.
|
||||
|
||||
**Active hours** — If your agent doesn't need to check in at 3 AM, don't let it. That cuts your heartbeat calls almost in half. If you must run your heartbeat all day, alternatively, you can have your heartbeat run every 1 or 2 hours, instead of every 30 minutes.
|
||||
|
||||
**And one more thing:** keep HEARTBEAT.md tiny. If that file is bloated with instructions, you're paying for all of it on every heartbeat run. Trim it to just the most essential checklist of things to check.
|
||||
|
||||
**Paste this prompt into Claude Code:**
|
||||
|
||||
```markdown
|
||||
Read the OpenClaw heartbeat docs here: https://docs.openclaw.ai/gateway/heartbeat Then inspect my current OpenClaw heartbeat configuration and optimize it for low token usage. Requirements:
|
||||
1. Enable lightContext for heartbeat
|
||||
2. Set the heartbeat model to google/gemini-3.1-flash-lite-preview
|
||||
3. Limit active hours to 08:00 through 23:00
|
||||
4. Review HEARTBEAT.md and trim it so it only contains the minimum instructions needed for heartbeat runs
|
||||
5. Do not remove any heartbeat behavior that is actually necessary
|
||||
6. After the change, explain what context heartbeat will still load on each run
|
||||
```
|
||||
|
||||
You do not need to enable **all** of the heartbeat cost-saving recommendations, though. At a minimum, you really only need to use a cheap model and keep HEARTBEAT.md tiny.
|
||||
|
||||
---
|
||||
|
||||
## Fix 4: Do a Full System Prompt Audit
|
||||
|
||||
This was the lesson that tied everything together for me.
|
||||
|
||||
When I was running Kimi K2.5, I kept thinking it was the model's fault. When I started getting endless "context full" error messages when I messaged Jarvis in Telegram, I switched to Sonnet 4.6. The increased context window helped a bit. But I was still burning more context than I should have.
|
||||
|
||||
That's when I realized: I had **no idea** what was actually in my agent's context. All these files — AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, HEARTBEAT.md, MEMORY.md — they all auto-load on every turn. And I'd been adding stuff to them without ever auditing how big they'd gotten or checking for redundancy.
|
||||
|
||||
You can inspect some of this inside OpenClaw with the command "/context detail." But the best move is to let Claude Code audit the whole prompt surface for duplication and bloat. Claude Code is perfect for this because it can read all those files, understand the relationships between them, and give you a concrete list of what to trim.
|
||||
|
||||
**Paste this prompt into Claude Code:**
|
||||
|
||||
```markdown
|
||||
Read all of my OpenClaw system prompt files:
|
||||
- AGENTS.md
|
||||
- SOUL.md
|
||||
- TOOLS.md
|
||||
- IDENTITY.md
|
||||
- USER.md
|
||||
- HEARTBEAT.md
|
||||
- MEMORY.md Then do a full system prompt audit. Requirements:
|
||||
1. Identify anything redundant, duplicated across files, or unnecessarily long
|
||||
2. Give me a concrete cut list with reasons
|
||||
3. Apply the trims carefully without removing important behavior
|
||||
4. Keep responsibilities clearly separated between files
|
||||
5. After editing, summarize the biggest reductions and any risks or follow-up checks I should make
|
||||
```
|
||||
|
||||
After I did this, my system prompt shrank significantly. And that's really why Kimi K2.5 was choking: it has a smaller context window, and I was wasting a huge chunk of it on bloated system files. The real fix wasn't switching models. It was trimming the unnecessary stuff.
|
||||
|
||||
This is why I now think that context engineering and memory management are super important when you're customizing your own personal AI agent like OpenClaw.
|
||||
|
||||
---
|
||||
|
||||
## Recap
|
||||
|
||||
Here's the practical sequence I'd recommend:
|
||||
|
||||
1. **Memory flush** — Write important context to disk before compaction wipes it.
|
||||
2. **Session pruning** — Stop long-running conversations from dragging dead context forever.
|
||||
3. **Retrieval + boot instructions** — Upgrade search with QMD, and make sure the agent is explicitly told to search for prior context before starting any task. Save important rules in a central .md file to prevent the agent from repeating mistakes.
|
||||
4. **Heartbeat optimization** — Enable light context, use a cheap model, limit active hours, and/or keep HEARTBEAT.md small.
|
||||
5. **System prompt audit** — Let Claude Code do a full audit on your system prompt to cut the bloat.
|
||||
|
||||
The main takeaway here is that if you're building with OpenClaw, the models you pick to run your agent are only half the battle (or less). The real value is in making sure your agent has a good memory and context management system.
|
||||
|
||||
---
|
||||
|
||||
## Resources
|
||||
|
||||
- [Ramya's (code_rams) article on agent memory debugging](https://x.com/i/article/2025615759771123712)
|
||||
- [OpenClaw memory docs](https://docs.openclaw.ai/concepts/memory)
|
||||
- [OpenClaw session pruning docs](https://docs.openclaw.ai/concepts/session-pruning)
|
||||
- [OpenClaw heartbeat docs](https://docs.openclaw.ai/gateway/heartbeat)
|
||||
- [QMD by Tobi Lutke](https://github.com/tobi/qmd)
|
||||
@@ -1,115 +0,0 @@
|
||||
# How to Fix Your OpenClaw's Memory
|
||||
|
||||
> **来源**: [X @_sean_matthew](https://x.com/_sean_matthew/status/2031800232569102610)
|
||||
> **作者**: Sean Matthew (认证账号)
|
||||
> **发布日期**: 2026年3月12日
|
||||
> **查看**: 1,669 次 | 5 转帖 | 41 喜欢 | 50 书签
|
||||
|
||||
---
|
||||
|
||||
## 摘要
|
||||
|
||||
作者分享了修复 OpenClaw 内存问题的四个关键优化,帮助降低 token 消耗并提升 Agent 稳定性。
|
||||
|
||||
---
|
||||
|
||||
## 问题背景
|
||||
|
||||
几周前,作者的 OpenClaw 出现问题:
|
||||
- Agent 不断遗忘重要上下文
|
||||
- Skills 没有正确触发
|
||||
- Cron job 停止运行
|
||||
- Telegram 中持续出现上下文相关错误
|
||||
- 会话越长,token 消耗越多
|
||||
|
||||
最初以为是模型问题(当时使用 Kimi K2.5),后来切换到 Sonnet 4.6 有所改善,但**真正的问题在于 OpenClaw 的内存和上下文管理方式**。
|
||||
|
||||
---
|
||||
|
||||
## 四个修复方案
|
||||
|
||||
### Fix 1: 防止压缩(Compaction)时丢失重要上下文
|
||||
|
||||
**问题**: OpenClaw 有有限的上下文窗口,会话变长时会压缩旧消息为摘要,但重要的指令和细节会丢失。
|
||||
|
||||
**解决方案**:
|
||||
1. **Memory Flush** - 在压缩前将重要信息写入磁盘
|
||||
2. **Session Pruning** - 积极清理旧的上下文
|
||||
|
||||
> 核心原则:只在上下文窗口中的内容是临时的,存在磁盘上的才会保留。
|
||||
|
||||
---
|
||||
|
||||
### Fix 2: 让检索真正生效
|
||||
|
||||
**问题**: 重要信息虽然保存在磁盘上,但 Agent 不会主动查找,或者默认检索效果不够好。
|
||||
|
||||
**解决方案**:
|
||||
1. 安装并配置 **QMD** (Tobi Lutke 的混合搜索引擎,结合关键词匹配、向量语义搜索和 LLM 重排序)
|
||||
2. 在 AGENTS.md 顶部添加明确的检索指令,让 Agent 在执行任务前搜索相关上下文
|
||||
3. 建立 LEARNINGS.md 文件,记录每次犯错后的规则,防止重复相同错误
|
||||
|
||||
---
|
||||
|
||||
### Fix 3: Heartbeat 成本陷阱
|
||||
|
||||
**问题**: Heartbeat 每 30 分钟唤醒一次,每次都是完整的 API 调用,携带整个会话上下文(可能 10,000-15,000 tokens),非常昂贵。
|
||||
|
||||
**解决方案**:
|
||||
```json
|
||||
{
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"heartbeat": {
|
||||
"every": "30m",
|
||||
"lightContext": true,
|
||||
"model": "google/gemini-3.1-flash-lite-preview",
|
||||
"activeHours": {
|
||||
"start": "08:00",
|
||||
"end": "23:00"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
关键优化:
|
||||
- **lightContext: true** - 只加载 HEARTBEAT.md,而不是整个系统提示
|
||||
- **使用便宜模型** - 如 Gemini 3.1 Flash-Lite,甚至可以用本地模型
|
||||
- **限制活跃时间** - 不需要凌晨 3 点检查,将心跳调用减半
|
||||
- **保持 HEARTBEAT.md 精简** - 只保留最基本的检查清单
|
||||
|
||||
---
|
||||
|
||||
### Fix 4: 完整系统提示审计
|
||||
|
||||
**问题**: AGENTS.md、SOUL.md、TOOLS.md、IDENTITY.md、USER.md、HEARTBEAT.md、MEMORY.md 都会自动加载,作者从未审计过它们的大小和冗余。
|
||||
|
||||
**解决方案**: 让 Claude Code 审计整个系统提示,识别冗余、重复和不必要的部分并精简。
|
||||
|
||||
> 真正的问题不是换模型,而是裁剪不必要的系统文件。
|
||||
|
||||
---
|
||||
|
||||
## 总结
|
||||
|
||||
推荐的优化顺序:
|
||||
1. **Memory Flush** - 压缩前将重要上下文写入磁盘
|
||||
2. **Session Pruning** - 防止长会话拖拽无效上下文
|
||||
3. **Retrieval + 启动指令** - 升级 QMD,确保 Agent 明确搜索 prior context
|
||||
4. **Heartbeat 优化** - 轻量上下文、便宜模型、限制活跃时间、精简 HEARTBEAT.md
|
||||
5. **系统提示审计** - 裁剪冗余内容
|
||||
|
||||
**核心观点**: 构建 OpenClaw 时,选择的模型只是其次,**真正的价值在于确保 Agent 有良好的内存和上下文管理系统**。
|
||||
|
||||
---
|
||||
|
||||
## 相关资源
|
||||
|
||||
- [Ramya's article on agent memory debugging](https://x.com/i/article/2025615759771123712)
|
||||
- [OpenClaw memory docs](https://docs.openclaw.ai/concepts/memory)
|
||||
- [OpenClaw session pruning docs](https://docs.openclaw.ai/concepts/session-pruning)
|
||||
- [OpenClaw heartbeat docs](https://docs.openclaw.ai/gateway/heartbeat)
|
||||
- [QMD by Tobi Lutke](https://github.com/tobi/qmd)
|
||||
- [YouTube 视频教程](https://youtu.be/UTztjR4o7Y8)
|
||||
Reference in New Issue
Block a user