{"record":{"id":"35cd9774e49229f5","repo":"charmbracelet/crush","slug":"failed-to-set-small-model-w","errorCode":null,"errorMessage":"failed to set small model: %w","messagePattern":"failed to set small model: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/run.go","lineNumber":524,"sourceCode":"\t\t\tProvider: found.provider,\n\t\t\tModel:    found.modelID,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set large model: %w\", err)\n\t\t}\n\t}\n\n\tswitch {\n\tcase smallModel != \"\":\n\t\tfound, err := validateModelMatches(smallMatches, smallModel, \"small\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tslog.Info(\"Overriding small model\", \"provider\", found.provider, \"model\", found.modelID)\n\t\tif err := c.UpdatePreferredModel(ctx, ws.ID, config.ScopeWorkspace, config.SelectedModelTypeSmall, config.SelectedModel{\n\t\t\tProvider: found.provider,\n\t\t\tModel:    found.modelID,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set small model: %w\", err)\n\t\t}\n\n\tcase largeModel != \"\":\n\t\tsm, err := c.GetDefaultSmallModel(ctx, ws.ID, largeProviderID)\n\t\tif err != nil {\n\t\t\tslog.Warn(\"Failed to get default small model\", \"error\", err)\n\t\t} else if sm != nil {\n\t\t\tif err := c.UpdatePreferredModel(ctx, ws.ID, config.ScopeWorkspace, config.SelectedModelTypeSmall, *sm); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to set small model: %w\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn c.UpdateAgent(ctx, ws.ID)\n}\n\n// restoreModelFromSession reads the last assistant message in the\n// session and, if it used a different provider/model than the current","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/run.go#L506-L542","documentation":"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.","triggerScenarios":"--small-model given and matched exactly one provider model; the subsequent c.UpdatePreferredModel(..., SelectedModelTypeSmall, ...) call fails (network error, HTTP 4xx/5xx, canceled context).","commonSituations":"Server rejects the provider/model for small-model use; transient network drop; expired credentials; workspace config locked by another writer.","solutions":["Inspect the wrapped cause (network vs HTTP status)","Retry the command","Confirm the small model is valid and enabled in the provider config","Check auth and workspace permissions","Check server logs for the failing request"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := runNonInteractive(...); err != nil {\n\tif strings.Contains(err.Error(), \"failed to set small model\") {\n\t\t// unwrap and classify; retry transient failures\n\t}\n}","preventionTips":["Verify the small model ID exists in the provider's model list","Run with stable network for multi-step config updates","Check server logs if writes repeatedly fail","Confirm workspace write permissions for the token"],"tags":["network","http","config","model-selection","go"],"backgroundTag":"config-write-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}