Skip to content

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

feat(inference): add openhuman backend model provider

Steven Enamakelb85d6a967ff4
diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
index 66192712dd..96bd666e5d 100644
--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
@@ -29,7 +29,7 @@ fn is_loopback_host(url: &url::Url) -> bool {
/// `openhuman_embed::turn::is_safe_endpoint_for_bearer`'s allowance for local
/// testing against a dev server. Anything else — a plaintext non-loopback
/// endpoint — would put the key on the wire in the clear (CWE-319), so
-/// [`OpenHumanBackendModel::resolve_bearer`] refuses before it gets there.
+/// the managed model refuses before it gets there.
/// Deliberately narrow to the managed-key bearer path: `normalize_api_base_url`
/// itself must stay permissive, because a library host's BYOK/local `api_url`
/// can legitimately be plain HTTP.
@@ -62,10 +62,6 @@ pub(crate) fn is_managed_endpoint_for_api_key(endpoint: &str) -> bool {
|| is_loopback_host(&url)
}
-/// The managed OpenHuman backend as a crate [`ChatModel`]. Holds the backend
-/// connection settings (for JWT + base-URL resolution) and the default model id
-}
-
/// Request-metadata key a caller sets (to `true`) to ask for no reasoning on
/// a call — see [`without_reasoning`].
pub const REASONING_OFF_METADATA_KEY: &str = "openhuman_reasoning_off";
@@ -80,3 +76,19 @@ pub(crate) fn without_reasoning(mut request: ModelRequest) -> ModelRequest {
if !request.metadata.is_object() {
request.metadata = Value::Object(serde_json::Map::new());
}
+
+/// Mark `request` as not needing the model to reason first. Provider-neutral:
+/// `ModelRequest.metadata` never reaches the wire, so a BYOK or local provider
+/// ignores it. The managed provider turns it into `reasoning: { enabled:
+/// false }`, which the backend forwards to OpenRouter only. For short structured
+/// helper calls (follow-up suggestions) reasoning adds seconds and more tokens
+/// than the answer itself, for no quality gain.
+pub(crate) fn without_reasoning(mut request: ModelRequest) -> ModelRequest {
+ if !request.metadata.is_object() {
+ request.metadata = Value::Object(serde_json::Map::new());
+ }
+ if let Some(map) = request.metadata.as_object_mut() {
+ map.insert(REASONING_OFF_METADATA_KEY.to_string(), Value::Bool(true));
+ }
+ request
+}