Skip to content

feat(settings): decouple default model from project model — per-project model.name support #6052

Description

@Alex-ai-future

What would you like to be added?

Refactor the model persistence semantics to distinguish between a default model (global) and a project model (per-project override).

Proposed semantics:

  • ~/.qwen/settings.jsonmodel.name = default model (unchanged)
  • <project>/.qwen/settings.jsonmodel.name = project model override
  • If project-level model.name is set → use it for sessions in that project
  • If project-level model.name is empty/absent → fall back to the global default

Implementation: the read path (loadSettings().mergedresolveModelConfig) already supports workspace overriding user settings. The fix is in the write path — change getPersistScopeForModelSelection to default to Workspace scope instead of following modelProviders ownership. Add a --global flag to /model for explicitly setting the global default.

Why is this needed?

Different projects have different complexity and cost requirements. A simple scripting project may only need a lightweight model, while a complex architecture project needs a stronger one. Today, /model always writes to the scope that owns modelProviders (usually ~/.qwen/settings.json), so switching models in one project affects all projects globally. The only workaround is to duplicate the entire modelProviders config at project level, which is impractical.

Additional context

Related issues:

Code analysis:

  • Read path: modelConfigResolver.ts resolves settings.model.name from merged settings — workspace already overrides user. No changes needed.
  • Write path: modelProvidersScope.ts getPersistScopeForModelSelection returns the scope that owns modelProviders, which is usually User. This is the only thing blocking per-project model support.
  • Suggested change: default to Workspace scope, add --global flag for explicit user-level writes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions