continuedev/continue · error · Error

No models available in assistant configuration

Error message

No models available in assistant configuration

What it means

Assistant.getModel throws when the assistant configuration has no models array or an empty one, so there is no default model to return when modelName is omitted.

Source

Thrown at packages/continue-sdk/typescript/src/Assistant.ts:33

   * Create a new Assistant instance
   *
   * @param config - The raw assistant configuration
   */
  constructor(config: any) {
    this.config = config;
  }

  /**
   * Get a model from the assistant by name
   *
   * @param modelName - The name of the model to find
   * @returns The model configuration or the first model if no name is provided
   */
  getModel(modelName?: string): string {
    const firstModel = this.config?.models?.[0];

    if (!this.config.models || !firstModel) {
      throw new Error("No models available in assistant configuration");
    }

    if (!modelName) {
      return firstModel.model;
    }

    // Look for a model matching the provided name
    const model = this.config.models.find(
      (m) =>
        m?.model === modelName ||
        m?.model.includes(modelName) ||
        m?.model.endsWith(`/${modelName}`),
    );

    if (!model) {
      throw new Error(
        `Model ${modelName} not found in assistant configuration`,
      );

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Check config.models exists and is non-empty before calling getModel
  2. Pass an explicit model name if you have one, though the first-model path is what fails here
  3. Fix the source of the assistant config so models are actually loaded (check hub fetch / mock setup)
  4. Fall back to a default model list when the config is empty

Example fix

// before
const model = assistant.getModel();

// after
const model = assistant.config?.models?.length
  ? assistant.getModel()
  : 'anthropic/claude-sonnet-4-5';
Defensive patterns

Strategy: type-guard

Validate before calling

if (!assistant.config?.models?.length) throw new Error('assistant has no models');

Type guard

function assistantHasModels(a: { config?: { models?: unknown[] } }): a is { config: { models: [unknown, ...unknown[] } } { return Array.isArray(a.config?.models) && a.config.models.length > 0; }

Try / catch

try { model = assistant.getModel(); } catch (e) { if (e.message.includes('No models available')) model = DEFAULT_MODEL; else throw e; }

Prevention

When it happens

Trigger: Calling assistant.getModel() (no argument) on an Assistant whose config.models is undefined, null, or [].

Common situations: Loading a hub assistant whose config failed to populate models, using Assistant.mock() or a partially-built config, or constructing Assistant manually without models.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/007ef535182e3a5a. Report an issue: GitHub.