Skip to content

default_provider = "deepseek" with default_model = "deepseek-v4-pro" silently falls back to Claude on startup #448

Closed

Description

@wushilong

When the config has:

 [provider]
 default_model = "deepseek-v4-pro"
 default_provider = "deepseek"

And DEEPSEEK_API_KEY is set (but no OPENROUTER_API_KEY), jcode silently ignores the DeepSeek default and starts with claude-sonnet-4 instead.

Root Cause:

In crates/jcode-base/src/provider/mod.rs, set_config_default_model (line 1301) resolves the config provider selection to OpenAiCompatibleProfile("deepseek"), whose active_provider() is ActiveProvider::OpenRouter. It then calls set_model_on_provider_with_credential_modes(OpenRouter, ...) which triggers the generic OpenRouter rebind logic (line 1006-1026). This logic decides the current DeepSeek profile runtime needs to be replaced with a plain OpenRouter API-key runtime — and fails because OPENROUTER_API_KEY is not set. The error is silently caught, so the active provider stays as the auto-detected default (Claude).

Fix location: crates/jcode-base/src/provider/mod.rs:1330-1378

When ConfigProviderSelection::OpenAiCompatibleProfile(profile_id), the code should short-circuit to set_model_on_openai_compatible_profile(profile, model) instead of going through the generic set_model_on_provider_with_credential_modes(ActiveProvider::OpenRouter, ...) path.

• resolve_config_provider_selection (in selection.rs:441) determines the selection
• ConfigProviderSelection::active_provider() (in selection.rs:13) maps all OpenAiCompatibleProfile to ActiveProvider::OpenRouter
• set_model_on_provider_with_credential_modes (line 885) for OpenRouter has complex rebind logic at lines 1006-1026 that tries to replace profile runtimes


Release Information: v0.36.0 (commit e18e983) – released July 5, 2026

Activity

  1. changed the title [-]https://github.com/1jehuang/jcode/issues[/-] [+]`default_provider = "deepseek"` with `default_model = "deepseek-v4-pro"` silently falls back to Claude on startup[/+] on Jul 5, 2026
  2. added
    bug
    priority: high
    triage: fixed-pending-release
    autonomous: clear
    on Jul 6, 2026
  3. 1jehuang commented on Jul 6, 2026

    @1jehuang
    Owner

    Triage: confirmed, and your root-cause analysis was exactly right - thank you, it made this a fast fix.

    Fixed on master in 2da4528: set_config_default_model now short-circuits ConfigProviderSelection::OpenAiCompatibleProfile to set_model_on_openai_compatible_profile, binding the DeepSeek profile runtime directly instead of routing through the generic OpenRouter path (whose rebind logic required OPENROUTER_API_KEY and silently failed).

    Added a regression test (test_config_default_provider_deepseek_applies_without_openrouter_key) that reproduces the exact config from this report and fails without the fix. A follow-up commit (af1df25) applies the same treatment to named [providers.<name>] config profiles.

    Will close automatically on the next release.

  4. 1jehuang commented on Jul 7, 2026

    @1jehuang
    Owner

    Released in v0.37.0. Run jcode update to get it.

  5. removed
    triage: fixed-pending-release
    on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugpriority: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions