{"record":{"id":"68db5a876df1b587","repo":"ruvnet/ruflo","slug":"hourly-cost-limit-exceeded-this-hourlycost-amo","errorCode":null,"errorMessage":"Hourly cost limit exceeded: $${this.hourlyCost.amount.toFixed(2)} / $${this.config.costLimitPerHour}","messagePattern":"Hourly cost limit exceeded: \\$(.+?) / \\$(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/integration/src/provider-adapter.ts","lineNumber":943,"sourceCode":"    if (provider.status === 'rate-limited') {\n      throw new Error(`Provider ${provider.id} is rate limited`);\n    }\n  }\n\n  /**\n   * Check cost limits\n   */\n  private checkCostLimits(): void {\n    const now = Date.now();\n\n    // Reset hourly cost if needed\n    if (now >= this.hourlyCost.resetAt) {\n      this.hourlyCost.amount = 0;\n      this.hourlyCost.resetAt = now + 3600000;\n    }\n\n    if (this.hourlyCost.amount >= this.config.costLimitPerHour!) {\n      throw new Error(\n        `Hourly cost limit exceeded: $${this.hourlyCost.amount.toFixed(2)} / $${this.config.costLimitPerHour}`\n      );\n    }\n  }\n\n  /**\n   * Get cached result\n   */\n  private getCachedResult(\n    task: Task,\n    providerId: string\n  ): ExecutionResult | null {\n    const cacheKey = `${providerId}:${task.id}:${task.description}`;\n    const cached = this.cache.get(cacheKey);\n\n    if (cached && Date.now() - cached.timestamp < this.config.cacheTTL!) {\n      this.emit('cache-hit', { taskId: task.id, providerId });\n      return cached.result;","sourceCodeStart":925,"sourceCodeEnd":961,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/provider-adapter.ts#L925-L961","documentation":"ProviderAdapter tracks accumulated spend in a rolling hour (hourlyCost); once the amount reaches config.costLimitPerHour, checkCostLimits refuses every further execution until the window resets (resetAt = last reset + 3600000ms). It is a hard cost circuit-breaker, not a warning.","triggerScenarios":"Any execution path that runs checkCostLimits after this hour's tracked spend has reached costLimitPerHour — the very next call throws, regardless of how cheap the target provider is.","commonSituations":"costLimitPerHour set below the workload's real burn rate (e.g. a $1 cap with token-heavy models), an expensive model selected for bulk jobs, or many workers sharing a single adapter instance and therefore one hourly budget.","solutions":["If the budget genuinely allows, raise config.costLimitPerHour","Otherwise wait for the hourly window to reset (up to 1h from the last reset)","Route to cheaper providers/models or reduce token usage per task so hourly burn stays under the cap","Track spend upstream and throttle submissions before the adapter's breaker trips"],"exampleFix":"// before\nconst adapter = new ProviderAdapterManager({ costLimitPerHour: 1 }); // trips minutes into a bulk run\n\n// after\nconst adapter = new ProviderAdapterManager({ costLimitPerHour: 25 }); // sized to measured hourly burn","handlingStrategy":"validation","validationCode":"// Mirror the adapter's rolling-hour accounting so you stop before it does\nconst spend = { amount: 0, resetAt: Date.now() + 3600_000 };\nfunction canAfford(estimatedCost: number, cap: number): boolean {\n  if (Date.now() >= spend.resetAt) {\n    spend.amount = 0;\n    spend.resetAt = Date.now() + 3600_000;\n  }\n  return spend.amount + estimatedCost < cap * 0.9; // 10% headroom\n}","typeGuard":null,"tryCatchPattern":"try {\n  await adapter.execute(task);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Hourly cost limit exceeded')) {\n    // pause the queue until the hour resets; do not create new adapter instances to dodge the cap\n  }\n  throw e;\n}","preventionTips":["Estimate per-task cost and enforce your own 90% threshold before submission","Alert when hourly spend crosses 50%/80% of the cap","Treat tripping the breaker as a budgeting bug, not a runtime fault to retry"],"tags":["cost-limit","budget","configuration","spend-cap"],"backgroundTag":"budget-limit-exceeded","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}