Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(config): retire managed tier slugs from persisted config

Steven Enamakel2b184b893caf
diff --git a/crates/openhuman-core/src/agent/cost.rs b/crates/openhuman-core/src/agent/cost.rs
index 77a12da245..9f0df7d50c 100644
--- a/crates/openhuman-core/src/agent/cost.rs
+++ b/crates/openhuman-core/src/agent/cost.rs
@@ -76,7 +76,8 @@ const LEGACY_TIER_ROWS: &[&str] = &crate::config::LEGACY_TIER_MODELS;
/// local model names — is a custom/BYO-provider model. Used by trace exporters
/// to stamp model provenance (`gen_ai.provider` = "managed" | "custom").
pub(crate) fn is_managed_tier(model: &str) -> bool {
- crate::platform::cost::route::route_for_model(model) == crate::platform::cost::route::CostRoute::Managed
+ crate::platform::cost::route::route_for_model(model)
+ == crate::platform::cost::route::CostRoute::Managed
|| model.trim().starts_with("hint:")
}
diff --git a/crates/openhuman-core/src/agent/cost_tests.rs b/crates/openhuman-core/src/agent/cost_tests.rs
index 40024d4e5b..c81c046491 100644
--- a/crates/openhuman-core/src/agent/cost_tests.rs
+++ b/crates/openhuman-core/src/agent/cost_tests.rs
@@ -25,7 +25,13 @@ fn lookup_pricing_maps_role_aliases_and_retired_tiers_onto_the_default() {
// Old cost records and `hint:*` routes ran on the managed default; they
// must price from its row, not via the $3/$15 fallback, which would inflate
// cost and could trip budget gates.
- for model in ["hint:chat", "hint:burst", "burst-v1", "vision-v1", "reasoning-v1"] {
+ for model in [
+ "hint:chat",
+ "hint:burst",
+ "burst-v1",
+ "vision-v1",
+ "reasoning-v1",
+ ] {
let p = lookup_pricing(model);
assert_eq!(p.model, FLASH, "{model} must price as the managed default");
}
diff --git a/crates/openhuman-core/src/agent/harness/definition_tests.rs b/crates/openhuman-core/src/agent/harness/definition_tests.rs
index f44640ff6a..3a26a689b1 100644
--- a/crates/openhuman-core/src/agent/harness/definition_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/definition_tests.rs
@@ -83,9 +83,9 @@ fn model_spec_resolve_vision_hint_yields_the_vision_alias() {
// alias — which `oh_tier_supports_vision` reports as image-capable.
let spec = ModelSpec::Hint("vision".into());
assert_eq!(spec.resolve("parent-model"), "hint:vision");
- assert!(crate::inference::provider::factory::oh_tier_supports_vision(
- &spec.resolve("parent-model")
- ));
+ assert!(
+ crate::inference::provider::factory::oh_tier_supports_vision(&spec.resolve("parent-model"))
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/agent/tinyagents/routes_tests.rs b/crates/openhuman-core/src/agent/tinyagents/routes_tests.rs
index 537950fbc4..2256e7c138 100644
--- a/crates/openhuman-core/src/agent/tinyagents/routes_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/routes_tests.rs
@@ -191,7 +191,10 @@ fn route_fallback_policy_matches_legacy_chains() {
(ROUTE_REASONING, Some(&[ROUTE_REASONING, ROUTE_AGENTIC])),
(ROUTE_AGENTIC, Some(&[ROUTE_AGENTIC, ROUTE_REASONING])),
(ROUTE_CODING, Some(&[ROUTE_CODING, ROUTE_AGENTIC])),
- (ROUTE_SUMMARIZATION, Some(&[ROUTE_SUMMARIZATION, ROUTE_CHAT])),
+ (
+ ROUTE_SUMMARIZATION,
+ Some(&[ROUTE_SUMMARIZATION, ROUTE_CHAT]),
+ ),
// Vision is primary-only (an image_in gate no text route can satisfy).
(ROUTE_VISION, None),
// A concrete model id installs no chain — including the managed
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_models_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_models_tests.rs
index 07cddef14a..2e9ef7eb3f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_models_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_models_tests.rs
@@ -43,7 +43,10 @@ fn resolver() -> TurnModelResolver {
let primary: Arc<dyn ChatModel<()>> =
Arc::new(NamedModel("openrouter/deepseek/deepseek-v4.1-flash"));
let mut routes: HashMap<String, Arc<dyn ChatModel<()>>> = HashMap::new();
- routes.insert("hint:coding".to_string(), Arc::new(NamedModel("hint:coding")));
+ routes.insert(
+ "hint:coding".to_string(),
+ Arc::new(NamedModel("hint:coding")),
+ );
routes.insert("hint:burst".to_string(), Arc::new(NamedModel("hint:burst")));
TurnModelResolver::new(primary, routes)
}
diff --git a/crates/openhuman-core/src/config/migrations/mod.rs b/crates/openhuman-core/src/config/migrations/mod.rs
index f622bb7727..d66a28f373 100644
--- a/crates/openhuman-core/src/config/migrations/mod.rs
+++ b/crates/openhuman-core/src/config/migrations/mod.rs
@@ -32,8 +32,8 @@ mod reconcile_orphaned_providers;
mod remove_write_auto_approve;
mod repair_http_request_limits;
mod retire_chat_v1_model;
-mod retire_managed_tier_slugs;
mod retire_local_whisper_stt;
+mod retire_managed_tier_slugs;
mod retire_subconscious_medulla;
mod unify_ai_provider_settings;
diff --git a/crates/openhuman-core/src/config/migrations/mod_tests.rs b/crates/openhuman-core/src/config/migrations/mod_tests.rs
index bcbaf434ba..b299d6f102 100644
--- a/crates/openhuman-core/src/config/migrations/mod_tests.rs
+++ b/crates/openhuman-core/src/config/migrations/mod_tests.rs
@@ -246,6 +246,52 @@ async fn run_pending_v7_to_v8_rolls_back_default_model_when_save_fails() {
);
}
+#[tokio::test]
+async fn run_pending_v12_to_v13_retires_persisted_tier_slugs() {
+ let tmp = TempDir::new().unwrap();
+ fs::create_dir_all(tmp.path().join("workspace")).unwrap();
+
+ let mut config = config_in(&tmp);
+ config.schema_version = 12;
+ config.default_model = Some("chat-v1".to_string());
+ config.orchestrator.model = Some("reasoning-v1".to_string());
+
+ run_pending(&mut config).await;
+
+ assert_eq!(config.schema_version, CURRENT_SCHEMA_VERSION);
+ assert_eq!(
+ config.default_model.as_deref(),
+ Some(crate::config::MODEL_MANAGED_DEFAULT)
+ );
+ assert_eq!(
+ config.orchestrator.model.as_deref(),
+ Some(crate::config::MODEL_MANAGED_DEFAULT)
+ );
+ let on_disk = std::fs::read_to_string(&config.config_path).unwrap();
+ assert!(
+ !on_disk.contains("chat-v1") && !on_disk.contains("reasoning-v1"),
+ "no retired tier slug may survive on disk, got:\n{on_disk}"
+ );
+}
+
+#[tokio::test]
+async fn run_pending_v12_to_v13_rolls_back_when_save_fails() {
+ let tmp = TempDir::new().unwrap();
+ fs::create_dir_all(tmp.path().join("workspace")).unwrap();
+
+ let mut config = config_in(&tmp);
+ config.schema_version = 12;
+ config.default_model = Some("chat-v1".to_string());
+ let blocker = tmp.path().join("blocker");
+ fs::write(&blocker, "not a directory").unwrap();
+ config.config_path = blocker.join("nested").join("config.toml");
+
+ run_pending(&mut config).await;
+
+ assert_eq!(config.schema_version, 12);
+ assert_eq!(config.default_model.as_deref(), Some("chat-v1"));
+}
+
#[tokio::test]
async fn run_pending_v8_to_v9_enables_shadow_reads_on_an_upgraded_workspace() {
let tmp = TempDir::new().unwrap();
diff --git a/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs.rs b/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs.rs
index 9373ab7a2b..a14cbe9f9c 100644
--- a/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs.rs
+++ b/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs.rs
@@ -70,7 +70,11 @@ pub fn run(config: &mut Config) -> anyhow::Result<MigrationStats> {
);
}
for (id, delegate) in config.agents.iter_mut() {
- rewrite(&format!("agents.{id}.model"), &mut delegate.model, &mut stats);
+ rewrite(
+ &format!("agents.{id}.model"),
+ &mut delegate.model,
+ &mut stats,
+ );
}
for route in config.model_routes.iter_mut() {
rewrite(
diff --git a/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs_tests.rs b/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs_tests.rs
index 230a72dc7a..3375873c7b 100644
--- a/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs_tests.rs
+++ b/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs_tests.rs
@@ -57,9 +57,7 @@ fn leaves_concrete_ids_hints_and_empty_values_alone() {
let mut config = Config::default();
config.default_model = Some("openrouter/deepseek/deepseek-v4-pro".to_string());
config.orchestrator.model = Some("hint:reasoning".to_string());
- config
- .agents
- .insert("byok".to_string(), delegate("gpt-4o"));
+ config.agents.insert("byok".to_string(), delegate("gpt-4o"));
let stats = run(&mut config).expect("migration runs");
diff --git a/crates/openhuman-core/src/config/mod.rs b/crates/openhuman-core/src/config/mod.rs
index 2202355226..e274a560c3 100644
--- a/crates/openhuman-core/src/config/mod.rs
+++ b/crates/openhuman-core/src/config/mod.rs
@@ -26,11 +26,11 @@ pub use ops as rpc;
pub use ops::*;
pub use schema::{
- is_legacy_tier_model, legacy_tier_role, WORKLOAD_ROLES,
action_dir_env_override, active_user_marker_path, active_workspace_dir,
active_workspace_dir_cached, active_workspace_snapshot, clear_active_user, default_action_dir,
- default_projects_dir, default_root_openhuman_dir, pre_login_user_dir, read_active_user_id,
- resolve_action_dir, user_openhuman_dir, write_active_user_id, PRE_LOGIN_USER_ID,
+ default_projects_dir, default_root_openhuman_dir, is_legacy_tier_model, legacy_tier_role,
+ pre_login_user_dir, read_active_user_id, resolve_action_dir, user_openhuman_dir,
+ write_active_user_id, PRE_LOGIN_USER_ID, WORKLOAD_ROLES,
};
pub use workspace_handle::workspace_handle;
// Crate-internal: workspace→config-dir resolver reused by the cloud embedder.
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
index 89c8f065cb..8b7ddc4b83 100644
--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
@@ -144,8 +144,7 @@ async fn one_shot_chat_models_preserve_factory_temperature_as_request_default()
.await
.expect("explicit-temperature invoke");
- let turn_model =
- create_turn_chat_model("chat", &config, "hint:chat", 0.2).expect("turn model");
+ let turn_model = create_turn_chat_model("chat", &config, "hint:chat", 0.2).expect("turn model");
turn_model
.invoke(&(), ModelRequest::new(vec![Message::user("turn default")]))
.await
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rs
index d38dc12213..b8bef3b5da 100644
--- a/tests/json_rpc_e2e.rs
+++ b/tests/json_rpc_e2e.rs
@@ -4230,7 +4230,10 @@ async fn json_rpc_web_chat_routing_cases_use_expected_backend_models_inner() {
("hint:agentic", "openrouter/deepseek/deepseek-v4-flash"),
("hint:coding", "openrouter/deepseek/deepseek-v4-flash"),
("reasoning-v1", "openrouter/deepseek/deepseek-v4-flash"),
- ("openrouter/deepseek/deepseek-v4-pro", "openrouter/deepseek/deepseek-v4-pro"),
+ (
+ "openrouter/deepseek/deepseek-v4-pro",
+ "openrouter/deepseek/deepseek-v4-pro",
+ ),
// Web chat forwards lightweight hint overrides as-is for this path,
// so the upstream model receives the original hint string.
("hint:reaction", "hint:reaction"),