fix(llm): reset stale hosted endpoint when quick-switching away from Anthropic
apply_llm_provider_args now resets llm_endpoint to Ollama's local default when switching to a non-Anthropic provider without an explicit endpoint and the stored endpoint is still Anthropic's fixed hosted URL. Prevents a future per-use provider switch (SummaryPanel) that only sends `provider` from silently leaving llm_endpoint pointed at a third party for a provider that has no business talking to it.
This commit is contained in:
@@ -2023,6 +2023,12 @@ pub struct SetLlmProviderArgs {
|
||||
/// Anthropic's endpoint is fixed, not user-configurable (ADR-0011) — any
|
||||
/// `endpoint` argument is ignored for that provider so a stale endpoint left
|
||||
/// over from a previous "custom"/"ollama" selection can't leak through.
|
||||
/// Symmetrically, switching *away* from Anthropic without supplying a new
|
||||
/// endpoint resets to Ollama's own local default rather than silently
|
||||
/// keeping its fixed hosted URL around — otherwise a quick per-use provider
|
||||
/// switch (SummaryPanel, M3.3) that only sends `provider` could leave
|
||||
/// `llm_endpoint` pointed at a third party for a provider that has no
|
||||
/// business talking to it.
|
||||
fn apply_llm_provider_args(
|
||||
settings: &mut Settings,
|
||||
provider: &str,
|
||||
@@ -2034,6 +2040,8 @@ fn apply_llm_provider_args(
|
||||
settings.llm_endpoint = "https://api.anthropic.com".to_string();
|
||||
} else if let Some(endpoint) = endpoint {
|
||||
settings.llm_endpoint = endpoint;
|
||||
} else if settings.llm_endpoint == "https://api.anthropic.com" {
|
||||
settings.llm_endpoint = "http://localhost:11434".to_string();
|
||||
}
|
||||
if let Some(model) = model {
|
||||
settings.llm_model = model;
|
||||
@@ -3584,6 +3592,21 @@ mod tests {
|
||||
assert_eq!(settings.llm_model, "llama3.1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn apply_llm_provider_args_resets_endpoint_when_switching_away_from_anthropics_fixed_url() {
|
||||
// A per-use provider quick-switch (SummaryPanel, M3.3) only sends
|
||||
// `provider`, relying on whatever endpoint/model were last saved —
|
||||
// if that was Anthropic's fixed URL, switching to ollama must not
|
||||
// silently keep pointing at a third party.
|
||||
let mut settings = default_settings();
|
||||
settings.llm_provider = "anthropic".to_string();
|
||||
settings.llm_endpoint = "https://api.anthropic.com".to_string();
|
||||
|
||||
apply_llm_provider_args(&mut settings, "ollama", None, None);
|
||||
assert_eq!(settings.llm_provider, "ollama");
|
||||
assert_eq!(settings.llm_endpoint, "http://localhost:11434");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn privacy_self_check_only_enabled_sync_targets_join_the_allowlist() {
|
||||
let mut settings = default_settings();
|
||||
|
||||
Reference in New Issue
Block a user