Skip to content

fix(config): honor default_model in ResolveModelWithFallback before iterating providers#3994

Merged
esengine merged 1 commit into
esengine:main-v2from
JesonChou:fix/default-model-fallback-3801
Jun 11, 2026
Merged

fix(config): honor default_model in ResolveModelWithFallback before iterating providers#3994
esengine merged 1 commit into
esengine:main-v2from
JesonChou:fix/default-model-fallback-3801

Conversation

@JesonChou

Copy link
Copy Markdown
Contributor

Problem

Fixes #3801

When the user configures a default_model (e.g. glm5) but that model is not the first provider in iteration order, ResolveModelWithFallback ignores it and falls back to the first configured provider instead. This causes new conversations to be assigned the wrong model (e.g. deepseek-v4-flash), forcing the user to manually switch every time.

Root Cause

ResolveModelWithFallback had only two paths:

  1. Direct resolve the given ref
  2. Iterate providers in order and pick the first configured one

There was no check for the user's DefaultModel between step 1 and step 2.

Fix

Added a DefaultModel preference check between the direct-resolve and the provider-iteration fallback:

  • Try the configured DefaultModel first (skip if the stale ref was the DefaultModel — it already failed above, so retrying is pointless)
  • Skip the DefaultModel provider if it has no API key configured (mirrors the existing Configured() gate on the provider-iteration path)
  • Fall through to provider iteration only if DefaultModel is unavailable

Changes

  • internal/config/config.go — 3-line block added to ResolveModelWithFallback
  • internal/config/model_fallback_test.go — new test TestResolveModelWithFallbackHonorsDefaultModel covering empty ref, stale ref, and keyless-default → next-configured chaining

Verification

…terating providers

When a tab's stored model ref is stale, empty, or points to a removed provider, ResolveModelWithFallback jumped straight to scanning [[providers]] in order and picked the first one with a configured API key. Since deepseek-flash is first in the built-in defaults, it always won — even when the user had configured a different default_model.

Fix: insert a middle step that tries c.DefaultModel before resorting to the provider iteration. This ensures the user's explicit preference is honored whenever the default provider is configured and has a valid API key.

Fixes esengine#3801.
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development config Configuration & setup (internal/config) labels Jun 11, 2026
@esengine esengine merged commit 5a487a5 into esengine:main-v2 Jun 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration & setup (internal/config) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 新增对话模型自动选择了deepseek

2 participants