Skip to content

Fix cross-provider model selection creating invalid session provider/model pairs #2859

@dpshde

Description

@dpshde

Summary

Selecting a model from :model can persist an invalid (provider_id, model_id) pair when the chosen model belongs to a different provider than the current default provider.

This leaves Forge in a corrupted session state such as:

[session]
provider_id = "fireworks-ai"
model_id = "glm-5.1"

That pair is invalid because glm-5.1 belongs to the ZAI providers, not Fireworks.

Impact

  • The UI can show one provider while the selected model belongs to another provider.
  • Subsequent requests may route to an unexpected upstream.
  • Error messages become misleading because the persisted config no longer reflects a valid provider/model pair.

Repro

  1. Start Forge with a valid Fireworks provider selected.
  2. Use :model and select glm-5.1 from the all-provider model picker.
  3. Inspect ~/forge/.forge.toml.
  4. Observe an invalid pair like:
[session]
provider_id = "fireworks-ai"
model_id = "glm-5.1"

Expected

Selecting a model from another provider should also switch the active provider, or the selection should be rejected.

Actual

Forge updates only the model, leaving the previous provider in place.

Notes

A local patch in crates/forge_main/src/ui.rs fixes this by resolving the selected model's owning provider and calling provider activation when the model crosses provider boundaries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions