{"record":{"id":"de832d7b6d105c82","repo":"Mintplex-Labs/anything-llm","slug":"sambanova-chat-no-results-length","errorCode":null,"errorMessage":"SambaNova chat: No results length!","messagePattern":"SambaNova chat: No results length!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/providers/sambanova.js","lineNumber":43,"sourceCode":"  get client() {\n    return this._client;\n  }\n\n  get supportsAgentStreaming() {\n    return true;\n  }\n\n  async #handleFunctionCallChat({ messages = [] }) {\n    return await this.client.chat.completions\n      .create({\n        model: this.model,\n        messages,\n      })\n      .then((result) => {\n        if (!result.hasOwnProperty(\"choices\"))\n          throw new Error(\"SambaNova chat: No results!\");\n        if (result.choices.length === 0)\n          throw new Error(\"SambaNova chat: No results length!\");\n        return result.choices[0].message.content;\n      });\n  }\n\n  async #handleFunctionCallStream({ messages = [] }) {\n    return await this.client.chat.completions.create({\n      model: this.model,\n      stream: true,\n      messages,\n    });\n  }\n\n  async stream(messages, functions = [], eventHandler = null) {\n    const useNative = this.supportsNativeToolCalling();\n\n    if (!useNative) {\n      return await UnTooled.prototype.stream.call(\n        this,","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/providers/sambanova.js#L25-L61","documentation":"Right after the choices-existence check (sambanova.js:40-41), SambaNovaProvider.#handleFunctionCallChat asserts result.choices.length > 0 and throws \"SambaNova chat: No results length!\" when the array is empty. This means SambaNova accepted the request and returned a well-formed envelope but produced zero choice objects.","triggerScenarios":"SambaNova returns a 200 with an empty choices array, typically from content filtering, a degenerate prompt, or a model that emitted nothing for the turn.","commonSituations":"A prompt tripping SambaNova's safety filter, a max_tokens of 0, an overloaded model returning an empty generation, or an unsupported/incompatible model id.","solutions":["Adjust the prompt to avoid filtered/empty generations and retry.","Verify max_tokens / generation parameters are sane.","Confirm the model id supports chat completions on SambaNova.","Log the full response to confirm choices is genuinely empty and not mis-parsed.","Retry once; empty generations are often transient."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (!process.env.SAMBANOVA_LLM_API_KEY)\n  throw new Error(\"SAMBANOVA_LLM_API_KEY is not set.\");","typeGuard":"/** @param {unknown} r\n * @returns {r is { choices: { length: number }[] }} */\nfunction hasNonEmptyChoices(r) {\n  return (\n    !!r &&\n    typeof r === \"object\" &&\n    Array.isArray(/** @type {any} */ (r).choices) &&\n    /** @type {any} */ (r).choices.length > 0\n  );\n}","tryCatchPattern":"try {\n  return await provider.complete(messages, functions);\n} catch (e) {\n  if (/No results length/.test(e.message)) {\n    // empty generation: tweak the prompt or retry once\n    await new Promise((r) => setTimeout(r, 1000));\n    return await provider.complete(messages, functions);\n  }\n  throw e;\n}","preventionTips":["Sanitize prompts to avoid tripping SambaNova safety filters.","Confirm max_tokens > 0 and a chat-capable model id.","Check choices length before reading choices[0] in your own code.","Retry once; empty generations are frequently transient."],"tags":["sambanova","response-parsing","content-filter","model-selection"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}