Skip to content

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

test(openhuman-embed): add profile integration tests

Steven Enamakel09e65f959ea2
diff --git a/crates/openhuman-embed/tests/README.md b/crates/openhuman-embed/tests/README.md
index f25f70ed9d..a4bf553800 100644
--- a/crates/openhuman-embed/tests/README.md
+++ b/crates/openhuman-embed/tests/README.md
@@ -29,7 +29,7 @@ record types preserve populated persisted JSON, including metadata and lineage.
| File | What it proves |
| --- | --- |
-| [`common/mod.rs`](common/mod.rs) | Shared helpers: `runtime()`, `offline_config()`, `provider(reply)`, `stub_backend()`, `chat_completion`, `tool_call_completion`, `echo_inference()` with `PointedTransport` (managed inference to a mock), and request inspectors (`chat_requests`, `tool_names`, `tool_results`, `last_user_message`). |
+| [`common/mod.rs`](common/mod.rs) | Shared helpers: `runtime()`, `offline_config()`, `provider(reply)`, `stub_backend()`, `chat_completion`, `tool_call_completion`, `echo_inference()` with `PointedInference` (managed inference to a mock), and request inspectors (`chat_requests`, `tool_names`, `tool_results`, `last_user_message`). |
| [`facades.rs`](facades.rs) | The runtime-free curated facades (`artifacts`, `chat_surface`, `identity`, `config` helpers, `modules`), the compile-status constants and `schema_for_rpc_method`. |
| [`seams_runtime.rs`](seams_runtime.rs) | A controller extension is invokable after a real `build()`, a `live_policy` is applied after boot, and hooks are removed on drop while the extension outlives the runtime. |
| [`harness_embed.rs`](harness_embed.rs) | A `Harness` runs a real turn with no transport and no background services, routes it to the mock provider, and binds nothing. |
@@ -38,7 +38,7 @@ record types preserve populated persisted JSON, including metadata and lineage.
| [`attached_tools.rs`](attached_tools.rs) | `Agent::attach_tools` sources survive clones and session resume, and name collisions are refused. |
| [`composio_agents.rs`](composio_agents.rs) | Two agents with their own `ComposioHostCredential` reach Composio with their own key only. |
| [`memory_facade.rs`](memory_facade.rs) | `Runtime::memory` over TinyMemory's in-memory reference engine keeps two tenant roots apart. |
-| [`saas_profiles.rs`](saas_profiles.rs) | A `ProfileRuntime` (SaaS mode, in-process): two users on thread `t1` see only their own messages and ride their own credential, a held `ProfileHandle` keeps its profile from release, a relayed Telegram message lands on the user's `channel:` thread with its `channel_outbound` reply on that user's events only, and the process refuses any other core afterwards. Inference is `common::echo_inference` behind `common::PointedTransport`. |
+| [`saas_profiles.rs`](saas_profiles.rs) | A `ProfileRuntime` (SaaS mode, in-process): two users on thread `t1` see only their own messages and ride their own credential, a held `ProfileHandle` keeps its profile from release, a relayed Telegram message lands on the user's `channel:` thread with its `channel_outbound` reply on that user's events only, and the process refuses any other core afterwards. Inference is `common::echo_inference` behind `common::PointedInference`. |
| [`host_only_tools.rs`](host_only_tools.rs) | Host tools declare read-only requirements through Embed's `ToolPolicy`; the exact host catalog is advertised and built-in shell/write calls are refused. |
| [`structured_turns.rs`](structured_turns.rs) | Host-owned document tools preserve structured response shape, usage, budgets and untrusted-input restrictions across the tool loop. |
| [`completion_routing.rs`](completion_routing.rs) | Ordered endpoint fallback, bounded 2x/4x truncation retries, final unpinned gateway routing, images and accounting across all attempts. |
diff --git a/crates/openhuman-embed/tests/common/mod.rs b/crates/openhuman-embed/tests/common/mod.rs
index dc0b890cae..72202cbbe7 100644
--- a/crates/openhuman-embed/tests/common/mod.rs
+++ b/crates/openhuman-embed/tests/common/mod.rs
@@ -224,75 +224,45 @@ pub async fn eventually<T>(what: &str, mut check: impl FnMut() -> Option<T>) ->
panic!("timed out waiting for {what}");
}
-/// A backend transport that sends managed inference to `base_url` (a mock)
-/// and answers every control-plane call as "no backend". For suites that run
-/// turns through the core's managed-inference path, such as SaaS profiles,
-/// whose configs name no inference endpoint of their own.
-pub struct PointedTransport {
- base_url: String,
- client: reqwest::Client,
-}
+/// Registers a managed chat-model provider that sends inference to `base_url`
+/// (a mock). For suites that run turns through the core's managed-inference
+/// path, such as SaaS profiles, whose configs name no inference endpoint of
+/// their own. The core carries no hosted provider, so the suite supplies one
+/// through the generic chat-model registry.
+pub struct PointedInference;
-impl PointedTransport {
+impl PointedInference {
pub fn install(base_url: &str) {
- openhuman_embed::install_backend_transport(std::sync::Arc::new(Self {
- base_url: base_url.trim_end_matches('/').to_string(),
- client: reqwest::Client::new(),
- }));
- }
-}
-
-#[async_trait::async_trait]
-impl openhuman_embed::BackendTransport for PointedTransport {
- async fn send_json(
- &self,
- req: openhuman_embed::BackendRequest<'_>,
- ) -> Result<serde_json::Value, openhuman_embed::BackendTransportError> {
- // Forward inference requests to the pointed mock endpoint.
- // This uses the same HTTP client as a real transport would.
- let url = format!("{}/{}", self.base_url, req.path.trim_start_matches('/'));
- let resp = self
- .client
- .post(&url)
- .json(&req.body)
- .send()
- .await
- .map_err(|_| openhuman_embed::BackendTransportError::Unavailable)?;
- resp.json()
- .await
- .map_err(|_| openhuman_embed::BackendTransportError::Unavailable)
- }
-
- async fn send_multipart(
- &self,
- _req: openhuman_embed::BackendRequest<'_>,
- _form: reqwest::multipart::Form,
- ) -> Result<serde_json::Value, openhuman_embed::BackendTransportError> {
- Err(openhuman_embed::BackendTransportError::Unavailable)
- }
-
- fn http_client(&self, _profile: openhuman_embed::TransportProfile) -> reqwest::Client {
- reqwest::Client::new()
- }
+ use openhuman_embed::__host::inference_registry::{
+ register_chat_model, ChatModelEntry, ChatModelRequest, PROVIDER_OPENHUMAN,
+ };
+ use tinyinference_llm::providers::openai::OpenAiModel;
- fn base_url(
- &self,
- _configured: Option<&str>,
- _purpose: openhuman_embed::BaseUrlPurpose,
- ) -> String {
- self.base_url.clone()
- }
-
- fn product_identity(&self) -> String {
- "openhuman-embed-test".to_string()
- }
-
- fn attribution_headers(&self) -> reqwest::header::HeaderMap {
- reqwest::header::HeaderMap::new()
- }
-
- fn name(&self) -> &'static str {
- "embed-test-pointed"
+ let base_url = base_url.trim_end_matches('/').to_string();
+ let build = move |request: &ChatModelRequest<'_>| {
+ let model = request
+ .model_override
+ .or(request.default_model)
+ .unwrap_or("embed-test-model")
+ .to_string();
+ let wire = OpenAiModel::compatible_provider(
+ "EmbedTest",
+ "embed-test-token".to_string(),
+ base_url.clone(),
+ &model,
+ )
+ .with_native_tool_calling(request.native_tool_calling);
+ let wire: std::sync::Arc<dyn tinyinference_llm::model::ChatModel<()>> =
+ std::sync::Arc::new(wire);
+ Ok((wire, model))
+ };
+ register_chat_model(
+ PROVIDER_OPENHUMAN,
+ ChatModelEntry {
+ build: std::sync::Arc::new(build),
+ probe: None,
+ },
+ );
}
}
diff --git a/crates/openhuman-embed/tests/profile_cron_sweep.rs b/crates/openhuman-embed/tests/profile_cron_sweep.rs
index 7ebc76d6ee..b53cb8ceba 100644
--- a/crates/openhuman-embed/tests/profile_cron_sweep.rs
+++ b/crates/openhuman-embed/tests/profile_cron_sweep.rs
@@ -7,7 +7,7 @@ mod common;
use std::sync::{Arc, Mutex};
use std::time::Duration;
-use common::{chat_completion, last_user_message, runtime_without_master_key, PointedTransport};
+use common::{chat_completion, last_user_message, runtime_without_master_key, PointedInference};
use openhuman_core::cron::{self, AgentJobSpec, DeliveryConfig, Schedule};
use openhuman_embed::profiles::ProfileCredentialKind;
use openhuman_embed::{CronDelivery, CronReply, JobOrigin, ProfileRuntime, SaasConfig};
@@ -62,7 +62,7 @@ async fn scenario() {
.with_priority(10)
.mount(&inference)
.await;
- PointedTransport::install(&inference.uri());
+ PointedInference::install(&inference.uri());
// The shared backend every sweeper would contend on.
openhuman_core::storage::install(Arc::new(openhuman_core::storage::MemoryStorage::new()));
diff --git a/crates/openhuman-embed/tests/profile_direct_providers.rs b/crates/openhuman-embed/tests/profile_direct_providers.rs
index 53dd20d6f5..b2f527b3a8 100644
--- a/crates/openhuman-embed/tests/profile_direct_providers.rs
+++ b/crates/openhuman-embed/tests/profile_direct_providers.rs
@@ -7,7 +7,7 @@
mod common;
use common::{
- chat_completion, chat_requests, runtime_without_master_key, tool_names, PointedTransport,
+ chat_completion, chat_requests, runtime_without_master_key, tool_names, PointedInference,
};
use openhuman_embed::config::{
PresentationMode, SearchConfig, SearchEngineCredentials, SearchProviderSettings, SearchRole,
@@ -119,7 +119,7 @@ async fn scenario() {
.respond_with(ResponseTemplate::new(500))
.mount(&managed)
.await;
- PointedTransport::install(&managed.uri());
+ PointedInference::install(&managed.uri());
let search = SearchConfig {
presentation: PresentationMode::Roles,
diff --git a/crates/openhuman-embed/tests/profile_host_capabilities.rs b/crates/openhuman-embed/tests/profile_host_capabilities.rs
index 0ee50149a6..d61ce6d3ad 100644
--- a/crates/openhuman-embed/tests/profile_host_capabilities.rs
+++ b/crates/openhuman-embed/tests/profile_host_capabilities.rs
@@ -8,7 +8,7 @@ use std::time::Duration;
use common::{
chat_completion, chat_requests, runtime_without_master_key, tool_call_completion, tool_names,
- PointedTransport,
+ PointedInference,
};
use openhuman_embed::memory::api::conformance::ReferenceEngine;
use openhuman_embed::memory::api::{LearningKind, MemoryEngine, MemoryMeta, StoreItem};
@@ -188,7 +188,7 @@ async fn scenario() {
.with_priority(10)
.mount(&inference)
.await;
- PointedTransport::install(&inference.uri());
+ PointedInference::install(&inference.uri());
let root = tempfile::tempdir().unwrap();
let calls = Arc::new(Mutex::new(Vec::new()));
let factory_calls = calls.clone();
diff --git a/crates/openhuman-embed/tests/profile_operator_tools.rs b/crates/openhuman-embed/tests/profile_operator_tools.rs
index f84f3566d2..3414889935 100644
--- a/crates/openhuman-embed/tests/profile_operator_tools.rs
+++ b/crates/openhuman-embed/tests/profile_operator_tools.rs
@@ -9,7 +9,7 @@ use std::sync::{Arc, Mutex};
use std::time::Duration;
use common::{
- chat_completion, chat_requests, runtime_without_master_key, tool_names, PointedTransport,
+ chat_completion, chat_requests, runtime_without_master_key, tool_names, PointedInference,
};
use openhuman_embed::seams::ToolHookDecision;
use openhuman_embed::{
@@ -118,7 +118,7 @@ async fn scenario() {
.respond_with(ResponseTemplate::new(500))
.mount(&managed)
.await;
- PointedTransport::install(&managed.uri());
+ PointedInference::install(&managed.uri());
openhuman_core::storage::install(Arc::new(openhuman_core::storage::MemoryStorage::new()));
let root = tempfile::tempdir().unwrap();
diff --git a/crates/openhuman-embed/tests/profile_refused_tool_generation.rs b/crates/openhuman-embed/tests/profile_refused_tool_generation.rs
index 849ab1b07a..e8c0c4f073 100644
--- a/crates/openhuman-embed/tests/profile_refused_tool_generation.rs
+++ b/crates/openhuman-embed/tests/profile_refused_tool_generation.rs
@@ -10,7 +10,7 @@ mod common;
use std::sync::Arc;
-use common::{chat_completion, chat_requests, runtime_without_master_key, PointedTransport};
+use common::{chat_completion, chat_requests, runtime_without_master_key, PointedInference};
use openhuman_embed::seams::ToolHookDecision;
use openhuman_embed::{
DirectProfileProvider, InMemorySessionStores, PermissionLevel, ProfileRuntime, SaasConfig,
@@ -102,7 +102,7 @@ async fn scenario() {
.respond_with(ResponseTemplate::new(500))
.mount(&managed)
.await;
- PointedTransport::install(&managed.uri());
+ PointedInference::install(&managed.uri());
openhuman_core::storage::install(Arc::new(openhuman_core::storage::MemoryStorage::new()));
let root = tempfile::tempdir().unwrap();
diff --git a/crates/openhuman-embed/tests/profile_system_prompt.rs b/crates/openhuman-embed/tests/profile_system_prompt.rs
index 9d45d2e31e..8535947711 100644
--- a/crates/openhuman-embed/tests/profile_system_prompt.rs
+++ b/crates/openhuman-embed/tests/profile_system_prompt.rs
@@ -5,7 +5,7 @@
mod common;
-use common::{chat_completion, chat_requests, runtime_without_master_key, PointedTransport};
+use common::{chat_completion, chat_requests, runtime_without_master_key, PointedInference};
use openhuman_embed::profiles::ProfileCredentialKind;
use openhuman_embed::{DirectProfileProvider, ProfileRuntime, SaasConfig};
use serde_json::Value;
@@ -32,7 +32,7 @@ async fn scenario() {
.respond_with(ResponseTemplate::new(500))
.mount(&managed)
.await;
- PointedTransport::install(&managed.uri());
+ PointedInference::install(&managed.uri());
let root = tempfile::tempdir().unwrap();
let mut saas = SaasConfig::new(root.path());
diff --git a/crates/openhuman-embed/tests/profile_turn_serialization.rs b/crates/openhuman-embed/tests/profile_turn_serialization.rs
index ad6b54bfbd..078e374cea 100644
--- a/crates/openhuman-embed/tests/profile_turn_serialization.rs
+++ b/crates/openhuman-embed/tests/profile_turn_serialization.rs
@@ -8,7 +8,7 @@ mod common;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
-use common::{chat_completion, last_user_message, runtime_without_master_key, PointedTransport};
+use common::{chat_completion, last_user_message, runtime_without_master_key, PointedInference};
use openhuman_core::cron::{self, AgentJobSpec, Schedule};
use openhuman_embed::profiles::ProfileCredentialKind;
use openhuman_embed::{ProfileRuntime, SaasConfig};
@@ -82,7 +82,7 @@ async fn scenario() {
.with_priority(10)
.mount(&inference)
.await;
- PointedTransport::install(&inference.uri());
+ PointedInference::install(&inference.uri());
openhuman_core::storage::install(Arc::new(openhuman_core::storage::MemoryStorage::new()));
let root = tempfile::tempdir().unwrap();
diff --git a/crates/openhuman-embed/tests/saas_profiles.rs b/crates/openhuman-embed/tests/saas_profiles.rs
index f505375143..8a96984d06 100644
--- a/crates/openhuman-embed/tests/saas_profiles.rs
+++ b/crates/openhuman-embed/tests/saas_profiles.rs
@@ -12,7 +12,7 @@ use std::time::Duration;
use common::{
chat_requests, echo_inference, last_user_message, runtime_without_master_key as runtime,
- PointedTransport,
+ PointedInference,
};
use openhuman_embed::profiles::ProfileCredentialKind;
use openhuman_embed::{
@@ -33,7 +33,7 @@ fn profiles_are_isolated_held_and_relayed() {
async fn scenario() {
let inference = echo_inference().await;
- PointedTransport::install(&inference.uri());
+ PointedInference::install(&inference.uri());
let root = tempfile::tempdir().expect("root");
let mut config = SaasConfig::new(root.path());