Skip to content

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

feat(config): add migration to retire managed tier slugs

Steven Enamakel6caf1692214d
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
new file mode 100644
index 0000000000..f984fdba08
--- /dev/null
+++ b/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs.rs
@@ -0,0 +1,91 @@
+//! Migration 12 → 13: retire the managed tier slugs (`chat-v1`, `agentic-v1`,
+//! `reasoning-v1`, …) in favour of concrete OpenRouter model ids.
+//!
+//! The managed backend no longer serves tier endpoints; every managed workload
+//! runs on the pinned default model or [`MODEL_MANAGED_DEFAULT`]. A persisted
+//! tier slug would reach the backend verbatim and 400, so every place a user
+//! (or an older build) could have written one is rewritten:
+//!
+//! - `default_model` — any tier slug becomes [`MODEL_MANAGED_DEFAULT`].
+//! - `agent.orchestrator.model`, `agent.team_models.{lead,agent}_model` and
+//! each `agents.<id>.model` delegate pin — tier slugs become the managed
+//! default too; a slug that was pinning a *role* (`reasoning-v1` on a lead)
+//! loses nothing, since on the managed backend every role now runs the same
+//! model.
+//! - `model_routes[].model` — the same rewrite; the `hint` key is untouched.
+//!
+//! Concrete ids (`openrouter/...`, BYOK model names) and `hint:*` markers are
+//! left exactly as they are: `hint:*` is still translated at dispatch, and a
+//! concrete id is the user's own choice.
+//!
+//! Pure in-memory mutation; the caller persists and bumps `schema_version`.
+//! Idempotent: a config with no tier slug is a no-op.
+
+use crate::config::{is_legacy_tier_model, Config, MODEL_MANAGED_DEFAULT};
+
+/// Counters returned by [`run`] for diagnostics.
+#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
+pub struct MigrationStats {
+ /// Number of fields rewritten from a tier slug to the managed default.
+ pub rewritten: usize,
+}
+
+fn rewrite(field: &str, value: &mut String, stats: &mut MigrationStats) {
+ if is_legacy_tier_model(value) {
+ log::info!(
+ "[migrations][retire-managed-tiers] {field}: {:?} -> {MODEL_MANAGED_DEFAULT:?}",
+ value
+ );
+ *value = MODEL_MANAGED_DEFAULT.to_string();
+ stats.rewritten += 1;
+ }
+}
+
+fn rewrite_opt(field: &str, value: &mut Option<String>, stats: &mut MigrationStats) {
+ if let Some(inner) = value.as_mut() {
+ rewrite(field, inner, stats);
+ }
+}
+
+/// Rewrite every retired tier slug in `config` to the managed default model.
+pub fn run(config: &mut Config) -> anyhow::Result<MigrationStats> {
+ let mut stats = MigrationStats::default();
+
+ rewrite_opt("default_model", &mut config.default_model, &mut stats);
+ rewrite_opt(
+ "agent.orchestrator.model",
+ &mut config.agent.orchestrator.model,
+ &mut stats,
+ );
+ rewrite_opt(
+ "agent.team_models.lead_model",
+ &mut config.agent.team_models.lead_model,
+ &mut stats,
+ );
+ rewrite_opt(
+ "agent.team_models.agent_model",
+ &mut config.agent.team_models.agent_model,
+ &mut stats,
+ );
+ for (id, delegate) in config.agents.iter_mut() {
+ rewrite(&format!("agents.{id}.model"), &mut delegate.model, &mut stats);
+ }
+ for route in config.model_routes.iter_mut() {
+ rewrite(
+ &format!("model_routes[{}].model", route.hint),
+ &mut route.model,
+ &mut stats,
+ );
+ }
+
+ log::debug!(
+ "[migrations][retire-managed-tiers] rewritten={} default_model={:?}",
+ stats.rewritten,
+ config.default_model
+ );
+ Ok(stats)
+}
+
+#[cfg(test)]
+#[path = "retire_managed_tier_slugs_tests.rs"]
+mod tests;
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
new file mode 100644
index 0000000000..02cd9ea5cb
--- /dev/null
+++ b/crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs_tests.rs
@@ -0,0 +1,85 @@
+use super::*;
+use crate::config::schema::{DelegateAgentConfig, ModelRouteConfig};
+
+fn delegate(model: &str) -> DelegateAgentConfig {
+ DelegateAgentConfig {
+ model: model.to_string(),
+ system_prompt: None,
+ temperature: None,
+ max_tokens: None,
+ allowed_tools: Vec::new(),
+ max_iterations: None,
+ timeout_secs: None,
+ }
+}
+
+#[test]
+fn rewrites_every_tier_slug_to_the_managed_default() {
+ let mut config = Config::default();
+ config.default_model = Some("chat-v1".to_string());
+ config.agent.orchestrator.model = Some("reasoning-v1".to_string());
+ config.agent.team_models.lead_model = Some("agentic-v1".to_string());
+ config.agent.team_models.agent_model = Some("burst-v1".to_string());
+ config
+ .agents
+ .insert("coder".to_string(), delegate("coding-v1"));
+ config.model_routes.push(ModelRouteConfig {
+ hint: "summarization".to_string(),
+ model: "summarization-v1".to_string(),
+ });
+
+ let stats = run(&mut config).expect("migration runs");
+
+ assert_eq!(stats.rewritten, 6);
+ assert_eq!(config.default_model.as_deref(), Some(MODEL_MANAGED_DEFAULT));
+ assert_eq!(
+ config.agent.orchestrator.model.as_deref(),
+ Some(MODEL_MANAGED_DEFAULT)
+ );
+ assert_eq!(
+ config.agent.team_models.lead_model.as_deref(),
+ Some(MODEL_MANAGED_DEFAULT)
+ );
+ assert_eq!(
+ config.agent.team_models.agent_model.as_deref(),
+ Some(MODEL_MANAGED_DEFAULT)
+ );
+ assert_eq!(config.agents["coder"].model, MODEL_MANAGED_DEFAULT);
+ assert_eq!(config.model_routes[0].model, MODEL_MANAGED_DEFAULT);
+ // The route's hint key is the role and stays.
+ assert_eq!(config.model_routes[0].hint, "summarization");
+}
+
+#[test]
+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.agent.orchestrator.model = Some("hint:reasoning".to_string());
+ config.agent.team_models.lead_model = None;
+ config
+ .agents
+ .insert("byok".to_string(), delegate("gpt-4o"));
+
+ let stats = run(&mut config).expect("migration runs");
+
+ assert_eq!(stats, MigrationStats::default());
+ assert_eq!(
+ config.default_model.as_deref(),
+ Some("openrouter/deepseek/deepseek-v4-pro")
+ );
+ assert_eq!(
+ config.agent.orchestrator.model.as_deref(),
+ Some("hint:reasoning")
+ );
+ assert_eq!(config.agents["byok"].model, "gpt-4o");
+}
+
+#[test]
+fn is_idempotent() {
+ let mut config = Config::default();
+ config.default_model = Some("reasoning-quick-v1".to_string());
+ run(&mut config).expect("first run");
+ let stats = run(&mut config).expect("second run");
+ assert_eq!(stats.rewritten, 0);
+ assert_eq!(config.default_model.as_deref(), Some(MODEL_MANAGED_DEFAULT));
+}