Skip to content

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

fix(inference): trim legacy provider type and backfill default endpoint

Steven Enamakel6cf72b177eaa
diff --git a/crates/openhuman-core/src/config/schemas/controllers/inference.rs b/crates/openhuman-core/src/config/schemas/controllers/inference.rs
index 3a55033b25..4515e2aa1c 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/inference.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/inference.rs
@@ -99,10 +99,18 @@ pub(super) fn handle_update_model_settings(params: Map<String, Value>) -> Contro
"cloud provider slug must not be empty".to_string()
);
}
- let legacy_auth = e.legacy_type.as_deref()
- .and_then(builtin_cloud_provider)
+ let legacy_provider = e.legacy_type.as_deref()
+ .map(str::trim)
+ .and_then(builtin_cloud_provider);
+ let legacy_auth = legacy_provider
.map(|provider| provider.auth_style.as_str())
.unwrap_or("bearer");
+ let endpoint = if e.endpoint.is_empty() {
+ legacy_provider.map(|provider| provider.endpoint.to_string())
+ .unwrap_or(e.endpoint)
+ } else {
+ e.endpoint
+ };
let auth_style = match e
.auth_style
.as_deref()
@@ -133,7 +141,7 @@ pub(super) fn handle_update_model_settings(params: Map<String, Value>) -> Contro
id,
slug,
label,
- endpoint: e.endpoint,
+ endpoint,
auth_style,
default_model: e.default_model,
};
diff --git a/crates/openhuman-core/src/inference/schemas/settings_handlers.rs b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
index ceae43afe9..c9a8efde2c 100644
--- a/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
+++ b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
@@ -183,10 +183,18 @@ pub(super) fn handle_inference_update_model_settings(
if slug.is_empty() {
return Err("cloud provider slug must not be empty".to_string());
}
- let legacy_auth = entry.legacy_type.as_deref()
- .and_then(builtin_cloud_provider)
+ let legacy_provider = entry.legacy_type.as_deref()
+ .map(str::trim)
+ .and_then(builtin_cloud_provider);
+ let legacy_auth = legacy_provider
.map(|provider| provider.auth_style.as_str())
.unwrap_or("bearer");
+ let endpoint = if entry.endpoint.is_empty() {
+ legacy_provider.map(|provider| provider.endpoint.to_string())
+ .unwrap_or(entry.endpoint)
+ } else {
+ entry.endpoint
+ };
let auth_style = match entry
.auth_style
.as_deref()
@@ -217,7 +225,7 @@ pub(super) fn handle_inference_update_model_settings(
id,
slug,
label,
- endpoint: entry.endpoint,
+ endpoint,
auth_style,
default_model: entry.default_model,
};
diff --git a/docs/dep-audit/2026-10-11-compatibility-retirement.md b/docs/dep-audit/2026-10-11-compatibility-retirement.md
index dcfd64daf6..8ad33195c8 100644
--- a/docs/dep-audit/2026-10-11-compatibility-retirement.md
+++ b/docs/dep-audit/2026-10-11-compatibility-retirement.md
@@ -48,7 +48,9 @@ user payloads or credentials were copied.
The old-provider fixture covers type-to-slug/default endpoint/auth migration
and model survival across save/reload. Migration fixtures also cover explicit
values, unknown provider slugs, malformed discriminator rejection, idempotence,
-and a schema-14 no-op. Existing native tests cover policy-context redaction,
+a schema-14 no-op, and failed-save retry. A real JSON-RPC fixture covers both
+settings controllers retaining incoming type defaults while preserving explicit
+endpoint/auth values. Existing native tests cover policy-context redaction,
cache fallback, route-based local usage and scoped cancellation.
The issue names scripts/e2e-core.sh, which is absent at this base. The supported
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rs
index 62abd910ab..d687c956cb 100644
--- a/tests/json_rpc_e2e.rs
+++ b/tests/json_rpc_e2e.rs
@@ -1191,7 +1191,7 @@ async fn json_rpc_legacy_provider_type_preserves_default_endpoint() {
41_250 + index as i64,
method,
json!({
- "cloud_providers": [{"slug": "legacy", "endpoint": "", "type": "anthropic",
+ "cloud_providers": [{"slug": "legacy", "endpoint": "", "type": " anthropic ",
"default_model": "claude-sonnet-4"}]
}),
)
@@ -1202,8 +1202,7 @@ async fn json_rpc_legacy_provider_type_preserves_default_endpoint() {
));
let path = snapshot["config_path"].as_str().expect("saved config path");
let persisted: openhuman_core::config::Config =
- toml::from_str(&std::fs::read_to_string(path).unwrap())
- .unwrap();
+ toml::from_str(&std::fs::read_to_string(path).unwrap()).unwrap();
let provider = persisted
.cloud_providers
.iter()
@@ -1218,6 +1217,22 @@ async fn json_rpc_legacy_provider_type_preserves_default_endpoint() {
openhuman_core::config::schema::AuthStyle::Anthropic
);
assert_eq!(provider.default_model.as_deref(), Some("claude-sonnet-4"));
+ let updated = post_json_rpc(
+ &rpc_base,
+ 41_260 + index as i64,
+ method,
+ json!({"cloud_providers": [{"slug": "legacy", "endpoint": "http://127.0.0.1:9/v1",
+ "type": "anthropic", "auth_style": "bearer"}]}),
+ )
+ .await;
+ let snapshot = peel_logs_envelope(assert_no_jsonrpc_error(
+ &updated,
+ "explicit provider values",
+ ));
+ let providers = snapshot["config"]["cloud_providers"].as_array().unwrap();
+ let provider = providers.iter().find(|p| p["slug"] == "legacy").unwrap();
+ assert_eq!(provider["endpoint"], "http://127.0.0.1:9/v1");
+ assert_eq!(provider["auth_style"], "bearer");
}
rpc_join.abort();
}