Mintplex-Labs/anything-llm · error · Error

SambaNova chat: No results length!

Error message

SambaNova chat: No results length!

What it means

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.

Source

Thrown at server/utils/agents/aibitat/providers/sambanova.js:43

  get client() {
    return this._client;
  }

  get supportsAgentStreaming() {
    return true;
  }

  async #handleFunctionCallChat({ messages = [] }) {
    return await this.client.chat.completions
      .create({
        model: this.model,
        messages,
      })
      .then((result) => {
        if (!result.hasOwnProperty("choices"))
          throw new Error("SambaNova chat: No results!");
        if (result.choices.length === 0)
          throw new Error("SambaNova chat: No results length!");
        return result.choices[0].message.content;
      });
  }

  async #handleFunctionCallStream({ messages = [] }) {
    return await this.client.chat.completions.create({
      model: this.model,
      stream: true,
      messages,
    });
  }

  async stream(messages, functions = [], eventHandler = null) {
    const useNative = this.supportsNativeToolCalling();

    if (!useNative) {
      return await UnTooled.prototype.stream.call(
        this,

View on GitHub (pinned to 526360e320)

Solutions

  1. Adjust the prompt to avoid filtered/empty generations and retry.
  2. Verify max_tokens / generation parameters are sane.
  3. Confirm the model id supports chat completions on SambaNova.
  4. Log the full response to confirm choices is genuinely empty and not mis-parsed.
  5. Retry once; empty generations are often transient.
Defensive patterns

Strategy: type-guard

Validate before calling

if (!process.env.SAMBANOVA_LLM_API_KEY)
  throw new Error("SAMBANOVA_LLM_API_KEY is not set.");

Type guard

/** @param {unknown} r
 * @returns {r is { choices: { length: number }[] }} */
function hasNonEmptyChoices(r) {
  return (
    !!r &&
    typeof r === "object" &&
    Array.isArray(/** @type {any} */ (r).choices) &&
    /** @type {any} */ (r).choices.length > 0
  );
}

Try / catch

try {
  return await provider.complete(messages, functions);
} catch (e) {
  if (/No results length/.test(e.message)) {
    // empty generation: tweak the prompt or retry once
    await new Promise((r) => setTimeout(r, 1000));
    return await provider.complete(messages, functions);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/de832d7b6d105c82. Report an issue: GitHub.