Skip to content

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

fix(inference): preserve caller-supplied model id verbatim

Steven Enamakel01149d747bd4
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
index b32b07f373..04dd1a23d0 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
@@ -72,11 +72,11 @@ pub async fn complete_once(
"complete_once: provider_options may not set `{key}`; use the typed request fields"
));
}
+ // Blank is refused, but the id itself goes out exactly as the caller named it.
let model_id = request
.model
.as_deref()
- .map(str::trim)
- .filter(|model| !model.is_empty())
+ .filter(|model| !model.trim().is_empty())
.ok_or_else(|| "complete_once: request.model is required".to_string())?
.to_string();
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once_tests.rs b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once_tests.rs
index d0845017d9..7719ef8a0d 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once_tests.rs
@@ -153,3 +153,18 @@ async fn refuses_tools_smuggled_through_provider_options() {
"{err}"
);
}
+
+#[tokio::test]
+async fn provider_error_is_returned_as_a_prefixed_string() {
+ let server = MockServer::start().await;
+ Mock::given(method("POST"))
+ .and(path("/v1/chat/completions"))
+ .respond_with(ResponseTemplate::new(400).set_body_string("unknown model"))
+ .mount(&server)
+ .await;
+ let request = ModelRequest::new(vec![Message::user("hi")]).with_model("m".to_string());
+ let err = complete_once(&endpoint(&server), request)
+ .await
+ .expect_err("a 400 from the provider must surface as an error");
+ assert!(err.starts_with("complete_once: "), "{err}");
+}