charmbracelet/crush · error

failed to override models: %w

Error message

failed to override models: %w

What it means

Wraps errors from overrideModels(), which applies --model/--large-model/--small-model CLI overrides to the workspace before the run. The wrapped error indicates the requested model/provider could not be applied.

Source

Thrown at internal/cmd/run.go:189

// runNonInteractive executes the agent via the server and streams output
// to stdout.
func runNonInteractive(
	ctx context.Context,
	c *client.Client,
	ws *proto.Workspace,
	prompt, largeModel, smallModel string,
	hideSpinner bool,
	continueSessionID string,
	useLast bool,
) error {
	slog.Info("Running in non-interactive mode")

	ctx, cancel := context.WithCancel(ctx)
	defer cancel()

	if largeModel != "" || smallModel != "" {
		if err := overrideModels(ctx, c, ws, largeModel, smallModel); err != nil {
			return fmt.Errorf("failed to override models: %w", err)
		}
	}

	var (
		spinner   *format.Spinner
		stderrTTY bool
		progress  bool
	)

	stderrTTY = term.IsTerminal(os.Stderr.Fd())
	progress = ws.Config.Options.Progress == nil || *ws.Config.Options.Progress

	if !hideSpinner && stderrTTY {
		t := styles.ThemeForProvider(ws.Config.Models[config.SelectedModelTypeLarge].Provider)

		spinner = format.NewSpinner(ctx, cancel, anim.Settings{
			Size:        10,
			Label:       "Generating",

View on GitHub (pinned to 7944b8e522)

Solutions

  1. Check the exact model id with `crush models` and use provider/model format
  2. Ensure the provider of the overridden model is configured with credentials
  3. Update crush so the model catalog is current (catwalk snapshot refresh)
  4. Remove the --model flag to fall back to configured defaults

Example fix

// before
crush run --model claude-sonnet-4 "fix the bug"
// after
crush run --model anthropic/claude-sonnet-4 "fix the bug"
Defensive patterns

Strategy: validation

Validate before calling

// verify model id format and availability before overriding
if largeModel != "" && !strings.Contains(largeModel, "/") {
	return fmt.Errorf("--model must be in provider/model form, got %q", largeModel)
}
if !modelCatalog.Contains(largeModel) {
	return fmt.Errorf("unknown model %q; run `crush models` to list ids", largeModel)
}

Try / catch

if err := overrideModels(ctx, c, ws, largeModel, smallModel); err != nil {
	return fmt.Errorf("failed to override models: %w (run `crush models` for valid ids)", err)
}

Prevention

When it happens

Trigger: Running `crush run --model provider/model` (or large/small variants) where overrideModels(ctx, c, ws, largeModel, smallModel) fails — usually an invalid model id or unknown provider.

Common situations: Typo in `provider/model` id; model removed or renamed in the model catalog; model belongs to a provider that has no credentials configured; model string missing the provider prefix.

Related errors


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