mirror of
https://github.com/mark3labs/kit.git
synced 2026-06-14 03:30:26 +00:00
fix: handle custom provider model persistence and bare model names
Two related fixes for --provider-url handling: 1. Don't restore custom/* models from preferences without --provider-url - When user runs with --provider-url, model defaults to custom/custom - If they switch models, custom/custom gets persisted to preferences - On next run without --provider-url, restoring custom/custom fails - Now we skip restoring custom/* models when no --provider-url is provided 2. Auto-prefix bare model names with custom/ when --provider-url is set - Users often provide just the model name (e.g., qwen3.5-35b-a3b) - This failed with 'invalid model format' error - Now auto-prefixed with custom/ for OpenAI-compatible endpoints
This commit is contained in:
+16
-1
@@ -680,9 +680,15 @@ func runNormalMode(ctx context.Context) error {
|
||||
// Restore persisted model preference when no explicit --model flag or
|
||||
// config file model is set. Precedence: CLI flag > config file > saved
|
||||
// preference > built-in default. This mirrors how themes are persisted.
|
||||
// Skip custom/* models unless --provider-url is also provided, since the
|
||||
// custom provider requires a URL that was only valid for the previous session.
|
||||
if !modelFlagChanged && !viper.InConfig("model") {
|
||||
if pref := ui.LoadModelPreference(); pref != "" {
|
||||
viper.Set("model", pref)
|
||||
if strings.HasPrefix(pref, "custom/") && viper.GetString("provider-url") == "" {
|
||||
// Don't restore custom models without a provider URL
|
||||
} else {
|
||||
viper.Set("model", pref)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,6 +709,15 @@ func runNormalMode(ctx context.Context) error {
|
||||
viper.Set("model", "custom/custom")
|
||||
}
|
||||
|
||||
// When --provider-url is set with an explicit --model that lacks a provider
|
||||
// prefix (no "/"), auto-prefix with "custom/" for OpenAI-compatible endpoints.
|
||||
if viper.GetString("provider-url") != "" && modelFlagChanged {
|
||||
model := viper.GetString("model")
|
||||
if model != "" && !strings.Contains(model, "/") {
|
||||
viper.Set("model", "custom/"+model)
|
||||
}
|
||||
}
|
||||
|
||||
// Load MCP configuration.
|
||||
mcpConfig, err := config.LoadAndValidateConfig()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user