{"record":{"id":"e5bd5b93a56f548f","repo":"Mintplex-Labs/anything-llm","slug":"error-message-e5bd5b","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"exception","errorClass":"RetryError","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/providers/cohere.js","lineNumber":116,"sourceCode":"\n    try {\n      return await tooledStream(\n        this.client,\n        this.model,\n        messages,\n        functions,\n        eventHandler,\n        { provider: this }\n      );\n    } catch (error) {\n      console.error(error.message, error);\n      if (error instanceof OpenAI.AuthenticationError) throw error;\n      if (\n        error instanceof OpenAI.RateLimitError ||\n        error instanceof OpenAI.InternalServerError ||\n        error instanceof OpenAI.APIError\n      ) {\n        throw new RetryError(error.message);\n      }\n      throw error;\n    }\n  }\n\n  async complete(messages, functions = []) {\n    const useNative = await this.supportsNativeToolCalling();\n\n    if (!useNative) {\n      return await UnTooled.prototype.complete.call(\n        this,\n        messages,\n        functions,\n        this.#handleFunctionCallChat.bind(this)\n      );\n    }\n\n    try {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/providers/cohere.js#L98-L134","documentation":"Cohere provider's `stream()` classifies OpenAI SDK errors. It logs `console.error(error.message, error)` first (so the full error object is in the server logs), then re-throws `AuthenticationError`, wraps `RateLimitError`/`InternalServerError`/`APIError` as `RetryError(error.message)`, and re-throws everything else. Cohere is reached through an OpenAI-compatible endpoint.","triggerScenarios":"Cohere 429 (trial/production key rate ceiling); Cohere 5xx; APIError from a model Cohere rejected (e.g. a deprecated command/aya slug); stream interrupted mid-flight and surfaced by the SDK as APIError.","commonSituations":"Cohere trial key quota exhausted; a non-Cohere model slug sent to the Cohere endpoint; regional Cohere outage; streaming connection dropped by an intermediary proxy.","solutions":["Inspect the server console — stream errors are console.error'd with the full object before rethrow.","Treat RetryError as transient: let the framework retry the turn.","On repeated 429, verify the COHERE_API_KEY tier and request volume; upgrade or throttle.","Confirm the model slug is a current Cohere model (command-r, command-r-plus, aya, etc.).","Check the Cohere status page for incidents."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify a Cohere model slug is current before streaming.\nconst KNOWN_COHERE_MODELS = new Set(['command-r','command-r-plus','aya','command-r-08-2024','command-r-plus-08-2024']);\nfunction assertCohereModel(model) {\n  if (!KNOWN_COHERE_MODELS.has(model)) throw new Error(`Unknown Cohere model: ${model}`);\n}","typeGuard":"function isRetryableProviderError(e) {\n  return e instanceof OpenAI.RateLimitError || e instanceof OpenAI.InternalServerError || e instanceof OpenAI.APIError;\n}","tryCatchPattern":"// Stream path logs to console.error — read it. Retry on RetryError, fail on auth.\ntry { return await provider.stream(messages, functions, handler); }\ncatch (e) {\n  if (e instanceof OpenAI.AuthenticationError) throw e;\n  if (e instanceof RetryError) return await backoffAndRetry();\n  throw e;\n}","preventionTips":["Check server logs — the stream path console.errors the full object before rethrow.","Keep the Cohere model slug current; command-r is rotated.","Respect trial-key limits; upgrade or throttle rather than hammering.","Separate auth (fatal) from rate/internal (retryable)."],"tags":["llm-provider","cohere","retry","rate-limit","streaming","openai-sdk"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}