{"record":{"id":"dc93bb1b49459048","repo":"Mintplex-Labs/anything-llm","slug":"foundry-local-crashed-trying-to-reply-to-this-mess","errorCode":null,"errorMessage":"Foundry Local crashed trying to reply to this message. You should change the message or try again.","messagePattern":"Foundry Local crashed trying to reply to this message\\. You should change the message or try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/providers/foundry.js","lineNumber":136,"sourceCode":"\n  async #handleFunctionCallChat({ messages = [] }) {\n    await this.#assertContextLimits();\n    return await this.client.chat.completions\n      .create({\n        model: this.model,\n        messages,\n        max_completion_tokens: FoundryLLM.promptWindowLimit(this.model),\n      })\n      .then((result) => {\n        if (!result.hasOwnProperty(\"choices\"))\n          throw new Error(\"Microsoft Foundry Local chat: No results!\");\n        if (result.choices.length === 0)\n          throw new Error(\"Microsoft Foundry Local chat: No results length!\");\n        return result.choices[0].message.content;\n      })\n      .catch((e) => {\n        if (this.#isPrematureClose(e))\n          throw new Error(FoundryLLM.explainStreamError(e, this.model));\n        return null;\n      });\n  }\n\n  async #handleFunctionCallStream({ messages = [] }) {\n    await this.#assertContextLimits();\n    return await this.client.chat.completions.create({\n      model: this.model,\n      stream: true,\n      messages,\n      max_completion_tokens: FoundryLLM.promptWindowLimit(this.model),\n    });\n  }\n\n  /**\n   * Stream a chat completion with tool calling support.\n   * Uses native tool calling when supported, otherwise falls back to UnTooled.\n   */","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/agents/aibitat/providers/foundry.js#L118-L154","documentation":"Failure sentinel in FoundryLLM.#handleFunctionCallChat: the local Foundry inference process crashed or terminated mid-reply, so no completion content is available; the message advises changing the input or retrying since the crash is typically input- or load-dependent.","triggerScenarios":"Foundry Local provider crashes while generating a chat completion for a user message.","commonSituations":"This error is raised at runtime in server/utils/agents/aibitat/providers/foundry.js. It occurs when the required configuration for this provider is missing or invalid (unset environment variables, empty API key or base path), when the external service is unreachable or returns an unexpected response, or when invalid input reaches the call site. To prevent it, validate the relevant provider settings and environment variables at startup and confirm the service is reachable before this code path executes.","solutions":["Retry the message or rephrase it.","Restart the Foundry Local service and confirm the model is loaded.","Check Foundry Local logs for the crash reason."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}