#11304: feishu: cache bot info to reduce probe API calls (feishu set low quota)
channel: feishu
stale
size: S
Cluster:
Feishu Integration Enhancements
Fixes #10549
Fixes #10041
## Summary
The gateway's periodic health refresh (`HEALTH_REFRESH_INTERVAL_MS = 60000`) calls `probeFeishu()` every 60 seconds, which hits `GET /open-apis/bot/v3/info`
each time. On Feishu's free tier the monthly "basic API call" quota is 10,000 — the probe alone burns through ~43,200 calls/month (1,440/day), exhausting the
quota in under a week and causing Error 99991403.
### Why Feishu needs this and other channels don't
All channels (Discord, Telegram, Slack, etc.) share the same 60-second probe pattern, but only Feishu enforces a hard **monthly API call cap**. Discord,
Telegram, and Slack use per-second rate limits with no monthly ceiling, so their probes are effectively free. Feishu's free tier counts every server API call
toward a shared 10,000/month budget.
## What this PR does
After the first successful `bot/v3/info` call per account, cache the bot metadata (`botName`, `botOpenId`) in memory. Subsequent probes validate connectivity
via the Lark SDK's internal `TokenManager.getTenantAccessToken()`, which:
- Returns from in-memory cache most of the time (~2 h TTL)
- On cache miss, refreshes via `POST /auth/v3/tenant_access_token/internal` — an auth infrastructure endpoint that does not count toward the basic API call
quota
| | Before | After |
|---|---|---|
| `bot/v3/info` calls/day | ~1,440 | 1 (startup) |
| Token refreshes/day | ~12 (SDK internal) | ~12 (unchanged, quota-exempt) |
| Monthly quota usage | ~43,200 | ~1 |
No change to bot metadata freshness — bot name and open_id are stable per app lifecycle and re-fetched on every gateway restart.
## Test plan
- [x] `pnpm build` passes
- [x] `pnpm lint` passes (0 warnings, 0 errors)
- [x] `pnpm test` — 840 passed, 8 failed (pre-existing memory/LanceDB failures on main, unrelated)
- [x] Deployed to live server, verified `openclaw channels status --probe` reports Feishu `works`
- [x] Confirmed zero `bot/v3/info` calls in logs after initial startup probe (monitored 2+ minutes)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Implements TTL-based caching of Feishu bot info to reduce API quota consumption from ~43,200 calls/month to ~30 calls/month. After the first successful probe, cached bot metadata is reused and connectivity is validated via the SDK's internal token manager (quota-exempt). The cache key now properly uses `appId:domain` to handle credential rotations, and token validation explicitly checks for non-empty strings before returning success. Includes LRU-style eviction with a 64-entry cap and a `clearBotInfoCache()` export for testing.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with low risk
- The implementation addresses the Feishu quota exhaustion issue with a well-reasoned caching strategy. Previous review concerns about token validation and cache key design have been resolved (explicit token validation on lines 63-66, credential-based cache key on lines 35-37). The fall-through pattern properly invalidates stale cache entries. Minor risk remains from relying on internal SDK APIs (`tokenManager.getTenantAccessToken()`), but this is mitigated by explicit validation and fallback to full probe on errors.
- No files require special attention
<sub>Last reviewed commit: ac74ea3</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#16337: feat(feishu): sync community plugin updates from clawdbot-feishu v0...
by graydawnc · 2026-02-14
78.0%
#10095: Add rate limiting to probeFeishu function
by Cotch22 · 2026-02-06
77.7%
#21484: fix(feishu): scope message deduplication by accountId to support mu...
by guanyu-zhang · 2026-02-20
76.2%
#21576: fix(feishu): stop ghost messages from corrupting active conversatio...
by xuanyue202 · 2026-02-20
74.7%
#10513: feat(feishu): add quota optimization flags
by BigUncle · 2026-02-06
74.4%
#15671: fix(feishu): Credentials check bug of Feishu bitable tools when usi...
by zxh0916 · 2026-02-13
74.2%
#9756: fix(feishu): prevent message redelivery during long AI generation
by cszhouwei · 2026-02-05
73.6%
#22675: feishu: move message dedup to just before dispatch
by zijiegeng · 2026-02-21
72.8%
#13761: fix(feishu): silently degrade when contact permission is missing
by echoVic · 2026-02-11
72.5%
#9268: Fix: Register feishu as official channel in CHAT_CHANNEL_ORDER
by vishaltandale00 · 2026-02-05
70.4%