@link-assistant/hive-mind 1.69.16 → 1.69.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @link-assistant/hive-mind
2
2
 
3
+ ## 1.69.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 46422f1: Increase the default `HIVE_MIND_USAGE_API_CACHE_TTL_MS` from 10 → 13 minutes so the Claude Usage API (`/api/oauth/usage`) is queried less frequently and we stop tripping the upstream "Resets in 3m Xs" rate-limit message. Operators can still override the value via the environment variable. Resolves #1798.
8
+
3
9
  ## 1.69.16
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/hive-mind",
3
- "version": "1.69.16",
3
+ "version": "1.69.17",
4
4
  "description": "AI-powered issue solver and hive mind for collaborative problem solving",
5
5
  "main": "src/hive.mjs",
6
6
  "type": "module",
@@ -528,12 +528,14 @@ export const getClaudeEnv = (options = {}) => {
528
528
  // Cache TTL configurations (in milliseconds)
529
529
  // The Usage API (Claude limits) has stricter rate limiting than regular APIs
530
530
  // See: https://github.com/link-assistant/hive-mind/issues/1074
531
+ // See: https://github.com/link-assistant/hive-mind/issues/1798
531
532
  export const cacheTtl = {
532
533
  // General API cache TTL (GitHub API, etc.)
533
534
  api: parseIntWithDefault('HIVE_MIND_API_CACHE_TTL_MS', 3 * 60 * 1000), // 3 minutes
534
- // Claude Usage API cache TTL - must be at least 20 minutes to avoid rate limiting
535
- // The API returns null values when called too frequently
536
- usageApi: parseIntWithDefault('HIVE_MIND_USAGE_API_CACHE_TTL_MS', 10 * 60 * 1000), // 10 minutes
535
+ // Claude Usage API cache TTL - increased by 3 minutes (from 10 13) per issue #1798
536
+ // because users still hit "Resets in 3m xs" rate-limit responses. The API
537
+ // returns null values or 429 when called too frequently.
538
+ usageApi: parseIntWithDefault('HIVE_MIND_USAGE_API_CACHE_TTL_MS', 13 * 60 * 1000), // 13 minutes
537
539
  // System metrics cache TTL (RAM, CPU, disk)
538
540
  system: parseIntWithDefault('HIVE_MIND_SYSTEM_CACHE_TTL_MS', 2 * 60 * 1000), // 2 minutes
539
541
  };
@@ -1271,17 +1271,20 @@ export function formatCodexLimitsSection(codexLimits, codexError = null, options
1271
1271
  * Values are loaded from config.lib.mjs which supports environment variable overrides.
1272
1272
  *
1273
1273
  * IMPORTANT: The Claude Usage API has stricter rate limiting than regular APIs.
1274
- * Calling it more frequently than every 20 minutes may result in null values being returned.
1274
+ * Calling it too frequently may return null values or a 429 "Resets in Xm Xs" error.
1275
+ * Default raised from 10 → 13 minutes in issue #1798 (the previous 10-minute TTL still
1276
+ * occasionally tripped a ~3-minute rate-limit window).
1275
1277
  * See: https://github.com/link-assistant/hive-mind/issues/1074
1278
+ * See: https://github.com/link-assistant/hive-mind/issues/1798
1276
1279
  *
1277
1280
  * Configurable via environment variables:
1278
1281
  * - HIVE_MIND_API_CACHE_TTL_MS: General API cache TTL (default: 180000 = 3 minutes)
1279
- * - HIVE_MIND_USAGE_API_CACHE_TTL_MS: Claude Usage API cache TTL (default: 1200000 = 20 minutes)
1282
+ * - HIVE_MIND_USAGE_API_CACHE_TTL_MS: Claude Usage API cache TTL (default: 780000 = 13 minutes)
1280
1283
  * - HIVE_MIND_SYSTEM_CACHE_TTL_MS: System metrics cache TTL (default: 120000 = 2 minutes)
1281
1284
  */
1282
1285
  export const CACHE_TTL = {
1283
1286
  API: cacheTtl.api, // 3 minutes for regular API calls (GitHub)
1284
- USAGE_API: cacheTtl.usageApi, // 20 minutes for Claude Usage API (rate limited)
1287
+ USAGE_API: cacheTtl.usageApi, // 13 minutes for Claude Usage API (rate limited)
1285
1288
  SYSTEM: cacheTtl.system, // 2 minutes for system metrics (RAM, CPU, disk)
1286
1289
  };
1287
1290
 
@@ -1345,9 +1348,10 @@ export function resetLimitCache() {
1345
1348
 
1346
1349
  export async function getCachedClaudeLimits(verbose = false) {
1347
1350
  const cache = getLimitCache();
1348
- // Use USAGE_API TTL (20 minutes) for Claude limits to avoid rate limiting
1349
- // The Claude Usage API returns null values when called too frequently
1351
+ // Use USAGE_API TTL (13 min by default, see issue #1798) for Claude limits to avoid rate limiting.
1352
+ // The Claude Usage API returns null values or 429 errors when called too frequently.
1350
1353
  // See: https://github.com/link-assistant/hive-mind/issues/1074
1354
+ // See: https://github.com/link-assistant/hive-mind/issues/1798
1351
1355
  const cached = cache.get('claude', CACHE_TTL.USAGE_API);
1352
1356
  if (cached) {
1353
1357
  if (verbose) console.log('[VERBOSE] /limits-cache: Using cached Claude limits (TTL: ' + Math.round(CACHE_TTL.USAGE_API / 60000) + ' minutes)');
@@ -1365,8 +1369,9 @@ export async function getCachedClaudeLimits(verbose = false) {
1365
1369
  cache.set('claude', result, CACHE_TTL.USAGE_API);
1366
1370
  } else if (result.error && result.error.includes('Rate limited')) {
1367
1371
  // Cache rate-limit errors to prevent hammering the API
1368
- // Use the same 20-minute TTL as successful responses
1372
+ // Use the same USAGE_API TTL (13 min by default) as successful responses
1369
1373
  // See: https://github.com/link-assistant/hive-mind/issues/1446
1374
+ // See: https://github.com/link-assistant/hive-mind/issues/1798
1370
1375
  cache.set('claude-rate-limited', result, CACHE_TTL.USAGE_API);
1371
1376
  if (verbose) console.log('[VERBOSE] /limits-cache: Cached rate-limit error for ' + Math.round(CACHE_TTL.USAGE_API / 60000) + ' minutes');
1372
1377
  }
@@ -5,8 +5,8 @@
5
5
  * the args before they are forwarded to /solve, /hive (or /task --split). When
6
6
  * set, the bot:
7
7
  * 1. Fetches usage limits for the selected tool (Claude or Codex) using the
8
- * shared cached helpers in limits.lib.mjs (TTL: 20 minutes for the usage
9
- * API to avoid rate limiting).
8
+ * shared cached helpers in limits.lib.mjs (USAGE_API TTL: 13 minutes by
9
+ * default — see issue #1798 — to avoid rate limiting).
10
10
  * 2. Embeds a compact "Limits at start" snapshot below the infoBlock so the
11
11
  * starting/executing message shows the user how much budget they had at
12
12
  * the moment the command was queued.