{"record":{"id":"8908ad866440431f","repo":"ruvnet/ruflo","slug":"rate-limit-8908ad","errorCode":"RATE_LIMIT","errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"exception","errorClass":"RateLimitError","httpStatus":429,"severity":"error","filePath":"v3/@claude-flow/providers/src/cohere-provider.ts","lineNumber":411,"sourceCode":"  }\n\n  private async handleErrorResponse(response: Response): Promise<never> {\n    const errorText = await response.text();\n    let errorData: { message?: string };\n\n    try {\n      errorData = JSON.parse(errorText);\n    } catch {\n      errorData = { message: errorText };\n    }\n\n    const message = errorData.message || 'Unknown error';\n\n    switch (response.status) {\n      case 401:\n        throw new AuthenticationError(message, 'cohere', errorData);\n      case 429:\n        throw new RateLimitError(message, 'cohere', undefined, errorData);\n      default:\n        throw new LLMProviderError(\n          message,\n          `COHERE_${response.status}`,\n          'cohere',\n          response.status,\n          response.status >= 500,\n          errorData\n        );\n    }\n  }\n}\n","sourceCodeStart":393,"sourceCodeEnd":424,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/providers/src/cohere-provider.ts#L393-L424","documentation":"CohereProvider maps HTTP 429 to RateLimitError (retryable). Cohere returns 429 when you exceed organization rate limits (requests or tokens per minute) or trial-tier caps. Note that this mapping passes retryAfter as undefined - the library does not extract Cohere's retry-after header here, so callers must apply their own backoff.","triggerScenarios":"A burst of provider.complete() calls exceeding the plan's RPM/TPM; many parallel completions from a fan-out workflow; load testing against a trial key.","commonSituations":"Concurrent batch generation without a concurrency limit; production traffic spike; plan too small for sustained throughput.","solutions":["Retry on RateLimitError with exponential backoff and jitter (start ~1 s, double, cap ~60 s)","Reduce concurrency (e.g. p-limit) and batch size to stay under RPM/TPM","Inspect the Cohere dashboard for current limits and upgrade the plan if throttling is sustained","Read error.details for Cohere's response body and honor any retry-after information it carries"],"exampleFix":"// before\nconst res = await provider.complete(req); // 429 propagates as RateLimitError\n\n// after - retry with backoff on RateLimitError\nasync function completeWithBackoff(provider, req, tries = 5) {\n  for (let i = 0; ; i++) {\n    try { return await provider.complete(req); }\n    catch (e) {\n      if (e instanceof RateLimitError && i < tries - 1) {\n        await new Promise(r => setTimeout(r, Math.min(60_000, 2 ** i * 1000)));\n        continue;\n      }\n      throw e;\n    }\n  }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"import { RateLimitError } from './types.js';\nfunction isCohereRateLimit(e: unknown): e is RateLimitError {\n  return e instanceof RateLimitError && e.provider === 'cohere';\n}","tryCatchPattern":"for (let attempt = 0; ; attempt++) {\n  try {\n    return await provider.complete(req);\n  } catch (e) {\n    if (isCohereRateLimit(e) && attempt < 5) {\n      // this mapping leaves retryAfter undefined - choose your own backoff\n      await new Promise(r => setTimeout(r, Math.min(60_000, 2 ** attempt * 1000) + Math.random() * 500));\n      continue;\n    }\n    throw e;\n  }\n}","preventionTips":["Cap concurrency below your Cohere RPM/TPM with p-limit or a queue","Add jittered exponential backoff for 429s rather than immediate retries","Track 429 rate per provider in metrics and alert before it becomes an outage"],"tags":["rate-limit","cohere","http-429","throttling","retry"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}