{"record":{"id":"a5fc0f9212b6ece4","repo":"RocketChat/Rocket.Chat","slug":"error-ai-provider-empty-response","errorCode":"error-ai-provider-empty-response","errorMessage":"error-ai-provider-empty-response","messagePattern":"error-ai-provider-empty-response","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/ai-search.ts","lineNumber":380,"sourceCode":"\n\t\tconst answerMessages = await getSearchAnswerMessagesForUser(this.userId, messages);\n\t\ttry {\n\t\t\tconst answer = await AISearch.answer({\n\t\t\t\tquery,\n\t\t\t\tmessages: answerMessages,\n\t\t\t});\n\n\t\t\treturn API.v1.success(answer);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : '';\n\t\t\tif (message === 'error-ai-not-enabled') {\n\t\t\t\tthrow new Meteor.Error('error-ai-not-enabled');\n\t\t\t}\n\t\t\tif (message === 'error-ai-provider-not-configured') {\n\t\t\t\tthrow new Meteor.Error('error-ai-provider-not-configured');\n\t\t\t}\n\t\t\tif (message === 'error-ai-provider-empty-response') {\n\t\t\t\tthrow new Meteor.Error('error-ai-provider-empty-response');\n\t\t\t}\n\t\t\tthrow new Meteor.Error('error-ai-provider-request-failed');\n\t\t}\n\t},\n);\n","sourceCodeStart":362,"sourceCodeEnd":386,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/api/v1/ai-search.ts#L362-L386","documentation":"Returned by POST ai.search.answer when the LLM provider responded successfully but with no usable content, and the AI service surfaced this as error-ai-provider-empty-response. The HTTP call itself worked; the model simply returned an empty completion (empty choices array or blank text).","triggerScenarios":"POST /api/v1/ai.search.answer where the model returns an empty completion: overly aggressive max_tokens (e.g. 0 or 1), content filters swallowing the answer, or a misbehaving OpenAI-compatible endpoint returning 200 with empty choices.","commonSituations":"Self-hosted LLM gateways (Ollama/LiteLLM proxies) that return 200 with empty content under load; max output tokens misconfigured near zero; safety filters triggered by the query phrasing; model version that streams an empty first chunk and terminates.","solutions":["Retry the request once: empty completions are frequently transient","Inspect the provider's response logs to confirm the completion body was actually empty","Increase or correct max_tokens / output limits for the answer-generation model","If reproducible with the same query, switch or update the answer-generation model"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* ai.search.answer */ } catch (e) {\n  if (e.error === 'error-ai-provider-empty-response') {\n    await backoff(1000);\n    return retryOnce(); // empty completions are often transient\n  }\n}","preventionTips":["Retry empty completions once with backoff before reporting failure","Monitor provider-side logs for recurring empty bodies; fix max_tokens if near zero"],"tags":["ai-search","llm","empty-response","retry","rocket-chat"],"backgroundTag":"llm-empty-completion","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}