Skip to content

Commit 78f96b1

Browse files
zenshanda-ai
andcommitted
feat: add model registry replacement
Co-Authored-By: Anda Bot <noreply@anda.bot>
1 parent 664e8bd commit 78f96b1

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to the Anda project will be documented in this file.
44

5+
## [0.13.2] — 2026-06-14
6+
7+
### Added — anda_engine v0.13.2
8+
9+
- **Runtime model registry replacement** — Added `Models::replace` to atomically replace a model registry from another `Models` instance, enabling callers to reload model configuration without preserving stale labels from the previous registry.
10+
11+
512
## [0.13.1] — 2026-06-14
613

714
### Changed — anda_engine v0.13.1

anda_engine/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "anda_engine"
33
description = "Agents engine for Anda -- an AI agent framework built with Rust, powered by ICP and TEEs."
44
repository = "https://github.com/ldclabs/anda/tree/main/anda_engine"
55
publish = true
6-
version = "0.13.1"
6+
version = "0.13.2"
77
edition.workspace = true
88
keywords.workspace = true
99
categories.workspace = true

anda_engine/src/model.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@ impl Models {
203203
}
204204
}
205205

206+
/// Replaces this registry with a clone of another [`Models`] instance.
207+
pub fn replace(&self, other: &Models) {
208+
let model = other.model.load_full();
209+
let models: HashMap<String, Vec<Model>> = HashMap::from_iter(
210+
other
211+
.models
212+
.load()
213+
.iter()
214+
.map(|(k, v)| (k.clone(), v.clone())),
215+
);
216+
self.model.store(model);
217+
self.models.store(Arc::new(models));
218+
}
219+
206220
/// Builds a registry from model configs by registering every resolved label.
207221
pub fn from_configs(configs: &[ModelConfig], http_client: reqwest::Client) -> Self {
208222
let models = Self::default();
@@ -1422,6 +1436,21 @@ mod tests {
14221436
"primary-v2"
14231437
);
14241438

1439+
let replacement = Models::default();
1440+
replacement.set_model(test_model("replacement-primary").with_labels(vec!["next".into()]));
1441+
let replaced = Models::default();
1442+
replaced.set("old".to_string(), test_model("old"));
1443+
replaced.replace(&replacement);
1444+
assert!(!replaced.contains("old"));
1445+
assert!(replaced.contains("next"));
1446+
assert_eq!(
1447+
replaced.get_model().unwrap().model_name(),
1448+
"replacement-primary"
1449+
);
1450+
1451+
replacement.set("later".to_string(), test_model("later"));
1452+
assert!(!replaced.contains("later"));
1453+
14251454
let configs = vec![
14261455
ModelConfig {
14271456
labels: vec!["primary".to_string()],

0 commit comments

Comments
 (0)