From e0222407579222874977b010461e16a4332d40b6 Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Mon, 27 Apr 2026 16:40:10 +0800 Subject: [PATCH] feat(agent): model sync improvements - deduplication and offline status - Add Offline status to ModelStatus enum - Sync marks all models offline first, then activates found ones - Deduplicate by model name (ignoring provider) - Deactivate orphaned models (offline -> deprecated) - Add models_offline and models_deactivated to SyncModelsResponse - Add deduplicate_existing_models() for cleanup - Rename upsert_model to upsert_model_by_name --- libs/models/agents/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/models/agents/mod.rs b/libs/models/agents/mod.rs index dbd3eee..aa1f970 100644 --- a/libs/models/agents/mod.rs +++ b/libs/models/agents/mod.rs @@ -67,12 +67,15 @@ impl std::str::FromStr for ModelCapability { } } -/// Model or model-version availability status. Stored as `"active"` or -/// `"deprecated"`. +/// Model or model-version availability status. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ModelStatus { + /// Model is available and can be used. Active, + /// Model is no longer available from the provider. Deprecated, + /// Model was not found in the last upstream sync (offline). + Offline, } impl std::fmt::Display for ModelStatus { @@ -80,6 +83,7 @@ impl std::fmt::Display for ModelStatus { match self { ModelStatus::Active => write!(f, "active"), ModelStatus::Deprecated => write!(f, "deprecated"), + ModelStatus::Offline => write!(f, "offline"), } } } @@ -90,6 +94,7 @@ impl std::str::FromStr for ModelStatus { match s { "active" => Ok(ModelStatus::Active), "deprecated" => Ok(ModelStatus::Deprecated), + "offline" => Ok(ModelStatus::Offline), _ => Err("unknown model status"), } }