Skip to content

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

test(config): update search tests for provider-based engine configuration

Steven Enamakel67ae718c78e1
diff --git a/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs b/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs
index 865c090020..c47eccb9ce 100644
--- a/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs
+++ b/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs
@@ -612,7 +612,7 @@ async fn apply_search_settings_accepts_disabled_engine() {
let tmp = tempdir().unwrap();
let mut cfg = tmp_config(&tmp);
- apply_search_settings(
+ let result = apply_search_settings(
&mut cfg,
SearchSettingsPatch {
engine: Some("disabled".to_string()),
@@ -622,11 +622,8 @@ async fn apply_search_settings_accepts_disabled_engine() {
.await
.expect("apply disabled search engine");
- assert_eq!(cfg.search.engine, "disabled");
- assert_eq!(
- cfg.search.effective_engine(),
- crate::config::SearchEngine::Disabled
- );
+ assert!(!cfg.search.is_enabled());
+ assert_eq!(result.value["enabled"], false);
}
#[tokio::test]
@@ -634,41 +631,40 @@ async fn apply_search_settings_stores_and_clears_tavily_key() {
let tmp = tempdir().unwrap();
let mut cfg = tmp_config(&tmp);
- let result = apply_search_settings(
- &mut cfg,
- SearchSettingsPatch {
- engine: Some("tavily".to_string()),
- tavily_api_key: Some(" tvly-test-key ".to_string()),
- ..Default::default()
- },
- )
- .await
- .expect("save Tavily settings");
- assert_eq!(result.value["tavily_configured"], true);
+ let enable: SearchSettingsPatch = serde_json::from_value(serde_json::json!({
+ "providers": {"tavily": {"enabled": true, "api_key": " tvly-test-key "}},
+ "roles": {"search": ["tavily", "exa"]}
+ }))
+ .unwrap();
+ let result = apply_search_settings(&mut cfg, enable)
+ .await
+ .expect("save Tavily settings");
+ let tavily = result.value["providers"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .find(|p| p["id"] == "tavily")
+ .unwrap()
+ .clone();
+ assert_eq!(tavily["key_configured"], true);
+ assert_eq!(tavily["status"], "ready");
+ assert_eq!(result.value["effective_roles"]["search"][0], "tavily");
assert!(!result.value.to_string().contains("tvly-test-key"));
-
- assert_eq!(cfg.search.engine, "tavily");
assert_eq!(cfg.search.tavily.api_key.as_deref(), Some("tvly-test-key"));
- assert_eq!(
- cfg.search.effective_engine(),
- crate::config::SearchEngine::Tavily
- );
-
- apply_search_settings(
- &mut cfg,
- SearchSettingsPatch {
- tavily_api_key: Some(" ".to_string()),
- ..Default::default()
- },
- )
- .await
- .expect("clear Tavily key");
+ let clear: SearchSettingsPatch = serde_json::from_value(serde_json::json!({
+ "providers": {"tavily": {"api_key": " "}}
+ }))
+ .unwrap();
+ let result = apply_search_settings(&mut cfg, clear)
+ .await
+ .expect("clear Tavily key");
assert!(cfg.search.tavily.api_key.is_none());
- assert_eq!(
- cfg.search.effective_engine(),
- crate::config::SearchEngine::Managed
- );
+ assert!(!result.value["effective_roles"]["search"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .any(|p| p == "tavily"));
}
#[tokio::test]
@@ -686,5 +682,5 @@ async fn apply_search_settings_rejects_unknown_search_engine() {
.await
.expect_err("unknown engine should be rejected");
- assert!(err.contains("disabled/managed/parallel/brave/querit/exa/tavily"));
+ assert!(err.contains("unknown search engine"), "{err}");
}
diff --git a/crates/openhuman-core/src/tools/ops_tests.rs b/crates/openhuman-core/src/tools/ops_tests.rs
index 15ec76e1ed..33463436e7 100644
--- a/crates/openhuman-core/src/tools/ops_tests.rs
+++ b/crates/openhuman-core/src/tools/ops_tests.rs
@@ -57,11 +57,6 @@ fn integration_test_config(tmp: &TempDir, backend_url: &str) -> Config {
cfg.integrations.tinyfish.enabled = true;
cfg.integrations.stock_prices.enabled = true;
cfg.integrations.twilio.enabled = true;
- // Parallel tools (search/extract/chat/research/enrich/dataset) are
- // registered by the unified search-engine selector, so flip the
- // engine to `parallel` in test setup.
- cfg.search.engine = crate::config::SEARCH_ENGINE_PARALLEL.into();
- cfg.search.parallel.api_key = Some("test-parallel-key".into());
cfg
}
diff --git a/crates/openhuman-core/src/tools/ops_tests_execution_and_serde_tests.rs b/crates/openhuman-core/src/tools/ops_tests_execution_and_serde_tests.rs
index 045cb9a517..b8b84f7a39 100644
--- a/crates/openhuman-core/src/tools/ops_tests_execution_and_serde_tests.rs
+++ b/crates/openhuman-core/src/tools/ops_tests_execution_and_serde_tests.rs
@@ -342,9 +342,6 @@ fn all_tools_registers_integration_families_when_enabled_and_signed_in() {
cfg.integrations.stock_prices.enabled = true;
cfg.integrations.twilio.enabled = true;
cfg.composio.enabled = true;
- // Parallel tools now register through the unified search-engine selector.
- cfg.search.engine = crate::config::SEARCH_ENGINE_PARALLEL.into();
- cfg.search.parallel.api_key = Some("test-parallel-key".into());
store_test_session_token(&cfg);
let tools = all_tools(
@@ -364,15 +361,6 @@ fn all_tools_registers_integration_families_when_enabled_and_signed_in() {
&[
"google_places_search",
"google_places_details",
- "parallel_search",
- "parallel_extract",
- "parallel_chat",
- "parallel_research",
- "parallel_enrich",
- "parallel_dataset",
- "tinyfish_search",
- "tinyfish_fetch",
- "tinyfish_agent_run",
"stock_quote",
"stock_exchange_rate",
"stock_options",
@@ -390,16 +378,18 @@ fn all_tools_registers_integration_families_when_enabled_and_signed_in() {
#[test]
fn all_tools_registers_brave_engine_lsp_and_tool_stats_when_enabled() {
- // The legacy seltz/searxng tools are no longer registered — the
- // unified `search.engine` selector replaces them. This test now
- // verifies that picking `brave` layers in its full tool surface
+ // Search registers one tool per capability role from the TinySearch
+ // catalog; a usable BYOK Brave key yields the `search` role tool
// alongside lsp + tool_stats.
let tmp = TempDir::new().unwrap();
let security = Arc::new(SecurityPolicy::default());
let browser = BrowserConfig::default();
let http = crate::config::HttpRequestConfig::default();
let mut cfg = test_config(&tmp);
- cfg.search.engine = crate::config::SEARCH_ENGINE_BRAVE.into();
+ cfg.search.providers.insert(
+ "brave".into(),
+ crate::config::SearchProviderSettings::direct(),
+ );
cfg.search.brave.api_key = Some("test-brave-key".into());
cfg.learning.enabled = true;
cfg.learning.tool_tracking_enabled = true;
@@ -425,10 +415,8 @@ fn all_tools_registers_brave_engine_lsp_and_tool_stats_when_enabled() {
assert_contains_all(
&names,
&[
+ #[cfg(feature = "modules")]
"web_search_tool",
- "brave_news_search",
- "brave_image_search",
- "brave_video_search",
"lsp",
"tool_stats",
],
@@ -440,13 +428,16 @@ fn all_tools_registers_brave_engine_lsp_and_tool_stats_when_enabled() {
}
#[test]
-fn all_tools_registers_querit_engine_when_enabled() {
+fn all_tools_registers_querit_as_the_search_role_when_enabled() {
let tmp = TempDir::new().unwrap();
let security = Arc::new(SecurityPolicy::default());
let browser = BrowserConfig::default();
let http = crate::config::HttpRequestConfig::default();
let mut cfg = test_config(&tmp);
- cfg.search.engine = crate::config::SEARCH_ENGINE_QUERIT.into();
+ cfg.search.providers.insert(
+ "querit".into(),
+ crate::config::SearchProviderSettings::direct(),
+ );
cfg.search.querit.api_key = Some("test-querit-key".into());
let tools = all_tools(
@@ -460,7 +451,10 @@ fn all_tools_registers_querit_engine_when_enabled() {
&cfg,
);
let names = tool_names(&tools);
- assert_contains_all(&names, &["web_search_tool", "querit_search"]);
+ #[cfg(feature = "modules")]
+ assert_contains_all(&names, &["web_search_tool"]);
+ // Provider tools stay behind the role tool in the default presentation.
+ assert!(!names.iter().any(|name| name == "querit_search"), "{names:?}");
}
#[test]
@@ -471,7 +465,7 @@ fn all_tools_omits_search_surface_when_search_is_disabled() {
let http = crate::config::HttpRequestConfig::default();
let mut cfg = test_config(&tmp);
cfg.api_url = Some("https://backend.example.test".to_string());
- cfg.search.engine = crate::config::SEARCH_ENGINE_DISABLED.into();
+ cfg.search.enabled = Some(false);
cfg.search.brave.api_key = Some("test-brave-key".into());
cfg.search.querit.api_key = Some("test-querit-key".into());
cfg.integrations.tinyfish.enabled = true;
@@ -491,6 +485,8 @@ fn all_tools_omits_search_surface_when_search_is_disabled() {
for search_tool in [
"web_search_tool",
+ "web_answer_tool",
+ "web_contents_tool",
"brave_news_search",
"brave_image_search",
"brave_video_search",