How to Fix OpenClaw’s Feishu API Quota Exhaustion with Self‑Repair

The article explains why OpenClaw users repeatedly hit Feishu’s free‑plan API call limit, analyzes the root cause in the probe logic, and provides a step‑by‑step self‑repair guide that adds a 5‑minute cache, adjusts health‑check intervals, and replaces the original probe file to cut API calls by over 90%.

Ubiquitous Tech
Ubiquitous Tech
Ubiquitous Tech
How to Fix OpenClaw’s Feishu API Quota Exhaustion with Self‑Repair

Problem Overview

Many OpenClaw users who connect the AI assistant to Feishu encounter the warning “Dear developer, your enterprise API call quota is about to be exhausted.” This happens even for users who make only occasional requests because the free personal Feishu plan limits the number of API calls per month.

The core issue is that OpenClaw’s Feishu integration calls the /open-apis/bot/v3/info endpoint every minute. For a single agent this amounts to:

1 call per minute × 1440 minutes per day = 1440 calls per day

1440 calls per day × 30 days ≈ 43,200 calls per month

These calls alone consume the entire free quota, and additional checks add further usage.

Root‑Cause Analysis

The excessive calls originate from three places in the codebase:

Monitor startup – extensions/feishu/src/monitor.ts invokes fetchBotOpenId()probeFeishu() each time the Feishu account starts.

Channel status check – extensions/feishu/src/channel.ts calls probeAccount()probeFeishu() during each channel health check.

Gateway health check – Configured via gateway.channelHealthCheckMinutes (default 30 min), which triggers the same probe regularly.

Solution 1 – Add a Cache Layer

The AI assistant generated an optimized probe.ts (named probe_optimized.ts) that introduces a 5‑minute TTL cache to store the result of probeFeishu(). The cache key is appId:appSecret, and the implementation automatically evicts entries when more than ten are stored.

import { createFeishuClient, type FeishuClientCredentials } from "./client.js";
import type { FeishuProbeResult } from "./types.js";
// Cache for bot probe results with TTL (5 minutes)
const botProbeCache = new Map<string, { result: FeishuProbeResult; timestamp: number }>();
const CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes cache
export async function probeFeishu(creds?: FeishuClientCredentials): Promise<FeishuProbeResult> {
  if (!creds?.appId || !creds?.appSecret) {
    return { ok: false, error: "missing credentials (appId, appSecret)" };
  }
  const cacheKey = `${creds.appId}:${creds.appSecret}`;
  const cached = botProbeCache.get(cacheKey);
  if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
    return cached.result;
  }
  try {
    const client = createFeishuClient(creds);
    const response = await (client as any).request({ method: "GET", url: "/open-apis/bot/v3/info", data: {} });
    if (response.code !== 0) {
      return { ok: false, appId: creds.appId, error: `API error: ${response.msg || `code ${response.code}`}` };
    }
    const bot = response.bot || response.data?.bot;
    const result: FeishuProbeResult = { ok: true, appId: creds.appId, botName: bot?.bot_name, botOpenId: bot?.open_id };
    botProbeCache.set(cacheKey, { result, timestamp: Date.now() });
    if (botProbeCache.size > 10) {
      const oldestKey = Array.from(botProbeCache.entries())
        .sort((a, b) => a[1].timestamp - b[1].timestamp)[0]?.[0];
      if (oldestKey) botProbeCache.delete(oldestKey);
    }
    return result;
  } catch (err) {
    return { ok: false, appId: creds.appId, error: err instanceof Error ? err.message : String(err) };
  }
}

Replacing the original extensions/feishu/src/probe.ts with this file eliminates redundant API calls within the cache window.

Solution 2 – Reduce Health‑Check Frequency

Modify openclaw.json to increase the health‑check interval from 30 minutes to 60 minutes:

{
  "gateway": {
    "channelHealthCheckMinutes": 60 // changed from 30
  }
}

Solution 3 – Optimize Monitor Startup Logic

Adjust monitor.ts to add a guard that prevents the probe from running on repeated starts. The AI assistant supplied a screenshot of the revised logic (omitted here for brevity).

Implementation Artifacts

The assistant also produced four supporting files: feishu_api_optimization.md – detailed technical analysis and full optimization plan. apply_feishu_optimization.sh – automation script to apply the changes. probe_optimized.ts – the cached probe implementation shown above. QUICK_FIX.md – quick‑start guide.

Before vs. After

Before : Every agent start and every health check triggers a fresh /open-apis/bot/v3/info request.

After : Calls within a 5‑minute window hit the cache, reducing API usage by more than 90 %.

Results

Post‑optimization logs (shown in the article’s screenshots) confirm a dramatic drop in request frequency. Users also note that Feishu’s free tier quota may have been reduced to 10 k calls per month, and a link to apply for higher limits is provided.

Conclusion

By adding a lightweight cache, extending health‑check intervals, and tightening monitor startup logic, OpenClaw’s Feishu integration can operate within the free‑plan quota, avoiding service interruptions without requiring external tooling.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

backendTypeScriptfeishuNode.jsCachingAI assistantOpenClawAPI quota
Ubiquitous Tech
Written by

Ubiquitous Tech

A ubiquitous public account for pirate enthusiasts, regularly sharing curated experiences, tech learning, and growth insights. Currently publishing articles on AI RAG customer service, AI MCP technology, and open-source design. Personal free Knowledge Planet: Awakening New World Programmer.

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.