Skip to content

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

fix(search): handle empty search results gracefully

Steven Enamakel3f66275923b1
diff --git a/crates/openhuman-cli/src/bin/library_profile/mock.rs b/crates/openhuman-cli/src/bin/library_profile/mock.rs
index c881340dab..2dba5e7cd3 100644
--- a/crates/openhuman-cli/src/bin/library_profile/mock.rs
+++ b/crates/openhuman-cli/src/bin/library_profile/mock.rs
@@ -89,20 +89,20 @@ fn env_u64(key: &str, default: u64) -> u64 {
.unwrap_or(default)
}
-/// Stable per-researcher marker embedded in a delegated subagent's prompt.
+/// Stable per-worker marker embedded in a delegated subagent's prompt.
/// Zero-padded so `..._001` is never a substring of `..._011` — the storm mock
/// routes by exact marker containment across K up to 32.
pub fn subagent_marker(index: usize) -> String {
format!("LIB_PROFILE_SUBAGENT_{index:03}")
}
-/// The finding text a delegated researcher returns for `index`. The merge turn
+/// The finding text a delegated worker returns for `index`. The merge turn
/// is detected by all K of these being present in the conversation.
pub fn finding_text(index: usize) -> String {
- format!("Finding {index:03}: researcher {index} reports healthy.")
+ format!("Finding {index:03}: worker {index} reports healthy.")
}
-/// Text the orchestrator returns once it has merged every researcher finding;
+/// Text the orchestrator returns once it has merged every worker finding;
/// its arrival in the parent (subconscious) conversation ends the storm turn.
pub const MERGE_SENTINEL: &str = "STORM_MERGE_COMPLETE";
@@ -156,11 +156,11 @@ impl LatencyKnobs {
}
/// Orchestration mock: the first (orchestrator) turn emits a
-/// `spawn_parallel_agents` tool call fanning out to **K** researchers; each
-/// researcher turn returns its finding; the final merge turn returns plain
+/// `spawn_parallel_agents` tool call fanning out to **K** `planner` workers;
+/// each worker turn returns its finding; the final merge turn returns plain
/// text once all K findings are present.
///
-/// `width` = K parallel researchers. `new()` keeps the original two-researcher
+/// `width` = K parallel workers. `new()` keeps the original two-worker
/// shape (K = 2, no injected latency, driven from the subconscious which has no
/// `spawn_parallel_agents` — the tool call is rejected and its markers echo
/// back, which is all the `subagents` scenario asserts). `with_width(k)` drives
@@ -169,8 +169,8 @@ impl LatencyKnobs {
/// the `subagent-storm` fuzz-width path.
pub struct SubagentMock {
pub prompts: Mutex<Vec<String>>,
- /// Actual wall-time (ms) of each *researcher* chat call, for percentiles.
- pub researcher_latencies_ms: Mutex<Vec<u128>>,
+ /// Actual wall-time (ms) of each *worker* chat call, for percentiles.
+ pub worker_latencies_ms: Mutex<Vec<u128>>,
width: usize,
latency: LatencyKnobs,
/// `true` for `with_width` (orchestrator-driven storm): route the full
@@ -183,12 +183,12 @@ pub struct SubagentMock {
}
impl SubagentMock {
- /// K researchers with per-researcher latency drawn from the env knobs, driven
+ /// K workers with per-worker latency drawn from the env knobs, driven
/// directly against the orchestrator agent (full agent-aware chain).
pub fn with_width(width: usize) -> Arc<Self> {
Arc::new(Self {
prompts: Mutex::new(Vec::new()),
- researcher_latencies_ms: Mutex::new(Vec::new()),
+ worker_latencies_ms: Mutex::new(Vec::new()),
width: width.max(1),
latency: LatencyKnobs::from_env(),
orchestrator_driven: true,
@@ -196,29 +196,29 @@ impl SubagentMock {
})
}
- /// Which researcher (1-based) this prompt is for, if any. A researcher
+ /// Which worker (1-based) this prompt is for, if any. A worker
/// prompt embeds exactly one `subagent_marker`.
- fn researcher_index(&self, joined: &str) -> Option<usize> {
+ fn worker_index(&self, joined: &str) -> Option<usize> {
(1..=self.width).find(|&i| joined.contains(&subagent_marker(i)))
}
- /// True once every researcher's finding is present — the merge turn.
+ /// True once every worker's finding is present — the merge turn.
fn is_merge(&self, joined: &str) -> bool {
(1..=self.width).all(|i| joined.contains(&finding_text(i)))
}
- /// True when this call is a real researcher worker turn: exactly one task
+ /// True when this call is a real `planner` worker turn: exactly one task
/// marker is present and the executing agent is neither the orchestrator nor
/// the subconscious (their Tool Policy Boundary headers name them, and their
- /// merge/echo turns also carry every marker). The researcher agent's system
- /// prompt names it `Researcher`, so it matches neither header string.
- fn is_researcher_turn(&self, joined: &str) -> bool {
- self.researcher_index(joined).is_some()
+ /// merge/echo turns also carry every marker). The planner agent's system
+ /// prompt names it `Planner`, so it matches neither header string.
+ fn is_worker_turn(&self, joined: &str) -> bool {
+ self.worker_index(joined).is_some()
&& !joined.contains("Agent: orchestrator")
&& !joined.contains("Agent: subconscious")
}
- /// Build the fan-out tool call delegating to K parallel researchers. Only
+ /// Build the fan-out tool call delegating to K parallel `planner` workers. Only
/// valid on an **orchestrator** turn — the subconscious has no
/// `spawn_parallel_agents` tool, so we `delegate_orchestrator` there first.
fn spawn_call(&self) -> ChatResponse {
@@ -226,7 +226,7 @@ impl SubagentMock {
let tasks: Vec<serde_json::Value> = (1..=self.width)
.map(|i| {
serde_json::json!({
- "agent_id": "researcher",
+ "agent_id": "planner",
// The nonce keeps each fan-out's tasks byte-distinct so the
// parallel-graph result cache can't short-circuit a re-spawn.
"prompt": format!("{} [spawn {nonce}]: inspect subsystem {i}", subagent_marker(i)),
@@ -235,7 +235,7 @@ impl SubagentMock {
})
.collect();
ChatResponse {
- text: Some(format!("Delegating to {} researchers.", self.width)),
+ text: Some(format!("Delegating to {} workers.", self.width)),
tool_calls: vec![ToolCall {
id: "profile-parallel-call".into(),
name: "spawn_parallel_agents".into(),
@@ -248,7 +248,7 @@ impl SubagentMock {
}
/// The subconscious's first turn: hand the task to the orchestrator (which
- /// owns `spawn_parallel_agents` and allows the `researcher` subagent).
+ /// owns `spawn_parallel_agents` and allows the `planner` subagent).
fn delegate_orchestrator_call(&self) -> ChatResponse {
ChatResponse {
text: Some("Delegating to the orchestrator for a parallel research fan-out.".into()),
@@ -269,7 +269,7 @@ impl SubagentMock {
/// Classify the turn by the *executing agent* (from the Tool Policy Boundary
/// header) and script the real delegation chain:
/// subconscious → `delegate_orchestrator` → orchestrator →
- /// `spawn_parallel_agents(K)` → K researchers → orchestrator merge →
+ /// `spawn_parallel_agents(K)` → K planner workers → orchestrator merge →
/// subconscious final. No latency/recording here — the async `chat` wrappers
/// handle sleeping + latency capture around this.
fn reply(&self, joined: &str) -> ChatResponse {
@@ -277,14 +277,14 @@ impl SubagentMock {
return self.reply_orchestrator_driven(joined);
}
// Original `subagents` routing (subconscious-driven): merge once both
- // findings are present, answer a researcher's marker with its finding,
+ // findings are present, answer a worker's marker with its finding,
// else emit the fan-out directly. The subconscious rejects the unknown
// `spawn_parallel_agents`, echoing the markers back — which is all the
// `subagents` scenario asserts.
if self.is_merge(joined) {
- return response("Merged all researcher findings.");
+ return response("Merged all worker findings.");
}
- if let Some(i) = self.researcher_index(joined) {
+ if let Some(i) = self.worker_index(joined) {
return response(&finding_text(i));
}
self.spawn_call()
@@ -292,11 +292,11 @@ impl SubagentMock {
/// Agent-aware routing for the orchestrator-driven storm.
fn reply_orchestrator_driven(&self, joined: &str) -> ChatResponse {
- // Researcher worker: return its finding.
- if self.is_researcher_turn(joined) {
+ // Planner worker: return its finding.
+ if self.is_worker_turn(joined) {
let i = self
- .researcher_index(joined)
- .expect("researcher turn has a marker");
+ .worker_index(joined)
+ .expect("worker turn has a marker");
return response(&finding_text(i));
}
// Orchestrator: fan out, then merge once every finding is back.
@@ -309,7 +309,7 @@ impl SubagentMock {
// Parent (subconscious / any other): finish once the orchestrator's
// merged result has flowed back; otherwise delegate to the orchestrator.
if joined.contains(MERGE_SENTINEL) {
- return response("Storm complete: merged every researcher's finding.");
+ return response("Storm complete: merged every worker's finding.");
}
self.delegate_orchestrator_call()
}
@@ -329,18 +329,18 @@ impl ChatModel<()> for SubagentMock {
}
impl SubagentMock {
- /// Record the prompt, sleep a sampled latency for *researcher* calls (and
+ /// Record the prompt, sleep a sampled latency for *worker* calls (and
/// capture their wall time), then return the classified response.
async fn dispatch(&self, joined: &str) -> ChatResponse {
record(&self.prompts, joined);
- let is_researcher = self.is_researcher_turn(joined);
+ let is_worker = self.is_worker_turn(joined);
let started = std::time::Instant::now();
- if is_researcher {
+ if is_worker {
self.latency.sleep_sampled().await;
}
let resp = self.reply(joined);
- if is_researcher {
- self.researcher_latencies_ms
+ if is_worker {
+ self.worker_latencies_ms
.lock()
.expect("mock latency lock")
.push(started.elapsed().as_millis());
diff --git a/crates/openhuman-cli/src/bin/library_profile/scenarios/subagent_storm.rs b/crates/openhuman-cli/src/bin/library_profile/scenarios/subagent_storm.rs
index 34afb9b425..04fd3a5690 100644
--- a/crates/openhuman-cli/src/bin/library_profile/scenarios/subagent_storm.rs
+++ b/crates/openhuman-cli/src/bin/library_profile/scenarios/subagent_storm.rs
@@ -1,9 +1,9 @@
//! `subagent-storm`: fuzz the *width* of delegation inside ONE core instance.
//!
-//! One orchestrator turn fans out to **K** parallel researcher subagents (all
+//! One orchestrator turn fans out to **K** parallel `planner` subagents (all
//! in-process tokio tasks, not child processes) via `spawn_parallel_agents`.
//! K comes from `OPENHUMAN_PROFILE_SUBAGENTS` (default 8; tested up to 32), and
-//! each researcher carries per-subagent mock latency drawn from the shared
+//! each worker carries per-subagent mock latency drawn from the shared
//! `OPENHUMAN_PROFILE_MOCK_LATENCY_MS` / `_JITTER_MS` knobs.
//!
//! ## Measurement shape (and a hard constraint we hit)
@@ -14,9 +14,9 @@
//! machinery is effectively one-shot per process. Once a fan-out's run ledger is
//! finalized, a second `spawn_parallel_agents` returns an empty result and the
//! orchestrator just re-calls the tool without re-running the workers. Worse,
-//! merely *constructing* an orchestrator/researcher agent beforehand perturbs
+//! merely *constructing* an orchestrator/planner agent beforehand perturbs
//! the fan-out the same way. The only shape that reliably executes all K real
-//! researcher subagents is a single fan-out as the process's first agent
+//! planner subagents is a single fan-out as the process's first agent
//! activity.
//!
//! So this scenario measures exactly that: one cold width-K fan-out. `retained_delta_kib`
@@ -30,8 +30,12 @@
//!
//! Reported fields: `subagents = K`, `marginal_rss_kib_per_agent` (retained/K,
//! upper bound), `checkpoints` (baseline → storm-turn-done), and
-//! `turn_latency_ms` (percentiles across the K researcher child executions).
-//! The workload asserts all K researcher subagents actually executed.
+//! `turn_latency_ms` (percentiles across the K planner child executions).
+//! The workload asserts all K planner subagents actually executed.
+//!
+//! The worker is `planner`: read-only, no spawn tools, and in the orchestrator's
+//! `[subagents] allowlist` — the closest surviving fit for the retired
+//! `researcher` archetype this scenario used to fan out to.
use anyhow::Result;
use openhuman_core::agent::harness::AgentDefinitionRegistry;
@@ -44,13 +48,14 @@ use crate::mock::{subagent_marker, SubagentMock};
const DEFAULT_SUBAGENTS: usize = 8;
/// The orchestrator's top-level task. The mock ignores the wording and always
-/// fans out to K researchers.
+/// fans out to K planner workers.
const STORM_PROMPT: &str = "Research every subsystem in parallel and merge the findings.";
-/// Positive identity anchor for a researcher *worker* turn — its own system
-/// prompt names it. Distinguishes a real worker from the orchestrator turns that
-/// also echo every task marker in the fan-out tool call / result.
-const RESEARCHER_IDENTITY: &str = "You are the **Researcher** agent";
+/// Positive identity anchor for a planner *worker* turn — its own system
+/// prompt (`agents/planner/prompt.md`) names it. Distinguishes a real worker
+/// from the orchestrator turns that also echo every task marker in the fan-out
+/// tool call / result.
+const WORKER_IDENTITY: &str = "You are the **Planner** agent";
fn env_usize(key: &str, default: usize) -> usize {
std::env::var(key)
@@ -100,9 +105,9 @@ pub async fn run() -> Result<ProfileResult> {
eprintln!("[library-profile] subagent-storm: width={width} — single cold width-K fan-out");
// We drive the `orchestrator` agent directly: it owns `spawn_parallel_agents`
- // and allows the `researcher` subagent (the chat-tier subconscious has
+ // and allows the `planner` subagent (the chat-tier subconscious has
// neither, and would reject the fan-out). One orchestrator turn fans out to
- // K real researcher subagents via the parallel graph. This fan-out MUST be
+ // K real planner subagents via the parallel graph. This fan-out MUST be
// the process's first agent activity — see the module docs for why prewarming
// is not possible here.
let config = fixture.config.clone();
@@ -113,17 +118,17 @@ pub async fn run() -> Result<ProfileResult> {
let reply = agent.run_single(STORM_PROMPT).await?;
rec.checkpoint("storm-turn-done")?;
anyhow::ensure!(!reply.trim().is_empty(), "empty storm-turn response");
- // Every one of the K researcher subagents must have actually executed as
+ // Every one of the K planner subagents must have actually executed as
// its own worker turn: for each i there must be a prompt that carries the
- // researcher identity anchor AND that researcher's task marker — not
+ // planner identity anchor AND that worker's task marker — not
// merely an orchestrator turn echoing every marker in the fan-out call.
let prompts = mock_for_workload.prompts.lock().expect("mock prompt lock");
for i in 1..=width {
anyhow::ensure!(
prompts
.iter()
- .any(|p| p.contains(RESEARCHER_IDENTITY) && p.contains(&subagent_marker(i))),
- "researcher subagent {i}/{width} never executed as its own worker turn"
+ .any(|p| p.contains(WORKER_IDENTITY) && p.contains(&subagent_marker(i))),
+ "planner subagent {i}/{width} never executed as its own worker turn"
);
}
Ok(())
@@ -139,13 +144,13 @@ pub async fn run() -> Result<ProfileResult> {
None
};
let latencies = mock
- .researcher_latencies_ms
+ .worker_latencies_ms
.lock()
.expect("mock latency lock")
.clone();
eprintln!(
"[library-profile] subagent-storm: width={width} retained_delta_kib={} \
- marginal_rss_kib_per_agent={:?} researcher_executions={}",
+ marginal_rss_kib_per_agent={:?} worker_executions={}",
result.retained_delta_kib,
marginal,
latencies.len()
diff --git a/crates/openhuman-core/src/config/ops/search.rs b/crates/openhuman-core/src/config/ops/search.rs
index 577ac7f978..0d483cac72 100644
--- a/crates/openhuman-core/src/config/ops/search.rs
+++ b/crates/openhuman-core/src/config/ops/search.rs
@@ -82,6 +82,7 @@ fn docs_url(provider: &str) -> Option<&'static str> {
"querit" => Some("https://querit.ai/"),
"seltz" => Some("https://seltz.ai/"),
"searxng" => Some("https://docs.searxng.org/"),
+ "tinyfish" => Some("https://agent.tinyfish.ai/api-keys"),
_ => None,
}
}
@@ -89,14 +90,11 @@ fn docs_url(provider: &str) -> Option<&'static str> {
/// Routes a provider supports, in UI order.
fn supported_routes(provider: &str) -> Vec<&'static str> {
let managed = MANAGED_SEARCH_PROVIDERS.contains(&provider);
- let direct = provider != "tinyfish";
let mut routes = Vec::new();
if managed {
routes.push(SearchRoute::Managed.as_str());
}
- if direct {
- routes.push(SearchRoute::Direct.as_str());
- }
+ routes.push(SearchRoute::Direct.as_str());
routes
}
@@ -157,7 +155,7 @@ fn apply_provider_patch(
if let Some(key) = patch.api_key {
match provider {
"seltz" => config.seltz.api_key = nonempty(&key),
- "searxng" | "tinyfish" => {
+ "searxng" => {
return Err(format!("{provider} does not take an API key"));
}
other => {
@@ -339,7 +337,7 @@ pub(crate) fn search_settings_json_with(config: &Config, managed_available: bool
"routes": supported_routes(p.id),
"managed_available": p.managed_available,
"key_configured": p.key_configured,
- "takes_key": !matches!(p.id, "searxng" | "tinyfish"),
+ "takes_key": p.id != "searxng",
"usable": p.usable,
"status": p.status(search_enabled),
"roles": p.roles,
diff --git a/crates/openhuman-core/src/config/schema/load/env_overlay/search.rs b/crates/openhuman-core/src/config/schema/load/env_overlay/search.rs
index d1e32a1e28..a45940fc55 100644
--- a/crates/openhuman-core/src/config/schema/load/env_overlay/search.rs
+++ b/crates/openhuman-core/src/config/schema/load/env_overlay/search.rs
@@ -236,6 +236,11 @@ impl Config {
self.search.tavily.api_key = Some(key);
}
}
+ if let Some(key) = env.get_any(&["OPENHUMAN_TINYFISH_API_KEY", "TINYFISH_API_KEY"]) {
+ if !key.trim().is_empty() {
+ self.search.tinyfish.api_key = Some(key);
+ }
+ }
if let Some(max) = env.get_any(&["OPENHUMAN_SEARCH_MAX_RESULTS", "SEARCH_MAX_RESULTS"]) {
if let Ok(n) = max.parse::<usize>() {
if (1..=20).contains(&n) {
diff --git a/crates/openhuman-core/src/config/schema/tools/search.rs b/crates/openhuman-core/src/config/schema/tools/search.rs
index 1f99f724b9..92ba016c78 100644
--- a/crates/openhuman-core/src/config/schema/tools/search.rs
+++ b/crates/openhuman-core/src/config/schema/tools/search.rs
@@ -353,6 +353,10 @@ pub struct SearchConfig {
/// Parallel route.
#[serde(default)]
pub parallel: SearchEngineCredentials,
+ /// TinyFish key. TinyFish is bring-your-own-key only: the TinyHumans
+ /// backend does not proxy it.
+ #[serde(default)]
+ pub tinyfish: SearchEngineCredentials,
// ── Legacy single-engine fields: read for migration, never written ──
#[serde(default, skip_serializing)]
@@ -390,6 +394,7 @@ impl Default for SearchConfig {
parallel_route: None,
gemini_route: None,
parallel: SearchEngineCredentials::default(),
+ tinyfish: SearchEngineCredentials::default(),
}
}
}
@@ -429,6 +434,7 @@ impl SearchConfig {
"tavily" => Some(&self.tavily),
"gemini" | "gemini_deep_research" => Some(&self.gemini),
"parallel" => Some(&self.parallel),
+ "tinyfish" => Some(&self.tinyfish),
_ => None,
}
}
@@ -441,6 +447,7 @@ impl SearchConfig {
"tavily" => Some(&mut self.tavily),
"gemini" | "gemini_deep_research" => Some(&mut self.gemini),
"parallel" => Some(&mut self.parallel),
+ "tinyfish" => Some(&mut self.tinyfish),
_ => None,
}
}
diff --git a/crates/openhuman-core/src/search/providers.rs b/crates/openhuman-core/src/search/providers.rs
index a4e6149be2..545fbad0ba 100644
--- a/crates/openhuman-core/src/search/providers.rs
+++ b/crates/openhuman-core/src/search/providers.rs
@@ -69,7 +69,6 @@ pub fn direct_configured(config: &Config, provider: &str) -> bool {
.as_deref()
.is_some_and(|key| !key.trim().is_empty()),
"searxng" => !config.searxng.base_url.trim().is_empty(),
- "tinyfish" => false,
other => config
.search
.credentials(other)