Mintplex-Labs/anything-llm · error · RetryError
error.message
Error message
error.message
What it means
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.
Source
Thrown at server/utils/agents/aibitat/providers/cohere.js:116
try {
return await tooledStream(
this.client,
this.model,
messages,
functions,
eventHandler,
{ provider: this }
);
} catch (error) {
console.error(error.message, 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;
}
}
async complete(messages, functions = []) {
const useNative = await this.supportsNativeToolCalling();
if (!useNative) {
return await UnTooled.prototype.complete.call(
this,
messages,
functions,
this.#handleFunctionCallChat.bind(this)
);
}
try {View on GitHub (pinned to 526360e320)
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.
Defensive patterns
Strategy: retry
Validate before calling
// Verify a Cohere model slug is current before streaming.
const KNOWN_COHERE_MODELS = new Set(['command-r','command-r-plus','aya','command-r-08-2024','command-r-plus-08-2024']);
function assertCohereModel(model) {
if (!KNOWN_COHERE_MODELS.has(model)) throw new Error(`Unknown Cohere model: ${model}`);
} Type guard
function isRetryableProviderError(e) {
return e instanceof OpenAI.RateLimitError || e instanceof OpenAI.InternalServerError || e instanceof OpenAI.APIError;
} Try / catch
// Stream path logs to console.error — read it. Retry on RetryError, fail on auth.
try { return await provider.stream(messages, functions, handler); }
catch (e) {
if (e instanceof OpenAI.AuthenticationError) throw e;
if (e instanceof RetryError) return await backoffAndRetry();
throw e;
} Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/e5bd5b93a56f548f.
Report an issue: GitHub.