charmbracelet/crush · error
failed to set large model: %w
Error message
failed to set large model: %w
What it means
overrideModels (internal/cmd/run.go:509) wraps an error from c.UpdatePreferredModel when persisting the user's --model override (large model) into workspace config. The model string already validated and matched a provider; the failure is in the server-side write.
Source
Thrown at internal/cmd/run.go:509
providers := cfg.Providers.Copy()
largeMatches, smallMatches := findModelMatches(providers, largeModel, smallModel)
var largeProviderID string
if largeModel != "" {
found, err := validateModelMatches(largeMatches, largeModel, "large")
if err != nil {
return err
}
largeProviderID = found.provider
slog.Info("Overriding large model", "provider", found.provider, "model", found.modelID)
if err := c.UpdatePreferredModel(ctx, ws.ID, config.ScopeWorkspace, config.SelectedModelTypeLarge, config.SelectedModel{
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 != "":View on GitHub (pinned to 7944b8e522)
Solutions
- Read the wrapped error to see whether it is a network or HTTP-level failure
- Retry the command — the write may have failed transiently
- Verify the provider is enabled and the model still exists server-side
- Check auth credentials and workspace permissions
- Inspect server logs for the UpdatePreferredModel request
Defensive patterns
Strategy: retry
Try / catch
if err := runNonInteractive(...); err != nil {
if strings.Contains(err.Error(), "failed to set large model") {
// inspect errors.Unwrap(err); retry with backoff on network errors
}
} Prevention
- Validate the model string resolves (via `crush models`) before running
- Ensure stable connectivity for config writes
- Avoid concurrent writers mutating the same workspace config
- Keep auth tokens fresh in automation
When it happens
Trigger: After validateModelMatches succeeds for the large model, c.UpdatePreferredModel(ctx, ws.ID, ScopeWorkspace, SelectedModelTypeLarge, SelectedModel{...}) returns an error: network failure, HTTP error, validation rejection server-side, or canceled context.
Common situations: Server rejects the selected provider/model combination; concurrent config update conflicts; expired auth; connection dropped mid-request; server bug returning 5xx on UpdatePreferredClodel.
Related errors
- failed to set small model: %w
- failed to get config: %w
- failed to read response: %w
- failed to set config field: %w
- failed to remove config field: %w
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/84f172f2cd6ba9e4.
Report an issue: GitHub.