{"record":{"id":"949d236b026c0678","repo":"Mintplex-Labs/anything-llm","slug":"error-message-949d23","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"exception","errorClass":"RetryError","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/providers/foundry.js","lineNumber":192,"sourceCode":"      return await tooledStream(\n        this.client,\n        this.model,\n        messages,\n        functions,\n        this.#filterToolCallMarkup(eventHandler),\n        { provider: this }\n      );\n    } catch (error) {\n      console.error(error.message, error);\n      if (error instanceof OpenAI.AuthenticationError) throw error;\n      if (this.#isPrematureClose(error))\n        throw new Error(FoundryLLM.explainStreamError(error, this.model));\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  /**\n   * Create a non-streaming completion with tool calling support.\n   * Uses native tool calling when supported, otherwise falls back to UnTooled.\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)","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/providers/foundry.js#L174-L210","documentation":"Foundry provider's `stream()` catch-all for OpenAI errors that are NOT premature-close and NOT AuthenticationError: `RateLimitError`, `InternalServerError`, or any other `APIError` is wrapped as `RetryError(error.message)` — the framework's transient-retry signal. Foundry Local can emit RateLimitError when its local concurrency queue is full and InternalServerError when local inference fails without a premature-close signature.","triggerScenarios":"Foundry Local concurrency limit hit (RateLimitError on the local queue); Foundry Local internal process error that did not manifest as a premature close; bad model slug returned as APIError; transient local GPU error surfaced as InternalServerError.","commonSituations":"Multiple concurrent agent turns against one Foundry model; FOUNDRY_MODEL_PREF referencing a model Foundry Local does not serve; Foundry service partially degraded after a crash that did not produce a premature-close.","solutions":["Treat RetryError as transient and let the framework retry the turn.","Lower concurrency to a single in-flight Foundry request to avoid RateLimitError.","Verify FOUNDRY_MODEL_PREF is a model Foundry Local actually serves.","Inspect the Foundry Local logs for the underlying 5xx.","If persistent, restart Foundry Local and re-pull the model."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm the model slug is one Foundry Local serves before the turn.\nasync function assertFoundryModelAvailable(model) {\n  const caps = await new FoundryLLM(null, model).getModelCapabilities();\n  if (!caps) throw new Error(`Foundry Local does not serve model: ${model}`);\n}","typeGuard":"function isRetryableProviderError(e) {\n  return e instanceof OpenAI.RateLimitError || e instanceof OpenAI.InternalServerError || e instanceof OpenAI.APIError;\n}","tryCatchPattern":"// Honor RetryError; keep one in-flight request to dodge Foundry RateLimitError.\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":["Serialize requests to the local Foundry model to avoid queue-induced RateLimitError.","Confirm FOUNDRY_MODEL_PREF is a model Foundry Local actually serves.","Inspect Foundry Local logs for the underlying 5xx.","Retry transient failures with backoff; reserve auth as fatal."],"tags":["llm-provider","foundry","retry","rate-limit","local-inference","openai-sdk"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}