charmbracelet/crush · error

failed to set small model: %w

Error message

failed to set small model: %w

What it means

overrideModels (internal/cmd/run.go:524) wraps an error from c.UpdatePreferredModel when setting the small model explicitly supplied via --small-model. Same write-failure family as the large-model variant, but for SelectedModelTypeSmall.

Source

Thrown at internal/cmd/run.go:524

			Provider: found.provider,
			Model:    found.modelID,
		}); err != nil {
			return fmt.Errorf("failed to set large model: %w", err)
		}
	}

	switch {
	case smallModel != "":
		found, err := validateModelMatches(smallMatches, smallModel, "small")
		if err != nil {
			return err
		}
		slog.Info("Overriding small model", "provider", found.provider, "model", found.modelID)
		if err := c.UpdatePreferredModel(ctx, ws.ID, config.ScopeWorkspace, config.SelectedModelTypeSmall, config.SelectedModel{
			Provider: found.provider,
			Model:    found.modelID,
		}); err != nil {
			return fmt.Errorf("failed to set small model: %w", err)
		}

	case largeModel != "":
		sm, err := c.GetDefaultSmallModel(ctx, ws.ID, largeProviderID)
		if err != nil {
			slog.Warn("Failed to get default small model", "error", err)
		} else if sm != nil {
			if err := c.UpdatePreferredModel(ctx, ws.ID, config.ScopeWorkspace, config.SelectedModelTypeSmall, *sm); err != nil {
				return fmt.Errorf("failed to set small model: %w", err)
			}
		}
	}

	return c.UpdateAgent(ctx, ws.ID)
}

// restoreModelFromSession reads the last assistant message in the
// session and, if it used a different provider/model than the current

View on GitHub (pinned to 7944b8e522)

Solutions

  1. Inspect the wrapped cause (network vs HTTP status)
  2. Retry the command
  3. Confirm the small model is valid and enabled in the provider config
  4. Check auth and workspace permissions
  5. Check server logs for the failing request
Defensive patterns

Strategy: retry

Try / catch

if err := runNonInteractive(...); err != nil {
	if strings.Contains(err.Error(), "failed to set small model") {
		// unwrap and classify; retry transient failures
	}
}

Prevention

When it happens

Trigger: --small-model given and matched exactly one provider model; the subsequent c.UpdatePreferredModel(..., SelectedModelTypeSmall, ...) call fails (network error, HTTP 4xx/5xx, canceled context).

Common situations: Server rejects the provider/model for small-model use; transient network drop; expired credentials; workspace config locked by another writer.

Related errors


AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29). Data as JSON: /api/errors/35cd9774e49229f5. Report an issue: GitHub.