{"record":{"id":"307db7297de5f2d7","repo":"sipeed/picoclaw","slug":"cannot-found-model-s-in-config","errorCode":null,"errorMessage":"cannot found model '%s' in config","messagePattern":"cannot found model '(.+?)' in config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/model/command.go","lineNumber":113,"sourceCode":"\t\tif !model.Enabled {\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Printf(\"%s- %s (%s)\\n\", marker, model.ModelName, model.Model)\n\t}\n}\n\nfunc setDefaultModel(configPath string, cfg *config.Config, modelName string) error {\n\t// Validate that the model exists in model_list\n\tmodelFound := false\n\tfor _, model := range cfg.ModelList {\n\t\tif model.Enabled && model.ModelName == modelName {\n\t\t\tmodelFound = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !modelFound && modelName != LocalModel {\n\t\treturn fmt.Errorf(\"cannot found model '%s' in config\", modelName)\n\t}\n\n\t// Update the default model\n\t// Clear old model field and set new model_name\n\toldModel := cfg.Agents.Defaults.ModelName\n\n\tcfg.Agents.Defaults.ModelName = modelName\n\n\t// Save config back to file\n\tif err := config.SaveConfig(configPath, cfg); err != nil {\n\t\treturn fmt.Errorf(\"failed to save config: %w\", err)\n\t}\n\n\tfmt.Printf(\"✓ Default model changed from '%s' to '%s'\\n\",\n\t\tformatModelName(oldModel), modelName)\n\tfmt.Println(\"\\nThe new default model will be used for all agent interactions.\")\n\n\treturn nil","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/model/command.go#L95-L131","documentation":"picoclaw model <alias> accepts only aliases present in model_list with enabled: true, plus the built-in alias local-model (the local VLLM default). This error means the argument matched no enabled entry. Note the message itself is ungrammatical ('cannot found') — it simply reports the model was not found. The match against ModelName is exact and case-sensitive.","triggerScenarios":"Typo or wrong case in the alias; the entry exists but has enabled: false; model_list is empty because the config was regenerated; the model was added under a different -n/--name alias (default custom-prefer); passing the provider model id (e.g. gpt-4o) instead of the local alias.","commonSituations":"Setting the default after models were re-added under new aliases; provider entries disabled during troubleshooting; users assuming the command takes the model id rather than the alias.","solutions":["Open the config and use the exact model_name of an enabled model_list entry","Re-enable the entry (enabled: true) or re-add it: picoclaw model add -n <alias>","For the built-in local VLLM default, use picoclaw model local-model","Remember the argument is the local alias, not the provider model id"],"exampleFix":"# before\n$ picoclaw model gpt-4o\ncannot found model 'gpt-4o' in config\n\n# after — use the alias from model_list (or local-model)\n$ picoclaw model custom-prefer","handlingStrategy":"validation","validationCode":"func enabledModelNames(cfg *config.Config) []string {\n  names := make([]string, 0, len(cfg.ModelList))\n  for _, m := range cfg.ModelList {\n    if m != nil && m.Enabled {\n      names = append(names, m.ModelName)\n    }\n  }\n  return names\n}\n\nif modelName != model.LocalModel && !slices.Contains(enabledModelNames(cfg), modelName) {\n  return fmt.Errorf(\"model %q not found; enabled models: %v (or use local-model)\", modelName, enabledModelNames(cfg))\n}","typeGuard":"func isModelNotFoundError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"in config\") && strings.Contains(err.Error(), \"model\")\n}","tryCatchPattern":"if err := setDefaultModel(configPath, cfg, name); err != nil {\n  if isModelNotFoundError(err) {\n    // show enabled model_name values and local-model, then re-ask for input\n  }\n  return err\n}","preventionTips":["Use the alias (model_name / -n value, default custom-prefer), not the provider model id","Check enabled: true on the entry before selecting it as default","picoclaw model local-model always works for the built-in VLLM default"],"tags":["model","config","cli","validation"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}