{"record":{"id":"512f79ac474147cb","repo":"Mintplex-Labs/anything-llm","slug":"sambanova-chat-no-results","errorCode":null,"errorMessage":"SambaNova chat: No results!","messagePattern":"SambaNova chat: No results!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/providers/sambanova.js","lineNumber":41,"sourceCode":"  }\n\n  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) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/providers/sambanova.js#L23-L59","documentation":"In SambaNovaProvider.#handleFunctionCallChat (sambanova.js:33-45), the UnTooled chat path asserts the response has a `choices` property and throws \"SambaNova chat: No results!\" when it is absent. SambaNova occasionally returns an error/empty payload that the SDK surfaces as a fulfilled object lacking choices.","triggerScenarios":"Calling the UnTooled (non-native) function-call chat path and SambaNova returns an object without a `choices` key, e.g. an error-shaped body, a model-not-found payload, or an empty {} from a gateway.","commonSituations":"Wrong or unsupported model id, an invalid/expired SAMBANOVA_LLM_API_KEY that SambaNova surfaces as a 200-with-error-body, or an upstream gateway returning a non-standard envelope.","solutions":["Verify SAMBANOVA_LLM_API_KEY is valid and not expired.","Confirm the model id is one SambaNova actually serves.","Log the raw result object to see the actual envelope SambaNova returned.","If the payload is a known error shape, surface it instead of the generic message.","Retry once; transient malformed responses do occur."],"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: unknown[] }} */\nfunction hasChoices(r) {\n  return (\n    !!r &&\n    typeof r === \"object\" &&\n    Array.isArray(/** @type {any} */ (r).choices)\n  );\n}","tryCatchPattern":"try {\n  return await provider.complete(messages, functions);\n} catch (e) {\n  if (/SambaNova chat: No results/.test(e.message)) {\n    // log the raw response and retry once; malformed envelopes are often transient\n    await new Promise((r) => setTimeout(r, 1000));\n    return await provider.complete(messages, functions);\n  }\n  throw e;\n}","preventionTips":["Validate the API key and model id before the first call.","Defensively check `choices` presence and length before indexing, both in your wrapper.","Log the full raw response when this fires so the real envelope is captured.","Prefer SambaNova model ids from the official catalog."],"tags":["sambanova","response-parsing","config","model-selection"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}