apply_session_llm_overrides

Function apply_session_llm_overrides 

Source
pub fn apply_session_llm_overrides(
    cfg: &mut AppConfig,
    session_llm: Option<&SessionLlmConfig>,
    api_key_lookup: impl Fn(&str) -> Option<String>,
) -> EffectiveLlmConfig
Expand description

Apply session-scoped LLM overrides to an in-memory config and return the effective provider/model.

This function does not persist any changes to disk.

Behavior:

  • If the session overrides the provider, set cfg.llm.primary.
  • If the session overrides the model, apply it to the active provider’s config.
  • If the model override is obviously incompatible with the provider, ignore it and fall back.

api_key_lookup is adapter-supplied (GUI keychain, CLI env, etc.) and is only used when we need to create a provider config to attach a model override.