OpenClaw Feishu Quota Guard
Use this skill when OpenClaw is connected to Feishu/Lark and a user reports that free quota or paid API budget is draining unexpectedly.
This skill is based on a short Bilibili video about OpenClaw + Feishu quota burn and cross-checked against current OpenClaw docs. The likely failure mode is not "chat usage" itself, but background traffic:
- - OpenClaw heartbeat runs that still hit a cloud model
- Feishu webhook or custom gateway health probes that accidentally trigger model work
Read references/source-notes.md only if you need the exact source-backed assumptions.
Quick Start
- 1. Run the bundled fixer in the native shell for that machine:
- macOS/Linux:
bash scripts/run-once.sh --dry-run
- Windows PowerShell:
powershell -ExecutionPolicy Bypass -File scripts/run-once.ps1 --dry-run
- Any OS with Python:
python scripts/apply_feishu_quota_fix.py --dry-run
- 2. If the summary only reports official/current OpenClaw heartbeat settings, run the same command without
--dry-run. - If the summary reports custom webhook or gateway health routes, keep the automatic heartbeat fix and then inspect those files manually.
- Restart the relevant process and verify from logs that repeated probes no longer trigger expensive model calls.
Default behavior of the bundled fixer
The bundled fixer makes only safe automatic changes to standard OpenClaw config:
- - INLINECODE5
- INLINECODE6
- INLINECODE7
- if
target is missing, set INLINECODE9
If you want a full stop instead of throttling, run:
CODEBLOCK0
On Windows:
CODEBLOCK1
That sets:
Workflow
1. Confirm the topology first
Do not patch blindly.
- - If the install uses the bundled/current Feishu plugin, treat this as a heartbeat-cost problem first.
- If the install uses a webhook bridge or custom gateway, inspect the health route before touching heartbeat settings.
Useful search terms:
- - INLINECODE11
- INLINECODE12
- INLINECODE13
- INLINECODE14
- INLINECODE15
- INLINECODE16
- INLINECODE17
- INLINECODE18
- INLINECODE19
2. Fix path A: reduce or cheapen OpenClaw heartbeat work
Use this path for the official/current plugin, or anytime logs show scheduled heartbeat runs causing the spend.
Focus on:
- -
~/.openclaw/openclaw.json or the workspace config the user actually runs - INLINECODE21
- INLINECODE22
- INLINECODE23
Preferred order of fixes:
- 1. First run the bundled fixer in throttle mode.
It applies the lowest-risk cost reduction settings supported by current OpenClaw heartbeat docs.
- 2. If heartbeat is not needed, disable it or make the heartbeat prompt effectively empty.
OpenClaw docs say an effectively empty
HEARTBEAT.md skips the heartbeat run and saves API calls.
- 3. If heartbeat is needed, lower frequency first.
Safe first move: change
every from a short interval to
1h or longer.
- 4. Reduce token and context cost.
Prefer
lightContext: true,
isolatedSession: true when appropriate, and avoid sending heartbeat output anywhere unless the user really wants it.
- 5. Route heartbeat away from an expensive cloud model.
If the install supports a separate heartbeat model, use a cheap or local model for heartbeat-only checks.
- 6. Keep
HEARTBEAT.md tiny.
A bloated checklist wastes tokens every run.
When editing configs manually, prefer minimal changes like:
CODEBLOCK2
Only add a heartbeat-specific local model if the config format in that install already supports it.
3. Fix path B: stop Feishu/webhook health probes from touching the model
Use this path for older installs, custom bridges, or any codebase where /health, /ready, or webhook verification ends up invoking OpenClaw chat/model logic.
Goal: liveness checks must return a cheap static success unless the user explicitly wants an end-to-end synthetic test.
Preferred order of fixes:
- 1. Do not auto-patch arbitrary app code unless the relevant route is obvious and isolated.
- Separate liveness from end-to-end checks.
/health should usually return a static
200 OK plus lightweight process info.
- 3. If a real downstream check is required, cache the successful result.
A 24-hour cache is a good default for "bot still works" validation when the alternative is paying every minute.
- 4. Never let Feishu verification or heartbeat probes call the main chat pipeline.
- If a custom bridge currently pings the model every 60 seconds, patch that route first before changing user-facing chat behavior.
For route handlers, acceptable outcomes are:
- - static INLINECODE34
- cached status object
- cheap local state check
Avoid:
- - calling the main message handler
- creating a new OpenClaw chat turn
- invoking the paid model just to answer a health probe
4. Verify after the patch
After editing:
- 1. Restart the OpenClaw gateway, plugin host, or custom bridge.
- Watch logs for 3-5 minutes.
- Confirm one of these outcomes:
- heartbeat frequency dropped to the intended interval
-
/health still gets hit, but no model invocation follows
- quota burn rate stops climbing abnormally
If the user is on Docker, check container logs rather than assuming host paths.
Guardrails
- - Do not change unrelated chat routing.
- Do not remove webhook verification unless the user is intentionally leaving webhook mode.
- Prefer the smallest patch that stops repeated paid calls.
- If the system mixes official Feishu config with custom gateway code, patch the custom health route first and then review heartbeat settings.
- If the bundled fixer already solved the standard heartbeat cost issue, say so clearly and stop there unless custom webhook code still appears in the scan.
OpenClaw Feishu 配额守卫
当 OpenClaw 连接到飞书,且用户报告免费配额或付费 API 预算异常消耗时,使用此技能。
此技能基于一个关于 OpenClaw + 飞书 配额消耗的简短 Bilibili 视频,并与当前 OpenClaw 文档进行了交叉验证。可能的故障模式并非聊天使用本身,而是后台流量:
- - OpenClaw 心跳运行仍然命中云模型
- 飞书 webhook 或自定义网关健康检查意外触发模型工作
仅在需要基于来源的精确假设时,才阅读 references/source-notes.md。
快速开始
- 1. 在该机器的原生 shell 中运行捆绑的修复工具:
- macOS/Linux:bash scripts/run-once.sh --dry-run
- Windows PowerShell:powershell -ExecutionPolicy Bypass -File scripts/run-once.ps1 --dry-run
- 任何操作系统(使用 Python):python scripts/apply
feishuquota_fix.py --dry-run
- 2. 如果摘要仅报告官方/当前的 OpenClaw 心跳设置,则运行不带 --dry-run 的相同命令。
- 如果摘要报告了自定义 webhook 或网关健康路由,则保留自动心跳修复,然后手动检查这些文件。
- 重启相关进程,并从日志中验证重复的探测不再触发昂贵的模型调用。
捆绑修复工具的默认行为
捆绑的修复工具仅对标准 OpenClaw 配置进行安全的自动更改:
- - agents.defaults.heartbeat.every = 1h
- agents.defaults.heartbeat.lightContext = true
- agents.defaults.heartbeat.isolatedSession = true
- 如果 target 缺失,则设置 target = none
如果您希望完全停止而不是限制,请运行:
bash
bash scripts/run-once.sh --mode disable
在 Windows 上:
powershell
powershell -ExecutionPolicy Bypass -File scripts/run-once.ps1 --mode disable
这将设置:
- - agents.defaults.heartbeat.every = 0m
工作流程
1. 首先确认拓扑结构
不要盲目打补丁。
- - 如果安装使用了捆绑/当前的飞书插件,首先将其视为心跳成本问题。
- 如果安装使用了 webhook 桥接或自定义网关,在修改心跳设置之前先检查健康路由。
有用的搜索关键词:
- - channels.feishu
- @openclaw/feishu
- heartbeat
- HEARTBEAT.md
- connectionMode
- webhook
- verificationToken
- health
- gateway
2. 修复路径 A:减少或降低 OpenClaw 心跳工作的成本
对于官方/当前插件,或任何时候日志显示定时心跳运行导致支出时,使用此路径。
重点关注:
- - ~/.openclaw/openclaw.json 或用户实际运行的工作区配置
- agents.defaults.heartbeat
- agents.list[].heartbeat
- HEARTBEAT.md
推荐的修复顺序:
- 1. 首先以限制模式运行捆绑的修复工具。
它应用当前 OpenClaw 心跳文档支持的最低风险成本降低设置。
- 2. 如果不需要心跳,则禁用心跳或使心跳提示有效为空。
OpenClaw 文档说明,有效为空的 HEARTBEAT.md 会跳过心跳运行并节省 API 调用。
- 3. 如果需要心跳,首先降低频率。
安全的首次操作:将 every 从短间隔改为 1h 或更长。
- 4. 减少令牌和上下文成本。
在适当时优先使用 lightContext: true、isolatedSession: true,并避免将心跳输出发送到任何地方,除非用户确实需要。
- 5. 将心跳路由远离昂贵的云模型。
如果安装支持单独的心跳模型,使用廉价或本地模型仅用于心跳检查。
- 6. 保持 HEARTBEAT.md 简短。
臃肿的检查清单每次运行都会浪费令牌。
手动编辑配置时,优先进行最小更改,例如:
jsonc
{
agents: {
defaults: {
heartbeat: {
every: 1h,
lightContext: true,
target: none
}
}
}
}
仅当该安装中的配置格式已支持时,才添加心跳专用的本地模型。
3. 修复路径 B:阻止飞书/webhook 健康探测触及模型
对于旧版安装、自定义桥接或任何 /health、/ready 或 webhook 验证最终调用 OpenClaw 聊天/模型逻辑的代码库,使用此路径。
目标:活跃度检查必须返回廉价的静态成功响应,除非用户明确需要端到端的综合测试。
推荐的修复顺序:
- 1. 除非相关路由明显且独立,否则不要自动修补任意应用代码。
- 将活跃度检查与端到端检查分开。
/health 通常应返回静态的 200 OK 加上轻量级进程信息。
- 3. 如果需要真正的下游检查,缓存成功结果。
当替代方案是每分钟付费时,24 小时缓存是机器人仍在工作验证的良好默认值。
- 4. 绝不让飞书验证或心跳探测调用主聊天管道。
- 如果自定义桥接当前每 60 秒 ping 一次模型,在更改面向用户的聊天行为之前,先修补该路由。
对于路由处理器,可接受的结果是:
避免:
- - 调用主消息处理器
- 创建新的 OpenClaw 聊天轮次
- 仅为了回答健康探测而调用付费模型
4. 补丁后验证
编辑后:
- 1. 重启 OpenClaw 网关、插件主机或自定义桥接。
- 观察日志 3-5 分钟。
- 确认以下结果之一:
- 心跳频率降至预期间隔
- /health 仍然被访问,但没有模型调用随之发生
- 配额消耗率停止异常增长
如果用户使用 Docker,请检查容器日志,而不是假设主机路径。
防护措施
- - 不要更改无关的聊天路由。
- 除非用户有意离开 webhook 模式,否则不要移除 webhook 验证。
- 优先选择能阻止重复付费调用的最小补丁。
- 如果系统混合了官方飞书配置和自定义网关代码,先修补自定义健康路由,然后审查心跳设置。
- 如果捆绑的修复工具已解决标准心跳成本问题,请明确说明并在此停止,除非扫描中仍出现自定义 webhook 代码。