Skip to content

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

refactor(inference): route provider and embedding setup through shared factory helpers

Steven Enamakelaabe6e11ce24
diff --git a/Cargo.lock b/Cargo.lock
index 01b96fc119..e0ced21f72 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -266,7 +266,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -277,7 +277,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -1060,7 +1060,7 @@ dependencies = [
"cap-primitives",
"cap-std",
"io-lifetimes 3.0.1",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -1077,7 +1077,7 @@ dependencies = [
"maybe-owned",
"rustix 1.1.5",
"rustix-linux-procfs",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
"winx",
]
@@ -2218,7 +2218,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users 0.5.2",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -2494,7 +2494,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -3579,28 +3579,6 @@ dependencies = [
"cc",
]
-[[package]]
-name = "icu_casemap"
-version = "2.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2edfd120d8445de853cf53a1abec916f638f933a70a6f4bf8f7e2d7b7f884e9"
-dependencies = [
- "icu_casemap_data",
- "icu_collections",
- "icu_locale_core",
- "icu_properties",
- "icu_provider",
- "potential_utf",
- "writeable",
- "zerovec",
-]
-
-[[package]]
-name = "icu_casemap_data"
-version = "2.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "059fcda0fc8d33effc6633a8cf0d8a3c17caf7d7c91918fba9918744f501e4e8"
-
[[package]]
name = "icu_collections"
version = "2.3.0"
@@ -3609,7 +3587,6 @@ checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513"
dependencies = [
"displaydoc",
"potential_utf",
- "serde",
"utf8_iter",
"yoke",
"zerofrom",
@@ -3624,7 +3601,6 @@ checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb"
dependencies = [
"displaydoc",
"litemap",
- "serde",
"tinystr",
"writeable",
"zerovec",
@@ -3679,8 +3655,6 @@ checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73"
dependencies = [
"displaydoc",
"icu_locale_core",
- "serde",
- "stable_deref_trait",
"writeable",
"yoke",
"zerofrom",
@@ -4855,7 +4829,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -6344,8 +6318,6 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661"
dependencies = [
- "serde_core",
- "writeable",
"zerovec",
]
@@ -6560,7 +6532,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -6797,12 +6769,6 @@ dependencies = [
"unicode-width",
]
-[[package]]
-name = "rawzip"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac9999039f74cd73c03158cddfe4362991703c74efe5ce5c8073026f80a5e48c"
-
[[package]]
name = "rdev"
version = "0.5.3"
@@ -7201,7 +7167,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.12.1",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -7270,7 +7236,7 @@ dependencies = [
"security-framework 3.7.0",
"security-framework-sys",
"webpki-root-certs",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -7925,7 +7891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [
"libc",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -8272,10 +8238,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
- "getrandom 0.4.3",
+ "getrandom 0.3.4",
"once_cell",
"rustix 1.1.5",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -8288,7 +8254,7 @@ dependencies = [
"parking_lot",
"rustix 1.1.5",
"signal-hook",
- "windows-sys 0.61.2",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -8822,13 +8788,11 @@ dependencies = [
[[package]]
name = "tinybus"
-version = "0.1.9"
+version = "0.1.6"
dependencies = [
"async-trait",
"flate2",
- "icu_casemap",
"libc",
- "rawzip",
"serde",
"serde_json",
"sha2 0.10.9",
@@ -8839,13 +8803,13 @@ dependencies = [
"tokio",
"toml 1.1.6+spec-1.1.0",
"tracing",
- "unicode-normalization",
"ureq",
+ "zip 9.0.5",
]
[[package]]
name = "tinybus-macros"
-version = "0.1.9"
+version = "0.1.6"
dependencies = [
"proc-macro2",
"quote",
@@ -8854,7 +8818,7 @@ dependencies = [
[[package]]
name = "tinybus-module"
-version = "0.1.9"
+version = "0.1.6"
dependencies = [
"async-trait",
"serde",
@@ -9982,7 +9946,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643"
dependencies = [
"displaydoc",
- "serde_core",
"zerovec",
]
@@ -11539,7 +11502,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "windows-sys 0.48.0",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -12270,7 +12233,6 @@ dependencies = [
"displaydoc",
"yoke",
"zerofrom",
- "zerovec",
]
[[package]]
@@ -12279,7 +12241,6 @@ version = "0.11.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8"
dependencies = [
- "serde",
"yoke",
"zerofrom",
"zerovec-derive",
@@ -12347,6 +12308,20 @@ dependencies = [
"zopfli",
]
+[[package]]
+name = "zip"
+version = "9.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e04976da629d3b04204ba8105b396a193af8ad2583b2c79bfb3ab8af580a11e"
+dependencies = [
+ "crc32fast",
+ "flate2",
+ "indexmap",
+ "memchr",
+ "nix 0.31.3",
+ "typed-path",
+]
+
[[package]]
name = "zlib-rs"
version = "0.6.8"
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/steering.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/steering.rs
index a696ed18d8..e9710516b1 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/steering.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/steering.rs
@@ -2,10 +2,12 @@
use tinyagents_harness::ids::TaskId;
use tinyagents_harness::run_queue::QueueLane;
-use tinyagents_orchestration::subagent::{steer_detached, SteerAccess, SteerError};
+use tinyagents_orchestration::steering::{
+ queue_lane_name, steer_detached, SteerAccess, SteerError,
+};
use super::cancel::now_ms;
-use super::registry::{control_admits, owner_key, registry};
+use super::registry::{control_admits, owner_key, registry, RunningSubagentMetadata};
/// Inject an instruction into a detached sub-agent owned by `parent_session`.
pub async fn steer(
@@ -22,7 +24,7 @@ pub async fn steer(
SteerAccess::Owner(&owner),
text,
lane,
- |metadata, lane, text| async move {
+ |metadata: RunningSubagentMetadata, lane, text| async move {
metadata
.run_queue
.push(
@@ -44,7 +46,7 @@ pub async fn steer(
.await?;
tracing::info!(
task_id,
- lane = tinyagents_orchestration::subagent::queue_lane_name(lane),
+ lane = queue_lane_name(lane),
?route,
"[running_subagents] steered detached task"
);
@@ -75,7 +77,7 @@ pub(crate) async fn steer_control(
SteerAccess::Trusted,
text,
lane,
- |metadata, lane, text| async move {
+ |metadata: RunningSubagentMetadata, lane, text| async move {
metadata
.run_queue
.push(
@@ -97,7 +99,7 @@ pub(crate) async fn steer_control(
.await?;
tracing::info!(
task_id,
- lane = tinyagents_orchestration::subagent::queue_lane_name(lane),
+ lane = queue_lane_name(lane),
?route,
"[running_subagents] control-steered detached task"
);
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_cancel_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_cancel_tests.rs
index 375232e972..31daede3cf 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_cancel_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_cancel_tests.rs
@@ -1,7 +1,7 @@
//! Cancelling and stopping registered sub-agents: by task, by thread, and all.
use super::*;
-use tinyagents_orchestration::subagent::SteerError;
+use tinyagents_orchestration::steering::SteerError;
/// A finished run stays registered until the terminal sweep, so a late
/// "Cancel" still finds it. It must come back flagged, so the RPC does not
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs
index 65a5a6c127..8999ce22b5 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use tinyagents_orchestration::subagent::SteerError;
+use tinyagents_orchestration::steering::SteerError;
#[tokio::test]
async fn steer_pushes_into_the_subagent_queue() {
@@ -109,25 +109,24 @@ async fn steer_rejects_cross_parent_and_unknown() {
}
#[tokio::test]
-async fn steer_after_terminal_is_rejected() {
+async fn steer_after_terminal_uses_the_host_fallback_queue() {
let _guard = test_guard_async().await;
let rq = run_queue();
- let tx = register_test("task-term", "session-A", rq);
+ let tx = register_test("task-term", "session-A", rq.clone());
let _ = tx.send(DetachedSubagentStatus::Failed {
error: "boom".into(),
});
- assert_eq!(
- steer(
- &crate::core::runtime::DispatchCtx::ambient(),
- "task-term",
- "session-A",
- "x".into(),
- QueueLane::Steer
- )
- .await,
- Err(SteerError::AlreadyDone)
- );
+ steer(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ "task-term",
+ "session-A",
+ "x".into(),
+ QueueLane::Steer,
+ )
+ .await
+ .expect("terminal tasks with retained metadata use the host fallback");
+ assert_eq!(rq.status().await.steers, 1);
prune("task-term");
}
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
index 0be7ef0aee..3df419cb4f 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
@@ -5,7 +5,7 @@ use crate::agent::orchestration::running_subagents::resolve::{
use crate::core::runtime::DispatchCtx;
use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet, Mode};
use crate::tools::toolpacks::ToolGroups;
-use tinyagents_orchestration::subagent::SteerError;
+use tinyagents_orchestration::steering::SteerError;
const CHILD: &str = "OPENHUMAN_DETACHED_TENANT_TEST_CHILD";
const PARENT: &str = "same-parent-session";
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs
index 59b26c3bbc..4e8237baa3 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use tinyagents_orchestration::subagent::SteerError;
+use tinyagents_orchestration::steering::SteerError;
/// The context these tests dispatch under: the calling task's own.
fn cx() -> crate::core::runtime::DispatchCtx {
diff --git a/crates/openhuman-core/src/agent/session_host/test_support.rs b/crates/openhuman-core/src/agent/session_host/test_support.rs
index 2e2b1c0079..c1743a9a01 100644
--- a/crates/openhuman-core/src/agent/session_host/test_support.rs
+++ b/crates/openhuman-core/src/agent/session_host/test_support.rs
@@ -1,9 +1,10 @@
use super::*;
+use tinyinference_llm::providers::overrides::{
+ ChatModelEntry, ChatModelRequest, ProviderModelMetadata,
+};
use crate::inference::provider::factory::PROVIDER_OPENHUMAN;
-use crate::inference::registry::{
- ChatModelEntry, ChatModelRequest, ProviderContext, ProviderModelMetadata,
-};
+use crate::inference::registry::ProviderContext;
use std::sync::Arc;
use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};
diff --git a/crates/openhuman-core/src/agent/tinyagents/verify_before_finish_tests.rs b/crates/openhuman-core/src/agent/tinyagents/verify_before_finish_tests.rs
index a76228e651..411ae107c0 100644
--- a/crates/openhuman-core/src/agent/tinyagents/verify_before_finish_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/verify_before_finish_tests.rs
@@ -14,6 +14,8 @@ fn activity(rounds: usize, tools: &[&str]) -> FinishActivity {
FinishActivity {
tool_rounds: rounds,
tools_called: tools.iter().map(|t| (*t).to_string()).collect(),
+ tools_executed: Default::default(),
+ tools_with_side_effects: Default::default(),
}
}
diff --git a/crates/openhuman-core/src/agent_runs/subagent_control.rs b/crates/openhuman-core/src/agent_runs/subagent_control.rs
index e1d43165d7..0ee37ecef7 100644
--- a/crates/openhuman-core/src/agent_runs/subagent_control.rs
+++ b/crates/openhuman-core/src/agent_runs/subagent_control.rs
@@ -16,7 +16,7 @@
use crate::core::runtime::DispatchCtx;
use serde_json::{json, Map, Value};
-use tinyagents_orchestration::subagent::SteerError;
+use tinyagents_orchestration::steering::SteerError;
use crate::agent::orchestration::running_subagents::CancelledSubagent;
use crate::agent::orchestration::{background_completions, running_subagents, subagent_sessions};
@@ -270,7 +270,6 @@ fn handle_subagent_steer(ctx: DispatchCtx, params: Map<String, Value>) -> Contro
Err(err) => {
let reason = match err {
SteerError::Unknown => "unknown",
- SteerError::AlreadyDone => "already_done",
// SaaS user controls check the captured worker profile,
// independently of the caller-supplied task ID.
SteerError::NotOwned => "not_owned",
diff --git a/crates/openhuman-core/src/doctor/checks/embeddings_live_tests.rs b/crates/openhuman-core/src/doctor/checks/embeddings_live_tests.rs
index 468e2fc79d..9f2c291972 100644
--- a/crates/openhuman-core/src/doctor/checks/embeddings_live_tests.rs
+++ b/crates/openhuman-core/src/doctor/checks/embeddings_live_tests.rs
@@ -90,11 +90,15 @@ async fn managed_inspection_does_not_fall_back_to_the_mutable_provider_factory()
let calls = Arc::new(AtomicUsize::new(0));
let provider_calls = Arc::clone(&calls);
let extensions = Extensions::new();
- crate::inference::registry::register_embedding_in(&extensions, PROVIDER_OPENHUMAN, move |_| {
- provider_calls.fetch_add(1, Ordering::SeqCst);
- Ok(Box::new(tinyinference_embeddings::NoopEmbeddingModel)
- as Box<dyn tinyinference_embeddings::EmbeddingModel>)
- });
+ crate::inference::registry::register_embedding_in(
+ &extensions,
+ PROVIDER_OPENHUMAN,
+ Arc::new(move |_| {
+ provider_calls.fetch_add(1, Ordering::SeqCst);
+ Ok(Box::new(tinyinference_embeddings::NoopEmbeddingModel)
+ as Box<dyn tinyinference_embeddings::EmbeddingModel>)
+ }),
+ );
let context = CoreContext::for_test_with_extensions(DomainSet::full(), None, extensions);
CoreContext::scope(context, async {
diff --git a/crates/openhuman-core/src/doctor/checks/inference_live_tests.rs b/crates/openhuman-core/src/doctor/checks/inference_live_tests.rs
index aaa618de6a..3bb887c052 100644
--- a/crates/openhuman-core/src/doctor/checks/inference_live_tests.rs
+++ b/crates/openhuman-core/src/doctor/checks/inference_live_tests.rs
@@ -6,6 +6,7 @@ use crate::config::Config;
use crate::core::runtime::{CoreContext, DomainSet};
use crate::doctor::{DoctorCtx, DoctorOptions, DoctorTier, Finding, FindingSeverity};
use serde_json::{json, Value};
+use tinyinference_llm::providers::overrides::ChatModelRequest;
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};
@@ -298,7 +299,7 @@ async fn live_probe_uses_selected_doctor_config_inside_another_ambient_context()
#[tokio::test]
async fn managed_chat_probe_uses_the_inspection_only_factory_callback() {
use crate::inference::registry::{
- register_inspection_chat_model_in, ChatModelRequest, InspectionChatModelFactory,
+ register_inspection_chat_model_in, InspectionChatModelFactory,
};
use std::sync::{
atomic::{AtomicUsize, Ordering},
@@ -327,15 +328,17 @@ async fn managed_chat_probe_uses_the_inspection_only_factory_callback() {
let extensions = crate::core::slots::Extensions::new();
let calls = Arc::new(AtomicUsize::new(0));
let model_calls = Arc::clone(&calls);
- let factory: InspectionChatModelFactory = Arc::new(move |request: &ChatModelRequest<'_>| {
- assert_eq!(request.role, "chat");
- Ok(crate::inference::registry::InspectionChatModelBuild {
- model: Arc::new(CountingModel(Arc::clone(&model_calls))) as Arc<dyn ChatModel<()>>,
- model_id: "managed-test-model".into(),
- endpoint: "https://managed.test/openai/v1".into(),
- credential: "frozen-managed-test-token".into(),
- })
- });
+ let factory: InspectionChatModelFactory = Arc::new(
+ move |request: &ChatModelRequest<'_, crate::inference::registry::ProviderContext>| {
+ assert_eq!(request.role, "chat");
+ Ok(crate::inference::registry::InspectionChatModelBuild {
+ model: Arc::new(CountingModel(Arc::clone(&model_calls))) as Arc<dyn ChatModel<()>>,
+ model_id: "managed-test-model".into(),
+ endpoint: "https://managed.test/openai/v1".into(),
+ credential: "frozen-managed-test-token".into(),
+ })
+ },
+ );
register_inspection_chat_model_in(&extensions, "openhuman", factory);
let mut fixture = isolated_config();
diff --git a/crates/openhuman-core/src/doctor/inference_catalog_tests.rs b/crates/openhuman-core/src/doctor/inference_catalog_tests.rs
index 4909d945ef..b18043fe8a 100644
--- a/crates/openhuman-core/src/doctor/inference_catalog_tests.rs
+++ b/crates/openhuman-core/src/doctor/inference_catalog_tests.rs
@@ -16,6 +16,7 @@ use std::sync::{
Arc,
};
use std::time::Duration;
+use tinyinference_llm::providers::overrides::{CatalogEntry, CatalogListing};
#[derive(Clone)]
struct CatalogServerState {
@@ -519,8 +520,7 @@ async fn a_slow_provider_times_out_without_blocking_the_other_catalog() {
async fn doctor_models_uses_read_only_http_without_calling_the_mutable_catalog() {
use crate::core::runtime::{CoreContext, DomainSet};
use crate::core::slots::Extensions;
- use crate::core::Outcome;
- use crate::inference::registry::{register_catalog_in, CatalogEntry, CatalogListing};
+ use crate::inference::registry::register_catalog_in;
let (endpoint, server) =
spawn_catalog_server(StatusCode::OK, catalog_body(&["must-not-be-used"]), true).await;
@@ -531,16 +531,14 @@ async fn doctor_models_uses_read_only_http_without_calling_the_mutable_catalog()
);
let normal_calls = Arc::new(AtomicUsize::new(0));
let call_counter = Arc::clone(&normal_calls);
- let ordinary_listing: CatalogListing = Arc::new(move |_, _| {
- let call_counter = Arc::clone(&call_counter);
- Box::pin(async move {
- call_counter.fetch_add(1, Ordering::SeqCst);
- Ok(Outcome::new(
- serde_json::json!({ "models": [{ "id": "must-not-be-used" }] }),
- Vec::new(),
- ))
- })
- });
+ let ordinary_listing: CatalogListing<crate::inference::registry::ProviderContext> =
+ Arc::new(move |_| {
+ let call_counter = Arc::clone(&call_counter);
+ Box::pin(async move {
+ call_counter.fetch_add(1, Ordering::SeqCst);
+ Ok(serde_json::json!({ "models": [{ "id": "must-not-be-used" }] }))
+ })
+ });
let extensions = Extensions::new();
register_catalog_in(
&extensions,
diff --git a/crates/openhuman-core/src/inference/embedding_host/factory.rs b/crates/openhuman-core/src/inference/embedding_host/factory.rs
index a65db783e6..5a768645c4 100644
--- a/crates/openhuman-core/src/inference/embedding_host/factory.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/factory.rs
@@ -4,8 +4,8 @@ use std::sync::Arc;
use crate::config::Config;
use tinyinference_embeddings::factory::{
- CredentialResolver, EmbeddingFactorySettings, ManagedModelFactory,
- create_configured_embedding_model, create_default_embedding_model,
+ create_configured_embedding_model, create_default_embedding_model, CredentialResolver,
+ EmbeddingFactorySettings, ManagedModelFactory,
};
use tinyinference_embeddings::{EmbeddingModel, UnavailableEmbeddingModel};
use tinyinference_providers::route::custom_provider_string;
@@ -69,7 +69,14 @@ fn inspection_managed_factory(config: &Config) -> ManagedModelFactory {
let Some(registered) = crate::inference::registry::inspection_embedding(PROVIDER_OPENHUMAN)
else {
log::debug!("[embeddings::factory] no inspection-safe managed embedder registered");
- return Ok(Box::new(UnavailableEmbeddingModel::new(model, dimensions)));
+ return Ok(Box::new(UnavailableEmbeddingModel::new(
+ model,
+ dimensions,
+ format!(
+ "{} managed embeddings need an inspection-safe hosted provider; none is registered",
+ crate::core::observability::BACKEND_UNAVAILABLE_PREFIX
+ ),
+ )));
};
let (state_dir, secrets_encrypt) = credential_scope(Some(&config));
let context =
diff --git a/crates/openhuman-core/src/inference/embedding_host/rpc/embed.rs b/crates/openhuman-core/src/inference/embedding_host/rpc/embed.rs
index e0fbb5f012..0b905bc62f 100644
--- a/crates/openhuman-core/src/inference/embedding_host/rpc/embed.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/rpc/embed.rs
@@ -3,13 +3,12 @@
use crate::config::Config;
use crate::core::Outcome;
-use super::{LOG_PREFIX, resolve_api_key};
+use super::{resolve_api_key, LOG_PREFIX};
use crate::inference::embedding_host::factory::{
create_embedding_provider_for_inspection, create_embedding_provider_with_config,
credential_resolver, managed_factory, settings,
};
-use tinyinference_embeddings::probe::probe_custom_embeddings;
-use tinyinference_embeddings::verify::{ConnectionTestError, test_embedding_connection_detailed};
+use tinyinference_embeddings::verify::{test_embedding_connection_detailed, ConnectionTestError};
use tinyinference_providers::route::split_custom_provider;
/// Generates embeddings for the given input texts using the currently
diff --git a/crates/openhuman-core/src/inference/model_context_tests.rs b/crates/openhuman-core/src/inference/model_context_tests.rs
index cbfd913cc1..86063645d1 100644
--- a/crates/openhuman-core/src/inference/model_context_tests.rs
+++ b/crates/openhuman-core/src/inference/model_context_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use tinyinference_llm::providers::overrides::{ChatModelEntry, ProviderModelMetadata};
#[test]
fn generic_model_window_patterns_retain_conservative_estimates() {
assert_eq!(context_window_for_model("gemma-3n-e2b"), Some(8_192));
@@ -101,9 +102,7 @@ fn managed_vision_capability_is_absent_without_provider_policy() {
#[test]
fn model_supports_vision_uses_the_scoped_provider_capability_hook() {
use crate::core::slots::Extensions;
- use crate::inference::registry::{
- register_chat_model_in, ChatModelEntry, ProviderModelMetadata,
- };
+ use crate::inference::registry::register_chat_model_in;
use std::sync::Arc;
let extensions = Extensions::new();
diff --git a/crates/openhuman-core/src/inference/ops/models.rs b/crates/openhuman-core/src/inference/ops/models.rs
index cc0c557e29..bf3776067e 100644
--- a/crates/openhuman-core/src/inference/ops/models.rs
+++ b/crates/openhuman-core/src/inference/ops/models.rs
@@ -72,7 +72,8 @@ pub async fn inference_list_models(
let result = match ctx.load_config().await {
Ok(config) => {
providers::models::catalog_listing::list_configured_models_from_config(
- provider_id, &config,
+ provider_id,
+ &config,
)
.await
}
diff --git a/crates/openhuman-core/src/inference/provider/factory.rs b/crates/openhuman-core/src/inference/provider/factory.rs
index 1ab0f105b1..1b14911c9d 100644
--- a/crates/openhuman-core/src/inference/provider/factory.rs
+++ b/crates/openhuman-core/src/inference/provider/factory.rs
@@ -22,13 +22,13 @@ mod managed_backend;
mod routing;
mod subprocess_providers;
-pub(crate) use chat_model::{OpenHumanModelFactory, resolves_to_managed_backend};
pub use chat_model::{
create_chat_model_from_string, create_chat_model_from_string_with_model_id,
create_chat_model_in, create_chat_model_with_model_id_in, probe_inference_readiness,
};
+pub(crate) use chat_model::{resolves_to_managed_backend, OpenHumanModelFactory};
pub(crate) use cloud_slug::resolve_cloud_slug_for;
-pub(crate) use cloud_spec::{CloudCredentialResolver, cloud_provider_spec};
+pub(crate) use cloud_spec::{cloud_provider_spec, CloudCredentialResolver};
pub use credentials::{auth_key_for_slug, lookup_key_for_slug};
pub(crate) use credentials::{
openai_bearer_is_oauth, redact_endpoint_origin, resolve_codex_routing,
@@ -39,12 +39,14 @@ pub(crate) use inspection::{
};
pub(crate) use local_runtime::create_local_chat_model_from_string;
pub(crate) use routing::fallback_diagnostics_for_role;
-pub(crate) use routing::{ConfigRouteSource, workload_router};
pub use routing::{provider_for_role, role_bypasses_managed_credits};
+pub(crate) use routing::{workload_router, ConfigRouteSource};
// Factory-internal helpers shared across the implementation modules.
use access_gates::{emit_inference_egress, enforce_local_only_inference};
-use chat_model::{unresolved_chat_model_error, with_default_temperature};
+use chat_model::{
+ unresolved_chat_model_error, unresolved_chat_model_error_for_access, with_default_temperature,
+};
#[cfg(test)]
use cloud_slug::try_create_cloud_slug_chat_model;
use cloud_slug::{
@@ -53,16 +55,16 @@ use cloud_slug::{
};
use credentials::CredentialAccess;
use local_runtime::{
- OptionalChatModelResult, try_create_local_runtime_chat_model_for_inspection,
- try_create_local_runtime_chat_model_from_string,
+ try_create_local_runtime_chat_model_for_inspection,
+ try_create_local_runtime_chat_model_from_string, OptionalChatModelResult,
};
use managed_backend::managed_chat_model_for;
pub(crate) use managed_backend::{
make_openhuman_backend_model_for_options, make_openhuman_backend_model_for_thread_in,
};
use subprocess_providers::{
- OpenHumanMcpEndpoint, try_create_claude_agent_sdk_chat_model_for_inspection,
- try_create_claude_code_chat_model_for_inspection,
+ try_create_claude_agent_sdk_chat_model_for_inspection,
+ try_create_claude_code_chat_model_for_inspection, OpenHumanMcpEndpoint,
};
use tinyinference_providers::route::split_model_and_temperature;
@@ -85,15 +87,15 @@ pub mod test_provider_override;
#[path = "factory_tests.rs"]
mod factory_tests;
-use crate::config::Config;
use crate::config::schema::cloud_providers::AuthStyle;
+use crate::config::Config;
use crate::inference::provider::openai_codex::resolve_openai_codex_routing_for_inspection;
use crate::security::egress::EgressLedger;
use std::sync::Arc;
use tinyinference_llm::model::ChatModel;
use tinyinference_llm::providers::openai::codex::{
- OPENAI_CODEX_ACCOUNT_HEADER, OPENAI_CODEX_ORIGINATOR, OPENAI_CODEX_ORIGINATOR_HEADER,
- openai_codex_client_version, openai_codex_user_agent,
+ openai_codex_client_version, openai_codex_user_agent, OPENAI_CODEX_ACCOUNT_HEADER,
+ OPENAI_CODEX_ORIGINATOR, OPENAI_CODEX_ORIGINATOR_HEADER,
};
/// Opaque per-report identity for an inspection completion. It contains the
diff --git a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
index 5faed297e4..a4172ea5ec 100644
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
@@ -10,7 +10,7 @@ use crate::inference::provider::factory::access_gates::verify_session_active;
use crate::inference::provider::fallback_diagnostics;
use tinyinference_llm::providers::anthropic::endpoint_is_anthropic_messages;
use tinyinference_llm::providers::registry::{
- ProviderBuildOptions, ProviderRegistry, resolve_slug_model,
+ resolve_slug_model, ProviderBuildOptions, ProviderRegistry,
};
type CloudSlugInspectionChatModelResult = Option<
diff --git a/crates/openhuman-core/src/inference/provider/factory/cloud_spec_tests.rs b/crates/openhuman-core/src/inference/provider/factory/cloud_spec_tests.rs
index 5ce712f220..8df8286c07 100644
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_spec_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_spec_tests.rs
@@ -88,12 +88,10 @@ fn discovery_request_carries_bearer_auth_and_pins_openrouter_sorting() {
.unwrap()
.expect("openrouter has a listing");
assert_eq!(request.endpoint, "https://openrouter.ai/api/v1");
- assert!(
- request
- .headers
- .iter()
- .any(|(name, value)| name == "Authorization" && value == "Bearer sk-or")
- );
+ assert!(request
+ .headers
+ .iter()
+ .any(|(name, value)| name == "Authorization" && value == "Bearer sk-or"));
}
#[test]
@@ -146,24 +144,18 @@ fn discovery_request_builds_codex_oauth_listing_request() {
"https://chatgpt.com/backend-api/codex/models?client_version=0.130.0"
);
assert_eq!(request.model, "gpt");
- assert!(
- request
- .headers
- .iter()
- .any(|(name, value)| name == "Authorization" && value == "Bearer tok")
- );
- assert!(
- request
- .headers
- .iter()
- .any(|(name, value)| name == "ChatGPT-Account-ID" && value == "account-123")
- );
- assert!(
- request
- .headers
- .iter()
- .any(|(name, value)| name == "originator" && value == "codex_cli_rs")
- );
+ assert!(request
+ .headers
+ .iter()
+ .any(|(name, value)| name == "Authorization" && value == "Bearer tok"));
+ assert!(request
+ .headers
+ .iter()
+ .any(|(name, value)| name == "ChatGPT-Account-ID" && value == "account-123"));
+ assert!(request
+ .headers
+ .iter()
+ .any(|(name, value)| name == "originator" && value == "codex_cli_rs"));
assert!(request.headers.iter().any(|(name, value)| {
name == "User-Agent" && value == "codex_cli_rs/0.0.0 (OpenHuman 0.64.18)"
}));
diff --git a/crates/openhuman-core/src/inference/provider/factory/credentials.rs b/crates/openhuman-core/src/inference/provider/factory/credentials.rs
index aa643de4be..c424816269 100644
--- a/crates/openhuman-core/src/inference/provider/factory/credentials.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/credentials.rs
@@ -3,6 +3,7 @@
use super::*;
use crate::config::ops::legacy_inference_slug;
+use crate::security::credentials::AuthService;
type ReadOnlyProfileCredential = (
String,
diff --git a/crates/openhuman-core/src/inference/provider/factory/inspection.rs b/crates/openhuman-core/src/inference/provider/factory/inspection.rs
index 5a32d96974..ddf50157ff 100644
--- a/crates/openhuman-core/src/inference/provider/factory/inspection.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/inspection.rs
@@ -1,6 +1,8 @@
//! Read-only provider preparation for doctor inspections.
use super::*;
+use crate::config::resolve_primary_cloud_provider_string;
+use crate::core::runtime::DispatchCtx;
/// Build a chat model for static inspection, sharing the runtime constructor
/// while resolving stored credentials through the read-only profile snapshot.
@@ -34,10 +36,7 @@ pub(crate) fn create_chat_model_with_identity_in_for_inspection(
}
if resolves_to_managed_backend(role, config) {
let build = managed_backend::managed_chat_model_build_for_inspection(
- extensions.as_ref(),
- role,
- config,
- None,
+ extensions, role, config, None,
)?;
return Ok(prepared_inspection_model(
build.model,
@@ -84,11 +83,9 @@ pub(crate) fn create_chat_model_with_identity_in_for_inspection(
InspectionOutputBudgetCapability::Bounded,
));
}
- if let Some(result) = try_create_cloud_slug_chat_model_for_inspection_with_identity(
- role,
- config,
- extensions.as_ref(),
- ) {
+ if let Some(result) =
+ try_create_cloud_slug_chat_model_for_inspection_with_identity(role, config, extensions)
+ {
let (model, model_id, endpoint, credential, output_budget) = result?;
return Ok(prepared_inspection_model(
model,
@@ -104,7 +101,7 @@ pub(crate) fn create_chat_model_with_identity_in_for_inspection(
&provider_for_role(role, config),
config,
&EgressLedger::none(),
- extensions.as_ref(),
+ extensions,
CredentialAccess::Inspection,
))
}
diff --git a/crates/openhuman-core/src/inference/provider/factory/local_runtime.rs b/crates/openhuman-core/src/inference/provider/factory/local_runtime.rs
index a9772a3d86..370e5bb93f 100644
--- a/crates/openhuman-core/src/inference/provider/factory/local_runtime.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/local_runtime.rs
@@ -3,8 +3,8 @@
use super::*;
use crate::inference::provider::factory::access_gates::verify_provider_session;
-use tinyinference_llm::providers::openai::AuthStyle as CompatAuthStyle;
use tinyinference_llm::providers::openai::build_local_runtime_chat_model;
+use tinyinference_llm::providers::openai::AuthStyle as CompatAuthStyle;
/// Local OpenAI-compatible runtimes (Ollama / LM Studio / MLX / OMLX /
/// local-openai) as a crate-native [`ChatModel`] (issue #4727).
@@ -79,7 +79,7 @@ fn try_create_local_runtime_chat_model_from_string_with_identity(
inspection_identity: Option<&mut Option<(String, String, String)>>,
) -> OptionalChatModelResult {
use tinyinference_local::local_runtime::{
- LocalRuntimeAuth, LocalRuntimeInputs, resolve_local_runtime,
+ resolve_local_runtime, LocalRuntimeAuth, LocalRuntimeInputs,
};
// Use the same classifier as privacy and session policy. Canonicalize only
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 5cd1b9607a..7241b7e94e 100644
--- a/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs
@@ -7,6 +7,7 @@
//! `BACKEND_UNAVAILABLE:` sentinel.
use super::*;
+use tinyinference_llm::providers::overrides::ChatModelRequest;
type ManagedChatModel = (
std::sync::Arc<dyn tinyinference_llm::model::ChatModel<()>>,
@@ -87,7 +88,7 @@ pub(super) fn managed_chat_model_for(
crate::security::egress::EgressDescriptor::inference("openhuman", &model, true),
);
let context = crate::inference::registry::ProviderContext::new(config, egress);
- let request = crate::inference::registry::ChatModelRequest {
+ let request = tinyinference_llm::providers::overrides::ChatModelRequest {
role,
model_override: Some(&model),
default_model,
@@ -122,16 +123,30 @@ pub(super) fn managed_chat_model_build_for_inspection(
else {
return Err(managed_unavailable_error());
};
- let model = resolve_managed_model(role, config, model_override);
- (factory)(&crate::inference::registry::ChatModelRequest {
+ let overrides = crate::inference::registry::provider_overrides(extensions.cloned());
+ let Some(entry) = overrides.chat_entry(PROVIDER_OPENHUMAN) else {
+ return Err(managed_unavailable_error());
+ };
+ let context = crate::inference::registry::ProviderContext::new(config, &EgressLedger::none());
+ let model = match entry.models.as_ref() {
+ Some(models) => (models.resolve_model)(role, &context, model_override),
+ None => model_override
+ .or(config.default_model.as_deref())
+ .map(str::trim)
+ .filter(|model| !model.is_empty() && !model.starts_with("hint:"))
+ .map(str::to_string),
+ }
+ .ok_or_else(managed_unavailable_error)?;
+ let context = crate::inference::registry::ProviderContext::new(config, &EgressLedger::none());
+ let request = tinyinference_llm::providers::overrides::ChatModelRequest {
role,
- config,
model_override: Some(&model),
default_model: None,
native_tool_calling: true,
thread_id: None,
- egress: &EgressLedger::none(),
- })
+ context: &context,
+ };
+ (factory)(&request)
}
/// Construct a managed turn model with the explicit OpenHuman thread attached.
@@ -224,7 +239,7 @@ pub(crate) fn make_openhuman_backend_model_for_options(
config.secrets.encrypt = options.secrets_encrypt;
let egress = EgressLedger::none();
let context = crate::inference::registry::ProviderContext::new(&config, &egress);
- let request = crate::inference::registry::ChatModelRequest {
+ let request = tinyinference_llm::providers::overrides::ChatModelRequest {
role: "delegate",
model_override: Some(model),
default_model: Some(model),
diff --git a/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs b/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs
index a871a5d70e..109b68a11d 100644
--- a/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use crate::config::Config;
use crate::config::schema::cloud_providers::{AuthStyle, CloudProviderCreds};
+use crate::config::Config;
use crate::inference::provider::factory::resolves_to_managed_backend;
fn byok_openai_compatible_entry() -> CloudProviderCreds {
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_cloud_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_cloud_tests.rs
index 46d535e551..b1cc13afc7 100644
--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_cloud_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_cloud_tests.rs
@@ -1,3 +1,57 @@
+use super::super::super::cloud_slug::{
+ try_create_cloud_slug_chat_model, try_create_cloud_slug_chat_model_from_string,
+ try_create_cloud_slug_chat_model_from_string_with_native_tools,
+};
+use super::super::super::OpenHumanModelFactory;
+use super::super::{
+ anthropic_entry, deepseek_entry, install_test_managed_provider, oh_entry, openai_entry,
+};
+use super::{isolated_config, store_fixture_cloud_key};
+use crate::config::Config;
+use crate::inference::provider::factory::{
+ create_chat_model_from_string_with_model_id, create_chat_model_with_model_id_in,
+};
+use crate::security::egress::EgressLedger;
+use tinyagents_harness::host::{
+ BuildOpts, ModelBuildGate, ModelBuildRequest, ModelFactory, ModelPurpose,
+};
+
+fn build_native_factory_model(
+ config: &Config,
+ pin: Option<&str>,
+ egress: &EgressLedger,
+) -> anyhow::Result<(
+ std::sync::Arc<dyn tinyinference_llm::model::ChatModel<()>>,
+ tinyinference_llm::model::ResolvedModelRoute,
+)> {
+ let ctx = crate::core::runtime::DispatchCtx::ambient();
+ let factory = OpenHumanModelFactory {
+ ctx: &ctx,
+ config,
+ primary_provider: None,
+ egress,
+ thread_id: None,
+ attach_host_attachments: false,
+ };
+ let request = ModelBuildRequest {
+ role: "chat".to_owned(),
+ route: None,
+ purpose: ModelPurpose::Primary,
+ model_pin: pin.map(str::to_owned),
+ opts: BuildOpts {
+ native_tools: true,
+ temperature: None,
+ egress_tag: None,
+ },
+ };
+ factory
+ .check(&request)
+ .map_err(|error| anyhow::anyhow!(error.to_string()))?;
+ factory
+ .build(&request)
+ .map_err(|error| anyhow::anyhow!(error.to_string()))
+}
+
#[test]
fn create_chat_model_routes_plain_bearer_cloud_slug_to_crate_native() {
let _guard = crate::inference::inference_test_guard();
@@ -31,19 +85,12 @@ fn turn_model_route_metadata_uses_post_remap_cloud_model() {
config.cloud_providers.push(deepseek_entry("p_ds"));
config.chat_provider = Some("deepseek:hint:chat".to_string());
- let (_model, provider, resolved_model) = create_turn_chat_model_with_native_tools_and_route(
- &crate::core::runtime::DispatchCtx::ambient(),
- "chat",
- &config,
- "hint:chat",
- 0.7,
- true,
- &EgressLedger::none(),
- )
- .expect("abstract BYOK tier must build");
+ let (_model, route) =
+ build_native_factory_model(&config, Some("hint:chat"), &EgressLedger::none())
+ .expect("abstract BYOK tier must build");
- assert_eq!(provider, "deepseek");
- assert_eq!(resolved_model, "deepseek-chat");
+ assert_eq!(route.provider, "deepseek");
+ assert_eq!(route.model, "deepseek-chat");
}
#[test]
@@ -135,6 +182,7 @@ fn anthropic_auth_cloud_slug_in_text_mode_keeps_the_compat_client() {
#[test]
fn configured_openhuman_jwt_slug_routes_to_managed_chat_model() {
let _guard = crate::inference::inference_test_guard();
+ install_test_managed_provider();
let mut config = Config::default();
config.cloud_providers.push(oh_entry("p_oh"));
// A retired tier slug after the managed slug is a role alias: it runs on
@@ -146,7 +194,7 @@ fn configured_openhuman_jwt_slug_routes_to_managed_chat_model() {
.expect("configured OpenhumanJwt slug should be recognized")
.expect("managed model should build");
- assert_eq!(model_id, crate::config::MODEL_MANAGED_DEFAULT);
+ assert_eq!(model_id, "fixture/managed-default");
// A concrete catalog id is forwarded verbatim.
config.chat_provider = Some("openhuman:openrouter/deepseek/deepseek-v4-pro".to_string());
@@ -170,6 +218,7 @@ async fn openhuman_jwt_slug_discloses_pinned_model() {
use std::time::Duration;
let _guard = crate::inference::inference_test_guard_async().await;
+ install_test_managed_provider();
crate::core::bus::init().await.expect("bus init");
let mut rx = crate::core::bus::BUS.get().unwrap().receiver();
@@ -232,14 +281,8 @@ async fn native_claude_turn_routes_disclose_pinned_models() {
let pinned_sdk = "egress-sdk-pinned-marker";
let mut sdk_config = Config::default();
sdk_config.chat_provider = Some(format!("claude_agent_sdk:{configured_sdk}"));
- create_turn_chat_model(
- &crate::core::runtime::DispatchCtx::ambient(),
- "chat",
- &sdk_config,
- pinned_sdk,
- 0.0,
- )
- .expect("Claude Agent SDK turn model should build");
+ build_native_factory_model(&sdk_config, Some(pinned_sdk), &EgressLedger::none())
+ .expect("Claude Agent SDK turn model should build");
let configured_code = "egress-code-configured-marker";
let pinned_code = "egress-code-pinned-marker";
@@ -248,13 +291,7 @@ async fn native_claude_turn_routes_disclose_pinned_models() {
// Egress is disclosed once the effective model is selected, before the
// environment probe. The test therefore remains valid on hosts without the
// Claude Code CLI.
- let _ = create_turn_chat_model(
- &crate::core::runtime::DispatchCtx::ambient(),
- "chat",
- &code_config,
- pinned_code,
- 0.0,
- );
+ let _ = build_native_factory_model(&code_config, Some(pinned_code), &EgressLedger::none());
let sentinel = "egress-native-claude-sentinel-end";
BUS.publish(DomainEvent::ExternalTransferPending {
@@ -333,6 +370,7 @@ fn openhuman_jwt_slug_preserves_forced_text_mode() {
#[test]
fn openhuman_jwt_slug_without_model_preserves_managed_role_tier() {
let _guard = crate::inference::inference_test_guard();
+ install_test_managed_provider();
let mut config = Config::default();
config.cloud_providers.push(oh_entry("p_oh"));
@@ -345,7 +383,7 @@ fn openhuman_jwt_slug_without_model_preserves_managed_role_tier() {
.expect("configured OpenhumanJwt slug should be recognized")
.expect("managed model should build");
- assert_eq!(model_id, crate::config::MODEL_MANAGED_DEFAULT);
+ assert_eq!(model_id, "fixture/managed-default");
}
#[test]
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
index 2d7a99ef7e..c64ba60e24 100644
--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
@@ -1,3 +1,4 @@
+use super::super::cloud_slug::try_create_cloud_slug_chat_model_from_string;
use super::*;
use crate::security::egress::EgressLedger;
@@ -125,11 +126,9 @@ fn enforce_local_only_inference_errors_on_external_when_local_only() {
Err(error) => error,
Ok(_) => panic!("direct Claude Code model must preserve the privacy gate"),
};
- assert!(
- claude_code_error
- .to_string()
- .contains("Local-only privacy mode")
- );
+ assert!(claude_code_error
+ .to_string()
+ .contains("Local-only privacy mode"));
// Both the default factory and a thread-attached managed picker route must
// hit the managed resolver's privacy gate before any backend client exists.
@@ -365,27 +364,23 @@ fn explicit_local_provider_string_routes_to_crate_native_model() {
fn try_create_local_runtime_returns_none_for_managed_and_cloud() {
let _guard = crate::inference::inference_test_guard();
// Default config resolves to the managed backend, not a local runtime.
- assert!(
- super::local_runtime::try_create_local_runtime_chat_model(
- "chat",
- &Config::default(),
- &EgressLedger::none(),
- )
- .is_none()
- );
+ assert!(super::local_runtime::try_create_local_runtime_chat_model(
+ "chat",
+ &Config::default(),
+ &EgressLedger::none(),
+ )
+ .is_none());
// A BYOK cloud slug is not a local runtime either — it falls through to the
// `Provider` path.
let mut cloud = Config::default();
cloud.cloud_providers.push(openai_entry("p_oai", "openai"));
cloud.chat_provider = Some("openai:gpt-4o-mini".to_string());
- assert!(
- super::local_runtime::try_create_local_runtime_chat_model(
- "chat",
- &cloud,
- &EgressLedger::none(),
- )
- .is_none()
- );
+ assert!(super::local_runtime::try_create_local_runtime_chat_model(
+ "chat",
+ &cloud,
+ &EgressLedger::none(),
+ )
+ .is_none());
}
#[test]
@@ -469,11 +464,9 @@ fn create_chat_model_routes_anthropic_auth_cloud_slug_to_crate_native() {
identity.starts_with("anthropic:https://api.anthropic.com/v1:claude-sonnet-4-6"),
"expected the native Messages adapter, got identity {identity}"
);
- assert!(
- model
- .profile()
- .is_some_and(|p| p.tool_calling && p.streaming)
- );
+ assert!(model
+ .profile()
+ .is_some_and(|p| p.tool_calling && p.streaming));
}
/// Text mode (prompt-guided tools) is only implemented on the Chat Completions
diff --git a/crates/openhuman-core/src/inference/provider/factory_explicit_ctx_tests.rs b/crates/openhuman-core/src/inference/provider/factory_explicit_ctx_tests.rs
index edb5ef77a0..dfe26a72b1 100644
--- a/crates/openhuman-core/src/inference/provider/factory_explicit_ctx_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_explicit_ctx_tests.rs
@@ -1,10 +1,13 @@
use super::*;
+use tinyinference_llm::providers::overrides::{
+ CatalogEntry, ChatModelEntry, ProviderModelMetadata,
+};
#[tokio::test]
async fn managed_factory_and_probe_use_the_explicit_provider_entry() {
use crate::core::runtime::{CoreContext, DispatchCtx, DomainSet};
use crate::core::slots::Extensions;
- use crate::inference::registry::{ChatModelEntry, ProviderContext, ProviderModelMetadata};
+ use crate::inference::registry::ProviderContext;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use tinyinference_llm::message::Message;
@@ -133,9 +136,7 @@ async fn hosted_cloud_slug_uses_explicit_auth_policy_and_model_entry() {
};
use crate::core::runtime::{CoreContext, DispatchCtx, DomainSet};
use crate::core::slots::Extensions;
- use crate::inference::registry::{
- register_catalog_in, CatalogEntry, ChatModelEntry, ProviderContext, ProviderModelMetadata,
- };
+ use crate::inference::registry::{register_catalog_in, ProviderContext};
use std::sync::Arc;
use tinyinference_llm::message::Message;
use tinyinference_llm::model::ModelRequest;
diff --git a/crates/openhuman-core/src/inference/provider/factory_managed_ledger_tests.rs b/crates/openhuman-core/src/inference/provider/factory_managed_ledger_tests.rs
index b0b33c951d..dcc5449907 100644
--- a/crates/openhuman-core/src/inference/provider/factory_managed_ledger_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_managed_ledger_tests.rs
@@ -35,7 +35,7 @@ async fn managed_construction_ledger_collapses_repeat_disclosures() {
let provider_id = crate::inference::provider::factory::PROVIDER_OPENHUMAN;
crate::inference::registry::register_chat_model(
provider_id,
- crate::inference::registry::ChatModelEntry {
+ tinyinference_llm::providers::overrides::ChatModelEntry {
build: Arc::new(|request| {
let model = request
.model_override
@@ -44,23 +44,25 @@ async fn managed_construction_ledger_collapses_repeat_disclosures() {
Ok((Arc::new(LedgerTestModel), model))
}),
probe: None,
- models: Some(crate::inference::registry::ProviderModelMetadata {
- default_model: Arc::new(|| Some("fixture-model".to_string())),
- role_for_model: Arc::new(|_| None),
- is_alias: Arc::new(|_| false),
- is_raw_model: Arc::new(|model| !model.starts_with("hint:")),
- supports_vision: Arc::new(|_| false),
- resolve_model: Arc::new(|_, config, model| {
- model
- .map(str::trim)
- .filter(|model| !model.is_empty() && !model.starts_with("hint:"))
- .map(str::to_string)
- .or_else(|| config.config.default_model.clone())
- }),
- context_window: Arc::new(|_| None),
- default_pricing: Arc::new(|| None),
- without_reasoning: Arc::new(|request| request),
- }),
+ models: Some(
+ tinyinference_llm::providers::overrides::ProviderModelMetadata {
+ default_model: Arc::new(|| Some("fixture-model".to_string())),
+ role_for_model: Arc::new(|_| None),
+ is_alias: Arc::new(|_| false),
+ is_raw_model: Arc::new(|model| !model.starts_with("hint:")),
+ supports_vision: Arc::new(|_| false),
+ resolve_model: Arc::new(|_, config, model| {
+ model
+ .map(str::trim)
+ .filter(|model| !model.is_empty() && !model.starts_with("hint:"))
+ .map(str::to_string)
+ .or_else(|| config.config.default_model.clone())
+ }),
+ context_window: Arc::new(|_| None),
+ default_pricing: Arc::new(|| None),
+ without_reasoning: Arc::new(|request| request),
+ },
+ ),
},
);
let build = |ledger: &EgressLedger| {
diff --git a/crates/openhuman-core/src/inference/provider/factory_tests.rs b/crates/openhuman-core/src/inference/provider/factory_tests.rs
index 9bbc543ff7..ebd3e3180c 100644
--- a/crates/openhuman-core/src/inference/provider/factory_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_tests.rs
@@ -43,8 +43,8 @@ impl ChatModel<()> for ManagedRouteFixtureModel {
fn install_test_managed_provider() -> Arc<std::sync::Mutex<Vec<bool>>> {
use crate::config::schema::cloud_providers::AuthStyle;
- use crate::inference::registry::{ChatModelEntry, ProviderModelMetadata};
use std::sync::Mutex;
+ use tinyinference_llm::providers::overrides::{ChatModelEntry, ProviderModelMetadata};
let native_modes = Arc::new(Mutex::new(Vec::new()));
let seen = Arc::clone(&native_modes);
@@ -174,7 +174,7 @@ fn inspection_requires_credentials_for_explicit_authenticated_cloud_routes() {
let mut config = config_with_providers_in_tempdir(&tmp, vec![provider.clone()]);
config.chat_provider = Some("factory-missing-key-test:gpt-4o".to_string());
- let inspection = super::chat_model::create_chat_model_with_model_id_in_for_inspection(
+ let inspection = super::inspection::create_chat_model_with_model_id_in_for_inspection(
&crate::core::runtime::DispatchCtx::ambient(),
"chat",
&config,
@@ -199,7 +199,7 @@ fn inspection_requires_credentials_for_explicit_authenticated_cloud_routes() {
provider.auth_style = AuthStyle::Anthropic;
config.cloud_providers = vec![provider.clone()];
assert!(
- super::chat_model::create_chat_model_with_model_id_in_for_inspection(
+ super::inspection::create_chat_model_with_model_id_in_for_inspection(
&crate::core::runtime::DispatchCtx::ambient(),
"chat",
&config,
@@ -212,7 +212,7 @@ fn inspection_requires_credentials_for_explicit_authenticated_cloud_routes() {
provider.auth_style = AuthStyle::None;
config.cloud_providers = vec![provider];
assert!(
- super::chat_model::create_chat_model_with_model_id_in_for_inspection(
+ super::inspection::create_chat_model_with_model_id_in_for_inspection(
&crate::core::runtime::DispatchCtx::ambient(),
"chat",
&config,
@@ -418,7 +418,7 @@ async fn inspection_construction_does_not_refresh_unselected_expired_codex_oauth
provider.endpoint = "https://api.openai.example.test/v1".into();
config.cloud_providers = vec![provider];
config.chat_provider = Some("openai:gpt-4o".into());
- let inspected = super::chat_model::create_chat_model_with_model_id_in_for_inspection(
+ let inspected = super::inspection::create_chat_model_with_model_id_in_for_inspection(
&crate::core::runtime::DispatchCtx::ambient(),
"chat",
&config,
diff --git a/crates/openhuman-core/src/inference/provider/mod.rs b/crates/openhuman-core/src/inference/provider/mod.rs
index 546468f36c..cd4751bb16 100644
--- a/crates/openhuman-core/src/inference/provider/mod.rs
+++ b/crates/openhuman-core/src/inference/provider/mod.rs
@@ -9,6 +9,7 @@ pub mod factory;
pub(crate) mod fallback_diagnostics;
pub mod http_error;
pub mod models;
+pub(crate) mod openai_codex;
pub use factory::{
create_chat_model_from_string, create_chat_model_from_string_with_model_id,
diff --git a/crates/openhuman-core/src/inference/provider/models/catalog_listing.rs b/crates/openhuman-core/src/inference/provider/models/catalog_listing.rs
index a1a3ca0d33..4bb9210cae 100644
--- a/crates/openhuman-core/src/inference/provider/models/catalog_listing.rs
+++ b/crates/openhuman-core/src/inference/provider/models/catalog_listing.rs
@@ -15,6 +15,7 @@ use tinyinference_llm::providers::openai::codex::{
openai_codex_client_version, openai_codex_user_agent, OpenAiCodexRouting,
OPENAI_CODEX_ACCOUNT_HEADER, OPENAI_CODEX_ORIGINATOR, OPENAI_CODEX_ORIGINATOR_HEADER,
};
+use tinyinference_llm::providers::overrides::CatalogEntry;
/// Resolve the API key used to probe a provider's `/models` endpoint.
///
diff --git a/crates/openhuman-core/src/inference/provider_model_tests.rs b/crates/openhuman-core/src/inference/provider_model_tests.rs
index 012fe64f1b..f4a032b0c9 100644
--- a/crates/openhuman-core/src/inference/provider_model_tests.rs
+++ b/crates/openhuman-core/src/inference/provider_model_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use tinyinference_llm::providers::overrides::{ChatModelEntry, ProviderModelMetadata};
#[test]
fn absent_provider_keeps_default_absent_and_concrete_model_ids_verbatim() {
@@ -33,9 +34,7 @@ fn abstract_hint_markers_do_not_become_raw_model_ids() {
#[test]
fn registered_model_defaults_and_aliases_are_context_scoped() {
use crate::core::slots::Extensions;
- use crate::inference::registry::{
- register_chat_model_in, ChatModelEntry, ProviderModelMetadata,
- };
+ use crate::inference::registry::register_chat_model_in;
use std::sync::Arc;
let extensions = Extensions::new();
@@ -225,8 +224,7 @@ fn registered_model_defaults_and_aliases_are_context_scoped() {
fn native_provider_metadata_resolves_by_context_and_preserves_request_fields() {
use crate::core::slots::Extensions;
use crate::inference::registry::{
- register_chat_model, register_chat_model_in, unregister_chat_model, ChatModelEntry,
- ProviderContext, ProviderModelMetadata,
+ register_chat_model, register_chat_model_in, unregister_chat_model, ProviderContext,
};
use serde_json::json;
use std::sync::Arc;
@@ -400,7 +398,7 @@ fn native_provider_metadata_resolves_by_context_and_preserves_request_fields() {
fn managed_options_builder_uses_the_ambient_native_provider_entry() {
use crate::core::slots::Extensions;
use crate::inference::registry::{
- register_chat_model_in, unregister_chat_model, ChatModelEntry, ProviderContext,
+ register_chat_model_in, unregister_chat_model, ProviderContext,
};
use std::sync::Arc;
@@ -449,9 +447,7 @@ fn managed_options_builder_uses_the_ambient_native_provider_entry() {
#[test]
fn managed_builder_uses_the_entry_selected_before_metadata_resolution() {
use crate::core::slots::Extensions;
- use crate::inference::registry::{
- register_chat_model_in, ChatModelEntry, ProviderContext, ProviderModelMetadata,
- };
+ use crate::inference::registry::{register_chat_model_in, ProviderContext};
use std::sync::Arc;
let _guard = crate::inference::inference_test_guard();
diff --git a/crates/openhuman-core/src/inference/readiness_tests.rs b/crates/openhuman-core/src/inference/readiness_tests.rs
index 2b9973e551..31cc07b12b 100644
--- a/crates/openhuman-core/src/inference/readiness_tests.rs
+++ b/crates/openhuman-core/src/inference/readiness_tests.rs
@@ -1,13 +1,12 @@
use super::*;
use tempfile::TempDir;
+use tinyinference_llm::providers::overrides::{ChatModelEntry, ProviderModelMetadata};
#[tokio::test]
async fn cached_probe_serves_definitive_negative_results() {
use crate::core::runtime::{CoreContext, DispatchCtx, DomainSet};
use crate::core::slots::Extensions;
- use crate::inference::registry::{
- register_chat_model_in, ChatModelEntry, ProviderModelMetadata,
- };
+ use crate::inference::registry::register_chat_model_in;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
diff --git a/crates/openhuman-core/src/inference/registry.rs b/crates/openhuman-core/src/inference/registry.rs
index fb46efad1c..c5d6b0ee63 100644
--- a/crates/openhuman-core/src/inference/registry.rs
+++ b/crates/openhuman-core/src/inference/registry.rs
@@ -22,8 +22,8 @@ use tinyinference_embeddings::EmbeddingModel;
use tinyinference_llm::model::ChatModel;
use crate::config::Config;
-use crate::core::Outcome;
use crate::core::slots::{Extensions, HookSlot};
+use crate::core::Outcome;
use crate::security::approval::ApprovalChatContext;
use crate::security::egress::EgressLedger;
@@ -108,9 +108,8 @@ impl ProviderContext {
}
use tinyinference_llm::providers::overrides::{
- BoxFuture, CatalogEntry, CatalogLimits, CatalogRequest, ChatModelEntry, ChatModelFactory,
- ChatModelRequest, EmbeddingFactory, EmbeddingRequest, ProviderModelMetadata, ProviderOverrides,
- ReadinessProbe,
+ BoxFuture, CatalogEntry, ChatModelEntry, ChatModelRequest, EmbeddingFactory, EmbeddingRequest,
+ ProviderModelMetadata, ProviderOverrides,
};
pub(crate) fn provider_overrides(
@@ -225,7 +224,11 @@ pub struct InspectionChatModelBuild {
/// Inspection-safe provider callback. Unlike the runtime callback this must
/// return the same frozen route identity used by the model invocation.
pub type PreparedInspectionChatModelFactory = Arc<
- dyn for<'a> Fn(&ChatModelRequest<'a>) -> anyhow::Result<InspectionChatModelBuild> + Send + Sync,
+ dyn for<'a> Fn(
+ &ChatModelRequest<'a, ProviderContext>,
+ ) -> anyhow::Result<InspectionChatModelBuild>
+ + Send
+ + Sync,
>;
static INSPECTION_CHAT_MODELS: HookSlot<InspectionChatModelFactory> =
@@ -479,7 +482,7 @@ static EMBEDDINGS: HookSlot<EmbeddingFactory<ProviderContext>> =
/// A managed embedding factory safe for doctor inspection: it uses a frozen
/// credential snapshot and never refreshes or publishes credential state.
-pub type InspectionEmbeddingFactory = EmbeddingFactory;
+pub type InspectionEmbeddingFactory = EmbeddingFactory<ProviderContext>;
static INSPECTION_EMBEDDINGS: HookSlot<InspectionEmbeddingFactory> =
HookSlot::new("inference::inspection-embeddings");
@@ -488,7 +491,7 @@ static INSPECTION_EMBEDDINGS: HookSlot<InspectionEmbeddingFactory> =
pub fn register_inspection_embedding<F>(provider_id: impl Into<String>, factory: F)
where
F: for<'a> Fn(
- &EmbeddingRequest<'a>,
+ &EmbeddingRequest<'a, ProviderContext>,
) -> tinyinference_embeddings::Result<Box<dyn EmbeddingModel>>
+ Send
+ Sync
@@ -504,7 +507,7 @@ pub fn register_inspection_embedding_in<F>(
factory: F,
) where
F: for<'a> Fn(
- &EmbeddingRequest<'a>,
+ &EmbeddingRequest<'a, ProviderContext>,
) -> tinyinference_embeddings::Result<Box<dyn EmbeddingModel>>
+ Send
+ Sync
diff --git a/crates/openhuman-core/src/inference/registry_tests.rs b/crates/openhuman-core/src/inference/registry_tests.rs
index ff58761025..56750fa6b0 100644
--- a/crates/openhuman-core/src/inference/registry_tests.rs
+++ b/crates/openhuman-core/src/inference/registry_tests.rs
@@ -1,14 +1,19 @@
use super::*;
use crate::inference::context_window::model_limits_request;
use crate::inference::provider::factory::{
- PROVIDER_OPENHUMAN, create_chat_model_from_string, make_openhuman_backend_model_for_thread,
+ create_chat_model_from_string, create_chat_model_with_identity_in_for_inspection,
+ make_openhuman_backend_model_for_thread_in, PROVIDER_OPENHUMAN,
};
use async_trait::async_trait;
-use std::sync::Mutex;
use std::sync::atomic::{AtomicUsize, Ordering};
-use tinyinference_llm::model::ChatModel;
+use std::sync::Mutex;
use tinyinference_llm::model::discover::DiscoveryRequest;
+use tinyinference_llm::model::ChatModel;
use tinyinference_llm::model::{ModelRequest, ModelResponse};
+use tinyinference_llm::providers::overrides::CatalogRequest;
+use tinyinference_llm::providers::overrides::{
+ CatalogEntry, ChatModelEntry, ProviderModelMetadata,
+};
type SeenModelRequests = Arc<Mutex<Vec<(String, Option<String>, Option<String>)>>>;
@@ -79,7 +84,8 @@ async fn a_registered_chat_model_serves_the_managed_provider_for_a_thread() {
let seen = Arc::default();
register_chat_model(PROVIDER_OPENHUMAN, fake_entry(Arc::clone(&seen)));
- let built = make_openhuman_backend_model_for_thread(
+ let built = make_openhuman_backend_model_for_thread_in(
+ None,
"chat",
&Config::default(),
Some("hint:reasoning"),
@@ -204,7 +210,8 @@ fn a_registered_catalog_supplies_the_managed_limits_request() {
fn selecting_the_managed_provider_with_nothing_registered_is_backend_unavailable() {
let _guard = crate::inference::inference_test_guard();
let _exclusive = crate::inference::provider::factory::test_provider_override::exclusive();
- let error = make_openhuman_backend_model_for_thread(
+ let error = make_openhuman_backend_model_for_thread_in(
+ None,
"chat",
&Config::default(),
Some("any-model"),
@@ -231,7 +238,7 @@ fn selecting_the_managed_provider_with_nothing_registered_is_backend_unavailable
#[tokio::test]
async fn a_registered_catalog_receives_the_entrys_provider_key() {
use crate::config::schema::cloud_providers::{AuthStyle, CloudProviderCreds};
- use crate::config::schema::{EPHEMERAL_ROUTE_SLUG, EphemeralRoute};
+ use crate::config::schema::{EphemeralRoute, EPHEMERAL_ROUTE_SLUG};
let seen = Arc::new(Mutex::new(String::new()));
crate::config::schema::cloud_providers::register_hosted_cloud_provider_policy(
Arc::new(|slug| slug == EPHEMERAL_ROUTE_SLUG),
@@ -285,17 +292,17 @@ async fn a_registered_catalog_receives_the_entrys_provider_key() {
fn inspection_model_factory_uses_the_callers_context_before_process_fallback() {
use crate::core::slots::Extensions;
use crate::inference::registry::{
- InspectionChatModelBuild, PreparedInspectionChatModelFactory,
register_inspection_chat_model, register_inspection_chat_model_in,
- unregister_inspection_chat_model,
+ unregister_inspection_chat_model, InspectionChatModelBuild,
+ PreparedInspectionChatModelFactory,
};
let _guard = crate::inference::inference_test_guard();
let factory = |endpoint: &'static str| -> PreparedInspectionChatModelFactory {
- Arc::new(move |_| {
+ Arc::new(move |request| {
Ok(InspectionChatModelBuild {
model: Arc::new(FakeModel),
- model_id: endpoint.to_owned(),
+ model_id: request.context.config.default_model.clone().unwrap(),
endpoint: format!("https://{endpoint}.example/v1"),
credential: format!("{endpoint}-credential"),
})
@@ -304,22 +311,47 @@ fn inspection_model_factory_uses_the_callers_context_before_process_fallback() {
register_inspection_chat_model(PROVIDER_OPENHUMAN, factory("process"));
let a = Extensions::new();
register_inspection_chat_model_in(&a, PROVIDER_OPENHUMAN, factory("context-a"));
+ let context_a = crate::core::runtime::DispatchCtx::new(
+ crate::core::runtime::CoreContext::for_test_with_host_kind_and_extensions(
+ crate::core::types::HostKind::Library,
+ crate::core::runtime::DomainSet::full(),
+ None,
+ a,
+ ),
+ );
let b = Extensions::new();
register_inspection_chat_model_in(&b, PROVIDER_OPENHUMAN, factory("context-b"));
+ let context_b = crate::core::runtime::DispatchCtx::new(
+ crate::core::runtime::CoreContext::for_test_with_host_kind_and_extensions(
+ crate::core::types::HostKind::Library,
+ crate::core::runtime::DomainSet::full(),
+ None,
+ b,
+ ),
+ );
- let config = Config::default();
- let build_a = crate::inference::provider::factory::managed_backend::
- managed_chat_model_build_for_inspection(Some(&a), "chat", &config, None)
- .expect("context A inspection provider");
- let build_b = crate::inference::provider::factory::managed_backend::
- managed_chat_model_build_for_inspection(Some(&b), "chat", &config, None)
- .expect("context B inspection provider");
- let build_process = crate::inference::provider::factory::managed_backend::
- managed_chat_model_build_for_inspection(None, "chat", &config, None)
- .expect("process inspection provider");
+ let mut config_a = Config::default();
+ config_a.default_model = Some("context-a".into());
+ let mut config_b = Config::default();
+ config_b.default_model = Some("context-b".into());
+ let mut config_process = Config::default();
+ config_process.default_model = Some("process".into());
+ let build_a =
+ create_chat_model_with_identity_in_for_inspection(&context_a, "chat", &config_a, 0.0)
+ .expect("context A inspection provider");
+ let build_b =
+ create_chat_model_with_identity_in_for_inspection(&context_b, "chat", &config_b, 0.0)
+ .expect("context B inspection provider");
+ let build_process = create_chat_model_with_identity_in_for_inspection(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ "chat",
+ &config_process,
+ 0.0,
+ )
+ .expect("process inspection provider");
unregister_inspection_chat_model(PROVIDER_OPENHUMAN);
- assert_eq!(build_a.endpoint, "https://context-a.example/v1");
- assert_eq!(build_b.endpoint, "https://context-b.example/v1");
- assert_eq!(build_process.endpoint, "https://process.example/v1");
+ assert_eq!(build_a.model_id, "context-a");
+ assert_eq!(build_b.model_id, "context-b");
+ assert_eq!(build_process.model_id, "process");
}
diff --git a/crates/openhuman-core/src/inference/turn_models_native_tests.rs b/crates/openhuman-core/src/inference/turn_models_native_tests.rs
index 716ed46aac..ad79113bf9 100644
--- a/crates/openhuman-core/src/inference/turn_models_native_tests.rs
+++ b/crates/openhuman-core/src/inference/turn_models_native_tests.rs
@@ -266,7 +266,7 @@ async fn injected_turn_profile_is_authoritative_and_skips_unselected_routes() {
crate::inference::registry::register_chat_model_in(
&extensions,
crate::inference::provider::factory::PROVIDER_OPENHUMAN,
- crate::inference::registry::ChatModelEntry {
+ tinyinference_llm::providers::overrides::ChatModelEntry {
build: Arc::new(move |_| {
count.fetch_add(1, Ordering::SeqCst);
Ok((Arc::new(NamedModel("unselected")), "unselected".into()))
diff --git a/crates/openhuman-core/src/inference/turn_models_tests.rs b/crates/openhuman-core/src/inference/turn_models_tests.rs
index 2776866e64..b1cf47ada4 100644
--- a/crates/openhuman-core/src/inference/turn_models_tests.rs
+++ b/crates/openhuman-core/src/inference/turn_models_tests.rs
@@ -31,10 +31,14 @@ use tinyagents_harness::host::PrebuiltModelResolver as TurnModelResolver;
fn scoped_model_entry(
name: &'static str,
supports_vision: bool,
-) -> crate::inference::registry::ChatModelEntry<crate::inference::registry::ProviderContext> {
- use crate::inference::registry::ProviderModelMetadata;
-
- crate::inference::registry::ChatModelEntry::<crate::inference::registry::ProviderContext> {
+) -> tinyinference_llm::providers::overrides::ChatModelEntry<
+ crate::inference::registry::ProviderContext,
+> {
+ use tinyinference_llm::providers::overrides::ProviderModelMetadata;
+
+ tinyinference_llm::providers::overrides::ChatModelEntry::<
+ crate::inference::registry::ProviderContext,
+ > {
build: Arc::new(move |_| Ok((Arc::new(NamedModel(name)), name.to_string()))),
probe: None,
models: Some(ProviderModelMetadata {
@@ -192,7 +196,9 @@ async fn role_pins_apply_when_the_primary_uses_config_routing() {
crate::inference::registry::register_chat_model_in(
&extensions,
crate::inference::provider::factory::PROVIDER_OPENHUMAN,
- crate::inference::registry::ChatModelEntry::<crate::inference::registry::ProviderContext> {
+ tinyinference_llm::providers::overrides::ChatModelEntry::<
+ crate::inference::registry::ProviderContext,
+ > {
build: Arc::new(|_| {
Ok((
Arc::new(NamedModel("managed fixture")),
@@ -200,28 +206,30 @@ async fn role_pins_apply_when_the_primary_uses_config_routing() {
))
}),
probe: None,
- models: Some(crate::inference::registry::ProviderModelMetadata {
- default_model: Arc::new(|| Some("fixture/managed-default".into())),
- role_for_model: Arc::new(|model| {
- model
- .strip_prefix("hint:")
- .filter(|role| matches!(*role, "chat" | "coding" | "summarization"))
- .map(str::to_string)
- }),
- is_alias: Arc::new(|model| model.starts_with("hint:")),
- is_raw_model: Arc::new(|model| !model.starts_with("hint:")),
- supports_vision: Arc::new(|_| false),
- resolve_model: Arc::new(|_, config, model| {
- model
- .filter(|model| !model.starts_with("hint:"))
- .map(str::to_string)
- .or_else(|| config.config.default_model.clone())
- .or_else(|| Some("fixture/managed-default".into()))
- }),
- context_window: Arc::new(|_| None),
- default_pricing: Arc::new(|| None),
- without_reasoning: Arc::new(|request| request),
- }),
+ models: Some(
+ tinyinference_llm::providers::overrides::ProviderModelMetadata {
+ default_model: Arc::new(|| Some("fixture/managed-default".into())),
+ role_for_model: Arc::new(|model| {
+ model
+ .strip_prefix("hint:")
+ .filter(|role| matches!(*role, "chat" | "coding" | "summarization"))
+ .map(str::to_string)
+ }),
+ is_alias: Arc::new(|model| model.starts_with("hint:")),
+ is_raw_model: Arc::new(|model| !model.starts_with("hint:")),
+ supports_vision: Arc::new(|_| false),
+ resolve_model: Arc::new(|_, config, model| {
+ model
+ .filter(|model| !model.starts_with("hint:"))
+ .map(str::to_string)
+ .or_else(|| config.config.default_model.clone())
+ .or_else(|| Some("fixture/managed-default".into()))
+ }),
+ context_window: Arc::new(|_| None),
+ default_pricing: Arc::new(|| None),
+ without_reasoning: Arc::new(|request| request),
+ },
+ ),
},
);
let mut overrides = HostOverrides::default();
diff --git a/crates/openhuman-core/src/tools/rules/ops.rs b/crates/openhuman-core/src/tools/rules/ops.rs
index 1e3f31592b..18380adc0b 100644
--- a/crates/openhuman-core/src/tools/rules/ops.rs
+++ b/crates/openhuman-core/src/tools/rules/ops.rs
@@ -149,6 +149,7 @@ pub fn child_rule_policy(
Some(Arc::new(ToolRulePolicy {
rules: Arc::new(set),
context,
+ permission_ceiling: parent.and_then(|parent| parent.permission_ceiling),
}))
}
@@ -184,5 +185,9 @@ impl crate::agent::tinyagents::host::OpenHumanRunContext {
/// The harness policy for one turn: `rules` evaluated in `context`.
#[must_use]
pub fn turn_rule_policy(rules: Arc<ToolRuleSet>, context: RuleContext) -> ToolRulePolicy {
- ToolRulePolicy { rules, context }
+ ToolRulePolicy {
+ rules,
+ context,
+ permission_ceiling: None,
+ }
}
diff --git a/crates/openhuman-core/src/tools/rules/ops_tests.rs b/crates/openhuman-core/src/tools/rules/ops_tests.rs
index 275247cd51..eab66c95e5 100644
--- a/crates/openhuman-core/src/tools/rules/ops_tests.rs
+++ b/crates/openhuman-core/src/tools/rules/ops_tests.rs
@@ -6,7 +6,7 @@ use crate::agent_registry::host_definition::AgentDefinition;
use crate::config::Config;
use tinytools::ToolRuleSet;
-use tinytools::{Surface, ToolSubject};
+use tinytools::{PermissionLevel, Surface, ToolSubject};
fn definition(id: &str) -> AgentDefinition {
crate::agent_registry::agents::load_builtins()
@@ -165,11 +165,13 @@ fn a_child_inherits_operator_layers_but_not_its_parents_agent_layer() {
Some("orchestrator"),
Some("ExternalChannel(telegram)"),
),
- );
+ )
+ .with_permission_ceiling(PermissionLevel::ReadOnly);
let mut worker = definition("code_executor");
worker.disallowed_tools = vec!["web_*".into()];
let child = child_rule_policy(Some(&parent), None, &worker).expect("child rules");
+ assert_eq!(child.permission_ceiling, Some(PermissionLevel::ReadOnly));
assert_eq!(child.context.get("agent"), Some("code_executor"));
assert_eq!(child.context.get("channel"), Some("telegram"));
assert!(
diff --git a/crates/openhuman-core/src/web_chat/suggestions_tests.rs b/crates/openhuman-core/src/web_chat/suggestions_tests.rs
index f656e551bf..bd2e412b08 100644
--- a/crates/openhuman-core/src/web_chat/suggestions_tests.rs
+++ b/crates/openhuman-core/src/web_chat/suggestions_tests.rs
@@ -7,10 +7,11 @@ use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};
use super::*;
use crate::inference::provider::factory::test_provider_override;
use crate::inference::provider::factory::PROVIDER_OPENHUMAN;
-use crate::inference::registry::{
- ChatModelEntry, ChatModelRequest, ProviderContext, ProviderModelMetadata,
-};
+use crate::inference::registry::ProviderContext;
use crate::web_chat::subscribe_web_channel_events;
+use tinyinference_llm::providers::overrides::{
+ ChatModelEntry, ChatModelRequest, ProviderModelMetadata,
+};
// ── parse_suggestions / strip_markdown_fence: pure unit tests ──────────────
diff --git a/crates/openhuman-embed/examples/support/mod.rs b/crates/openhuman-embed/examples/support/mod.rs
index c653141091..b5b94dff8c 100644
--- a/crates/openhuman-embed/examples/support/mod.rs
+++ b/crates/openhuman-embed/examples/support/mod.rs
@@ -245,7 +245,7 @@ impl PointedInference {
// rides as the bearer.
let token = openhuman_embed::__host::security::credentials::session_support::resolve_backend_credential(&request.context.config)
.map(|credential| credential.secret().to_string())
- .map_err(anyhow::Error::msg)?;
+ .map_err(tinyinference_llm::Error::Model)?;
let wire =
OpenAiModel::compatible_provider("EmbedTest", token, base_url.clone(), &model)
.with_native_tool_calling(request.native_tool_calling);
diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rs
index 4a0e80eabc..024323df64 100644
--- a/crates/openhuman-embed/src/host_internals.rs
+++ b/crates/openhuman-embed/src/host_internals.rs
@@ -400,8 +400,8 @@ pub mod inference_registry {
unregister_embedding, unregister_inspection_catalog, unregister_inspection_chat_model,
BackendErrorClassification, BackendErrorClassifier, BackendErrorKind, CatalogCallContext,
CatalogHostRequest, ConfigNormalizer, EmbeddingCallContext, InspectionCatalogError,
- InspectionCatalogListing, InspectionCatalogRequest, InspectionChatModelBuild, InspectionChatModelFactory,
- InspectionEmbeddingFactory, PreparedInspectionCatalog,
+ InspectionCatalogListing, InspectionCatalogRequest, InspectionChatModelBuild,
+ InspectionChatModelFactory, InspectionEmbeddingFactory, PreparedInspectionCatalog,
PreparedInspectionChatModelFactory, ProviderContext,
};
pub use tinyinference_llm::providers::overrides::{
diff --git a/crates/openhuman-embed/tests/common/mod.rs b/crates/openhuman-embed/tests/common/mod.rs
index 27701c2a38..36d7f518c5 100644
--- a/crates/openhuman-embed/tests/common/mod.rs
+++ b/crates/openhuman-embed/tests/common/mod.rs
@@ -276,7 +276,7 @@ impl PointedInference {
// rides as the bearer.
let token = openhuman_embed::__host::security::credentials::session_support::resolve_backend_credential(&request.context.config)
.map(|credential| credential.secret().to_string())
- .map_err(anyhow::Error::msg)?;
+ .map_err(tinyinference_llm::Error::Model)?;
let wire =
OpenAiModel::compatible_provider("EmbedTest", token, base_url.clone(), &model)
.with_native_tool_calling(request.native_tool_calling);
@@ -304,6 +304,7 @@ impl PointedInference {
.map(str::to_string)
.or_else(|| {
config
+ .config
.default_model
.as_deref()
.map(str::trim)
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_catalog.rs b/crates/openhuman-tinyhumans/src/inference/managed_catalog.rs
index 98e1b0b908..fabef26926 100644
--- a/crates/openhuman-tinyhumans/src/inference/managed_catalog.rs
+++ b/crates/openhuman-tinyhumans/src/inference/managed_catalog.rs
@@ -38,10 +38,7 @@ pub(super) fn entry() -> CatalogEntry<ProviderContext> {
|request: CatalogRequest<ProviderContext>| -> BoxFuture<Result<serde_json::Value, String>> {
Box::pin(async move {
let context = request.context;
- let host = context
- .catalog
- .as_ref()
- .expect("catalog host context");
+ let host = context.catalog.as_ref().expect("catalog host context");
let outcome = list_models(
&context.config,
CatalogHostRequest {
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_catalog_tests.rs b/crates/openhuman-tinyhumans/src/inference/managed_catalog_tests.rs
index 31b74368c6..a2dc033bef 100644
--- a/crates/openhuman-tinyhumans/src/inference/managed_catalog_tests.rs
+++ b/crates/openhuman-tinyhumans/src/inference/managed_catalog_tests.rs
@@ -48,22 +48,22 @@ fn without_session(config: &Config) {
#[test]
fn a_managed_401_on_an_attached_session_reads_as_signed_out() {
- assert!(managed_401_means_signed_out(Some(401), true));
- assert!(!managed_401_means_signed_out(None, true));
+ assert!(managed_401_means_signed_out(401, true));
+ assert!(!managed_401_means_signed_out(200, true));
}
/// A 401 on a request that never carried the session token describes the
/// request (a misconfigured URL), not the session, so the error surfaces.
#[test]
fn a_401_without_an_attached_session_still_surfaces() {
- assert!(!managed_401_means_signed_out(Some(401), false));
+ assert!(!managed_401_means_signed_out(401, false));
}
#[test]
fn other_statuses_still_surface_the_error() {
for status in [400, 403, 404, 429, 500, 503] {
assert!(
- !managed_401_means_signed_out(Some(status), true),
+ !managed_401_means_signed_out(status, true),
"managed {status}"
);
}
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_embedding_tests.rs b/crates/openhuman-tinyhumans/src/inference/managed_embedding_tests.rs
index 5519f28aff..ba08246bfd 100644
--- a/crates/openhuman-tinyhumans/src/inference/managed_embedding_tests.rs
+++ b/crates/openhuman-tinyhumans/src/inference/managed_embedding_tests.rs
@@ -24,13 +24,23 @@ fn state_dir_of(config: &Config) -> std::path::PathBuf {
/// Builds the embedder the way the core's managed factory does: through the
/// registered embedding provider, with the config's credential scope.
fn build_through_registry(config: &Config, model: &str, dimensions: usize) -> CloudEmbeddingModel {
+ let context = openhuman_embed::__host::inference_registry::ProviderContext {
+ config: config.clone(),
+ egress: openhuman_embed::__host::egress::EgressLedger::none(),
+ embedding: Some(
+ openhuman_embed::__host::inference_registry::EmbeddingCallContext {
+ config: Some(config.clone()),
+ chat: None,
+ state_dir: state_dir_of(config),
+ secrets_encrypt: config.secrets.encrypt,
+ },
+ ),
+ catalog: None,
+ };
from_request(&EmbeddingRequest {
- config: Some(config),
model,
dimensions,
- chat: None,
- state_dir: state_dir_of(config),
- secrets_encrypt: config.secrets.encrypt,
+ context: &context,
})
}
@@ -77,6 +87,7 @@ async fn api_key_alone_authenticates_cloud_embeddings() {
"m",
2,
None,
+ None,
);
let vectors = provider
@@ -110,6 +121,7 @@ async fn api_key_is_refused_over_plaintext_non_loopback() {
"m",
2,
None,
+ None,
);
let err = provider.embed(&["hello".to_string()]).await.unwrap_err();
assert!(
@@ -162,6 +174,7 @@ fn unreachable_embedder_with_chat(
model,
DEFAULT_CLOUD_DIMENSIONS,
chat,
+ None,
)
}
@@ -493,6 +506,7 @@ async fn offline_local_session_is_refused_before_embedding_request() {
"m",
2,
None,
+ None,
);
let err = provider
@@ -563,6 +577,7 @@ async fn expired_session_publishes_session_expired_before_embedding_request() {
"m",
2,
None,
+ None,
);
let err = provider
diff --git a/crates/openhuman-tinyhumans/src/inference/mod.rs b/crates/openhuman-tinyhumans/src/inference/mod.rs
index 3c0150f707..7e202d0706 100644
--- a/crates/openhuman-tinyhumans/src/inference/mod.rs
+++ b/crates/openhuman-tinyhumans/src/inference/mod.rs
@@ -122,7 +122,7 @@ fn build_chat_model_for_inspection(
})
}
-fn readiness_probe() -> ReadinessProbe {
+fn readiness_probe() -> ReadinessProbe<ProviderContext> {
Arc::new(
|request: tinyinference_llm::providers::overrides::ReadinessRequest<ProviderContext>| -> tinyinference_llm::providers::overrides::BoxFuture<Result<(), String>> {
Box::pin(async move {
@@ -153,7 +153,10 @@ fn readiness_probe() -> ReadinessProbe {
/// Registers this area's hooks with the core. Idempotent.
pub(crate) fn register(_options: &InstallOptions) {
- let build: ChatModelFactory<ProviderContext> = Arc::new(build_chat_model);
+ let build: ChatModelFactory<ProviderContext> = Arc::new(|request| {
+ build_chat_model(request)
+ .map_err(|error| tinyinference_llm::Error::Model(error.to_string()))
+ });
register_chat_model(
PROVIDER_OPENHUMAN,
ChatModelEntry {
@@ -189,10 +192,7 @@ pub(crate) fn register(_options: &InstallOptions) {
.map(|model| Box::new(model) as Box<dyn tinyinference_embeddings::EmbeddingModel>)
});
register_catalog(PROVIDER_OPENHUMAN, managed_catalog::entry());
- register_inspection_catalog(
- PROVIDER_OPENHUMAN,
- managed_catalog::inspection_entry(),
- );
+ register_inspection_catalog(PROVIDER_OPENHUMAN, managed_catalog::inspection_entry());
register_config_normalizer(PROVIDER_OPENHUMAN, Arc::new(tiers::normalize_config));
register_backend_error_classifier(Arc::new(backend_error_code::classify));
log::debug!(
diff --git a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs
index b74913a9d6..8552447bc4 100644
--- a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs
+++ b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs
@@ -2,7 +2,10 @@ use super::*;
fn normalize_with_hosted_registration(config: &mut Config) -> bool {
let _registry = crate::registry_test_lock();
- crate::register::register_all(&crate::install::InstallOptions::default());
+ crate::register::register_all(
+ &crate::install::InstallOptions::default(),
+ crate::register::DoctorRegistration::Process,
+ );
super::normalize_config(config)
}
@@ -179,7 +182,10 @@ fn hosted_normalizer_leaves_custom_and_explicit_primary_choices_alone() {
#[test]
fn hosted_cost_defaults_include_the_registered_managed_model_price() {
let _registry = crate::registry_test_lock();
- crate::register::register_all(&crate::install::InstallOptions::default());
+ crate::register::register_all(
+ &crate::install::InstallOptions::default(),
+ crate::register::DoctorRegistration::Process,
+ );
let prices = openhuman_embed::__host::config::Config::default()
.cost
diff --git a/crates/openhuman-tinyhumans/src/register_tests.rs b/crates/openhuman-tinyhumans/src/register_tests.rs
index 03909cba56..02ea6d623c 100644
--- a/crates/openhuman-tinyhumans/src/register_tests.rs
+++ b/crates/openhuman-tinyhumans/src/register_tests.rs
@@ -12,7 +12,7 @@ fn register_all_is_idempotent() {
#[tokio::test]
async fn boot_registration_supplies_hosted_model_default_and_normalizer_before_context_exists() {
let _registry = crate::registry_test_lock_async().await;
- register_all(&InstallOptions::default());
+ register_all(&InstallOptions::default(), DoctorRegistration::Process);
let config = openhuman_embed::__host::config::Config::default();
assert_eq!(
diff --git a/scripts/ci/agent-runtime-boundary-baseline.json b/scripts/ci/agent-runtime-boundary-baseline.json
index bfcdc19299..8bb32f2ee4 100644
--- a/scripts/ci/agent-runtime-boundary-baseline.json
+++ b/scripts/ci/agent-runtime-boundary-baseline.json
@@ -524,34 +524,6 @@
"text": "pub use tinyagents_harness::store::{AppendStore, Store};",
"occurrence": 1
},
- {
- "rule": "openhuman-task-local",
- "path": "crates/openhuman-tinyhumans/src/inference/managed_calls.rs",
- "line": 12,
- "text": "use super::managed_reasoning::{apply_reasoning_hint, with_thread_id};",
- "occurrence": 1
- },
- {
- "rule": "openhuman-task-local",
- "path": "crates/openhuman-tinyhumans/src/inference/managed_calls.rs",
- "line": 123,
- "text": "with_thread_id(apply_reasoning_hint(request), self.thread_id.as_deref()),",
- "occurrence": 1
- },
- {
- "rule": "openhuman-task-local",
- "path": "crates/openhuman-tinyhumans/src/inference/managed_calls.rs",
- "line": 153,
- "text": "with_thread_id(apply_reasoning_hint(request), self.thread_id.as_deref()),",
- "occurrence": 2
- },
- {
- "rule": "openhuman-task-local",
- "path": "crates/openhuman-tinyhumans/src/inference/managed_model.rs",
- "line": 99,
- "text": "pub fn with_thread_id(mut self, thread_id: Option<impl AsRef<str>>) -> Self {",
- "occurrence": 1
- },
{
"rule": "openhuman-upstream-reexport",
"path": "crates/openhuman-core/src/agent/tinyagents/budget.rs",