Skip to content

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

feat(inference): add managed backend provider support

Steven Enamakel19776a2ac51b
diff --git a/crates/openhuman-core/src/agent/tools/delegate.rs b/crates/openhuman-core/src/agent/tools/delegate.rs
index 54a2a70a55..af67e7b6c5 100644
--- a/crates/openhuman-core/src/agent/tools/delegate.rs
+++ b/crates/openhuman-core/src/agent/tools/delegate.rs
@@ -1,7 +1,6 @@
use crate::config::DelegateAgentConfig;
-use crate::inference::provider::{
- OpenHumanBackendModel, ProviderRuntimeOptions, INFERENCE_BACKEND_ID,
-};
+use crate::inference::provider::factory::make_openhuman_backend_model_for_options;
+use crate::inference::provider::{ProviderRuntimeOptions, INFERENCE_BACKEND_ID};
use crate::security::policy::ToolOperation;
use crate::security::SecurityPolicy;
use crate::tools::timeout::tool_execution_timeout_secs;
@@ -243,15 +242,22 @@ impl DelegateTool {
return Ok(ToolResult::error(error));
}
- let model = OpenHumanBackendModel::new(
- None,
- &self.provider_runtime_options,
- agent_config.model.clone(),
- )
// `metadata` below is diagnostic only; the managed model owns the
// actual backend wire extension so configured delegates cannot lose
// their parent's thread between typed dispatch and provider invoke.
- .with_thread_id(tool_context.and_then(ToolRunContext::thread_id));
+ let thread_id = tool_context.and_then(ToolRunContext::thread_id);
+ let model = match make_openhuman_backend_model_for_options(
+ &self.provider_runtime_options,
+ &agent_config.model,
+ thread_id,
+ ) {
+ Ok((model, _resolved)) => model,
+ Err(error) => {
+ return Ok(ToolResult::error(format!(
+ "Agent '{agent_name}' failed: {error}"
+ )));
+ }
+ };
// Build the message
let full_prompt = if context.is_empty() {
diff --git a/crates/openhuman-core/src/inference/provider/factory.rs b/crates/openhuman-core/src/inference/provider/factory.rs
index c192ed4fb6..d5ad0a488b 100644
--- a/crates/openhuman-core/src/inference/provider/factory.rs
+++ b/crates/openhuman-core/src/inference/provider/factory.rs
@@ -89,7 +89,9 @@ use local_runtime::{
try_create_local_runtime_chat_model, try_create_local_runtime_chat_model_from_string,
OptionalChatModelResult,
};
-pub(crate) use managed_backend::make_openhuman_backend_model_for_thread;
+pub(crate) use managed_backend::{
+ make_openhuman_backend_model_for_options, make_openhuman_backend_model_for_thread,
+};
use managed_backend::{managed_chat_model, resolve_managed_model};
use primary_cloud::{legacy_inference_slug, resolve_primary_cloud_provider_string};
use subprocess_providers::{
diff --git a/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs b/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs
index ff19ac6228..707a13fedb 100644
--- a/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs
@@ -132,3 +132,30 @@ pub(crate) fn make_openhuman_backend_model(
) -> anyhow::Result<ManagedChatModel> {
managed_chat_model(role, config, None, None, true, None, &EgressLedger::none())
}
+
+/// The managed model for a caller that holds runtime options rather than a
+/// [`Config`] (the configured `delegate` tool): `model` is used verbatim, with
+/// no tier translation and no egress emission, exactly as that tool always did.
+pub(crate) fn make_openhuman_backend_model_for_options(
+ options: &crate::inference::provider::ProviderRuntimeOptions,
+ model: &str,
+ thread_id: Option<&str>,
+) -> anyhow::Result<ManagedChatModel> {
+ let Some(entry) = crate::inference::registry::chat_model(PROVIDER_OPENHUMAN) else {
+ return Err(managed_unavailable_error());
+ };
+ let mut config = Config::default();
+ if let Some(dir) = options.openhuman_dir.as_ref() {
+ config.config_path = dir.join("config.toml");
+ }
+ config.secrets.encrypt = options.secrets_encrypt;
+ (entry.build)(&crate::inference::registry::ChatModelRequest {
+ role: "delegate",
+ config: &config,
+ model_override: Some(model),
+ default_model: Some(model),
+ native_tool_calling: true,
+ thread_id,
+ egress: &EgressLedger::none(),
+ })
+}
diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rs
index b64c86ffda..70d52f291a 100644
--- a/crates/openhuman-embed/src/host_internals.rs
+++ b/crates/openhuman-embed/src/host_internals.rs
@@ -225,13 +225,6 @@ pub mod inference {
}
}
-/// tinyhumans: the team ops budget gate.
-pub mod integrations {
- pub mod client {
- pub use openhuman_core::integrations::client::budget_gate;
- }
-}
-
/// tinyhumans (credentials for the hosted client) and rpc (server auth,
/// Socket.IO approvals, bind policy).
pub mod security {
@@ -339,6 +332,29 @@ pub mod composio {
register_composio_route_builder, unregister_composio_route_builder, ComposioRoute,
ComposioRouteBuilder,
};
+ // The proxy route's target (origin + bearer) for `composio.mode = backend`.
+ pub use openhuman_core::modules::connectors::{
+ register_proxy_target, unregister_proxy_target, ProxyTarget, ProxyTargetResolver,
+ };
+}
+
+/// Media-generation tool building over host-supplied generators (tinyhumans).
+#[cfg(feature = "media")]
+pub mod media {
+ pub mod generation {
+ pub use openhuman_core::media::generation::{
+ media_tools_for_config, GeneratorRouter, MediaGenerators, MediaReferenceAllowlist,
+ };
+ }
+}
+
+/// The wallet module's authenticated backend hook (tinyhumans web3).
+#[cfg(feature = "web3")]
+pub mod wallet_backend {
+ pub use openhuman_core::modules::wallet_backend::{
+ register_wallet_backend, register_wallet_backend_in, unregister_wallet_backend,
+ WalletBackendCall, WalletBackendFuture, WalletBackendHandler,
+ };
}
/// Model-provider registries: chat models, embeddings, catalogs.