Mintplex-Labs/anything-llm · error · RetryError

error.message

Error message

error.message

What it means

Cerebras provider's `complete()` classifies OpenAI SDK errors. `OpenAI.AuthenticationError` is re-thrown unchanged (auth failures are fatal, not retryable). `RateLimitError`, `InternalServerError`, or any other `APIError` is wrapped as `RetryError(error.message)` — the framework's signal that the failure is transient and the outer agent loop should retry the turn. Anything else (network, programming bug) is re-thrown unchanged. Cerebras is an OpenAI-compatible inference service tuned for high throughput.

Source

Thrown at server/utils/agents/aibitat/providers/cerebras.js:165

        messages,
        functions,
        this.getCost.bind(this),
        { provider: this }
      );

      if (result.retryWithError) {
        return this.complete([...messages, result.retryWithError], functions);
      }

      return result;
    } catch (error) {
      if (error instanceof OpenAI.AuthenticationError) throw error;
      if (
        error instanceof OpenAI.RateLimitError ||
        error instanceof OpenAI.InternalServerError ||
        error instanceof OpenAI.APIError
      ) {
        throw new RetryError(error.message);
      }
      throw error;
    }
  }

  /**
   * Updates the stored usage metrics from a provider response.
   * Override in subclasses to handle provider-specific usage formats.
   * @param {Object} usage - The usage object from the provider response
   * @param {Object} time_info - The time info object from the provider response (Cerebras specific)
   */
  recordUsage(usage = {}, time_info = {}) {
    // assume start time
    let duration = (Date.now() - this._requestStartTime) / 1000;
    const promptTokens = usage.prompt_tokens || 0;
    const completionTokens = usage.completion_tokens || 0;
    if (time_info?.completion_time) duration = time_info.completion_time;

View on GitHub (pinned to 526360e320)

Solutions

  1. Let the framework's RetryError handling re-attempt the turn — that is the intended response to RetryError.
  2. If it repeatedly fails with 429, lower the request rate, shorten the context, or upgrade the Cerebras tier.
  3. Verify CEREBRAS_MODEL_PREF is a slug Cerebras currently serves (it rotates model names).
  4. Confirm CEREBRAS_API_KEY is valid — if not, you would see AuthenticationError, not RetryError.
  5. Check the Cerebras status page for an ongoing incident.
Defensive patterns

Strategy: retry

Validate before calling

// Budget-aware preflight: estimate tokens and skip if obviously over the Cerebras TPM limit.
function wouldExceedCerebrasTpm(estimatedTokens, tpmLimit) {
  return typeof tpmLimit === 'number' && estimatedTokens > tpmLimit * 0.9;
}

Type guard

function isRetryableProviderError(e) {
  return e instanceof OpenAI.RateLimitError
      || e instanceof OpenAI.InternalServerError
      || e instanceof OpenAI.APIError;
}

Try / catch

// Outer agent loop: honor RetryError, surface auth immediately.
try {
  return await provider.complete(messages, functions);
} catch (e) {
  if (e instanceof OpenAI.AuthenticationError) throw e;     // fatal
  if (e instanceof RetryError) await backoffAndRetry();      // transient
  else throw e;
}

Prevention

When it happens

Trigger: Cerebras returns 429 (tokens-per-minute or requests-per-minute ceiling hit); 5xx from the Cerebras gateway; transient APIError mid-completion (e.g. the model briefly unavailable); a bad or deprecated model slug surfaced as APIError.

Common situations: Cerebras free-tier TPM limit hit on a long context window; CEREBRAS_MODEL_PREF pointing at a model Cerebras rotated out; a brief Cerebras platform outage; mismatched model name against the Cerebras catalog.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/25b50a42c541c7a0. Report an issue: GitHub.