Skip to content

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

feat(agent): add researcher agent with prompt loading and tests

Steven Enamakel8230676ee657
diff --git a/crates/openhuman-core/src/agent/registry/agents/loader.rs b/crates/openhuman-core/src/agent/registry/agents/loader.rs
index 5160a04393..c08293573d 100644
--- a/crates/openhuman-core/src/agent/registry/agents/loader.rs
+++ b/crates/openhuman-core/src/agent/registry/agents/loader.rs
@@ -159,12 +159,6 @@ pub const BUILTINS: &[BuiltinAgent] = &[
prompt_fn: super::skill_creator::prompt::build,
graph_fn: None,
},
- BuiltinAgent {
- id: "researcher",
- toml: include_str!("researcher/agent.toml"),
- prompt_fn: super::researcher::prompt::build,
- graph_fn: Some(super::researcher::graph::graph),
- },
BuiltinAgent {
id: "context_scout",
toml: include_str!("context_scout/agent.toml"),
diff --git a/crates/openhuman-core/src/agent/registry/agents/mod.rs b/crates/openhuman-core/src/agent/registry/agents/mod.rs
index 13e3f32411..0bdbef33b8 100644
--- a/crates/openhuman-core/src/agent/registry/agents/mod.rs
+++ b/crates/openhuman-core/src/agent/registry/agents/mod.rs
@@ -16,7 +16,7 @@
//! [`BUILTINS`] installs it as `PromptSource::Dynamic` on the parsed
//! definition. Most archetypes keep a `prompt_tests.rs` beside it.
//!
-//! `researcher` additionally owns a `graph.rs` exposing
+//! An archetype may additionally own a `graph.rs` exposing
//! `fn graph() -> AgentGraph` for a bespoke turn graph; see
//! [`BuiltinAgent::graph_fn`].
//!
@@ -50,7 +50,6 @@ pub mod orchestrator;
pub mod planner;
pub mod presentation_agent;
pub mod profile_memory_agent;
-pub mod researcher;
pub mod scheduler_agent;
pub mod settings_agent;
pub mod skill_creator;
diff --git a/crates/openhuman-core/src/agent/registry/agents/researcher/agent.toml b/crates/openhuman-core/src/agent/registry/agents/researcher/agent.toml
deleted file mode 100644
index b85ecc4eb5..0000000000
--- a/crates/openhuman-core/src/agent/registry/agents/researcher/agent.toml
+++ /dev/null
@@ -1,31 +0,0 @@
-id = "researcher"
-display_name = "Researcher"
-delegate_name = "research"
-when_to_use = "Multi-source web research in a separate context: crawls, comparisons, deep digests. One fact or one page is `web_search_tool` / `web_fetch` directly."
-temperature = 0.4
-max_iterations = 10
-iteration_policy = "extended"
-max_turn_output_tokens = 4096
-max_result_chars = 8000
-sandbox_mode = "none"
-omit_identity = true
-omit_memory_context = true
-omit_safety_preamble = true
-# No eager memory pre-fetch. The researcher is a pure-function web/docs
-# specialist with `omit_memory_context = true`; the orchestrator passes it
-# the focused task to research, so it never needed the memory-tree walk.
-
-[model]
-hint = "burst"
-
-[tools]
-named = [
- # Keep the default researcher narrow: search to locate sources, a grounded
- # answer for a cited summary, contents/fetch to read selected pages.
- # Market, filesystem, and general HTTP/curl tools belong to more specific
- # agents so simple research tasks don't expand into open-ended search loops.
- "web_search_tool",
- "web_answer_tool",
- "web_contents_tool",
- "web_fetch",
-]
diff --git a/crates/openhuman-core/src/agent/registry/agents/researcher/graph.rs b/crates/openhuman-core/src/agent/registry/agents/researcher/graph.rs
deleted file mode 100644
index a5fdce577b..0000000000
--- a/crates/openhuman-core/src/agent/registry/agents/researcher/graph.rs
+++ /dev/null
@@ -1,146 +0,0 @@
-//! Bespoke turn graph for the built-in `researcher` agent.
-//!
-//! The researcher still uses the shared sub-agent leaf for the model/tool loop
-//! so transcript persistence, progress events, handoff middleware, and usage
-//! rollup stay identical to the default runner. This graph owns the first
-//! per-agent `AgentGraph::Custom` topology: route the research task, execute the
-//! shared turn leaf, then finalize the result.
-
-use std::future::Future;
-use std::pin::Pin;
-use std::sync::Arc;
-
-use tinyagents_graph::export::GraphTopology;
-use tinyagents_graph::{ClosureStateReducer, CompiledGraph, GraphBuilder, NodeContext, NodeResult};
-use tokio::sync::Mutex;
-
-use crate::agent::harness::agent_graph::{AgentGraph, AgentTurnRequest, AgentTurnResult};
-use crate::agent::subagent_host::SubagentRunError;
-
-const RESEARCHER_GRAPH_PHASES: &[&str] = &["route_research", "run_research_turn", "finalize"];
-
-#[derive(Clone, Default)]
-struct ResearcherGraphState {
- visited: Vec<&'static str>,
- request: Arc<Mutex<Option<AgentTurnRequest>>>,
- result: Arc<Mutex<Option<Result<AgentTurnResult, String>>>>,
-}
-
-impl ResearcherGraphState {
- fn with_request(request: AgentTurnRequest) -> Self {
- Self {
- request: Arc::new(Mutex::new(Some(request))),
- ..Self::default()
- }
- }
-}
-
-enum ResearcherGraphUpdate {
- PhaseEntered(&'static str),
-}
-
-type ResearcherGraphNodeFuture = Pin<
- Box<dyn Future<Output = tinyagents_harness::Result<NodeResult<ResearcherGraphUpdate>>> + Send>,
->;
-
-fn phase_node(
- phase: &'static str,
-) -> impl Fn(ResearcherGraphState, NodeContext) -> ResearcherGraphNodeFuture
- + Clone
- + Send
- + Sync
- + 'static {
- move |_state: ResearcherGraphState, _ctx: NodeContext| {
- Box::pin(async move {
- Ok(NodeResult::Update(ResearcherGraphUpdate::PhaseEntered(
- phase,
- )))
- })
- }
-}
-
-fn build_researcher_graph(
-) -> Result<CompiledGraph<ResearcherGraphState, ResearcherGraphUpdate>, String> {
- let phases = RESEARCHER_GRAPH_PHASES;
- GraphBuilder::<ResearcherGraphState, ResearcherGraphUpdate>::new()
- .set_reducer(ClosureStateReducer::new(
- |mut state: ResearcherGraphState, update: ResearcherGraphUpdate| {
- match update {
- ResearcherGraphUpdate::PhaseEntered(phase) => state.visited.push(phase),
- }
- Ok(state)
- },
- ))
- .add_node(phases[0], phase_node(phases[0]))
- .add_node(
- phases[1],
- |state: ResearcherGraphState, _ctx: NodeContext| {
- Box::pin(async move {
- let request = state.request.lock().await.take().ok_or_else(|| {
- tinyagents_harness::TinyAgentsError::Graph(
- "researcher graph missing turn request".to_string(),
- )
- })?;
- tracing::debug!(
- agent_id = %request.agent_id,
- task_id = %request.task_id,
- "[researcher_graph] running shared sub-agent turn leaf"
- );
- let result =
- crate::agent::subagent_host::run_agent_turn_request_via_default_graph(
- request,
- )
- .await
- .map_err(|err| err.to_string());
- *state.result.lock().await = Some(result);
- Ok(NodeResult::Update(ResearcherGraphUpdate::PhaseEntered(
- "run_research_turn",
- )))
- })
- },
- )
- .add_node(phases[2], phase_node(phases[2]))
- .add_edge(phases[0], phases[1])
- .add_edge(phases[1], phases[2])
- .set_entry(phases[0])
- .set_finish(phases[2])
- .compile()
- .map_err(|e| format!("researcher graph compile failed: {e}"))
-}
-
-async fn run_researcher_graph(
- request: AgentTurnRequest,
-) -> Result<AgentTurnResult, SubagentRunError> {
- let label = format!("agent:researcher:{}", request.task_id);
- let graph = build_researcher_graph()
- .map_err(|err| SubagentRunError::Provider(anyhow::anyhow!(err)))?
- .with_event_sink(Arc::new(
- crate::agent::tinyagents::observability::GraphTracingSink::new(label),
- ));
- let execution = graph
- .run(ResearcherGraphState::with_request(request))
- .await
- .map_err(|err| SubagentRunError::Provider(anyhow::anyhow!(err)))?;
- tracing::debug!(
- visited = ?execution.state.visited,
- "[researcher_graph] completed custom researcher topology"
- );
- let result = execution.state.result.lock().await.take().ok_or_else(|| {
- SubagentRunError::Provider(anyhow::anyhow!("researcher graph finished without result"))
- })?;
- result.map_err(|err| SubagentRunError::Provider(anyhow::anyhow!(err)))
-}
-
-fn run(
- request: AgentTurnRequest,
-) -> Pin<Box<dyn Future<Output = Result<AgentTurnResult, SubagentRunError>> + Send>> {
- Box::pin(run_researcher_graph(request))
-}
-
-pub fn graph() -> AgentGraph {
- AgentGraph::custom(run)
-}
-
-pub(crate) fn topology() -> Result<GraphTopology, String> {
- Ok(build_researcher_graph()?.topology())
-}
diff --git a/crates/openhuman-core/src/agent/registry/agents/researcher/mod.rs b/crates/openhuman-core/src/agent/registry/agents/researcher/mod.rs
deleted file mode 100644
index cedb79d0e6..0000000000
--- a/crates/openhuman-core/src/agent/registry/agents/researcher/mod.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-pub mod graph;
-pub mod prompt;
diff --git a/crates/openhuman-core/src/agent/registry/agents/researcher/prompt.md b/crates/openhuman-core/src/agent/registry/agents/researcher/prompt.md
deleted file mode 100644
index 7a324402b9..0000000000
--- a/crates/openhuman-core/src/agent/registry/agents/researcher/prompt.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# Researcher — Documentation & Web Crawler
-
-You are the **Researcher** agent. You find accurate, up-to-date information.
-
-## Capabilities
-
-- Web search for current information (`web_search_tool`), grounded answers with citations (`web_answer_tool`, pass `depth: "deep"` for a long research report when it is offered), and the readable text of known URLs, up to ten per call (`web_contents_tool`)
-- HTTP requests to fetch documentation (`web_fetch`)
-- The `web_*_tool`s are routed: each tries the configured search providers in order and falls back on its own when one is down or out of quota. Leave `provider` unset; setting it disables that fallback, so use it only when the user asks for a specific provider.
-
-## Rules
-
-- **Read real docs** — Don't guess API signatures or library usage. Look it up.
-- **No hallucination** — If you can't find the answer, say so. Never fabricate URLs or APIs.
-- **Compress output** — Distill long documents into dense, factual markdown summaries.
-- **Cite sources** — Include URLs or file paths for information you reference.
-- **Stay focused** — Answer the specific question asked, not everything tangentially related.
-
-## Research Loop Contract
-
-- Use `web_search_tool` to find likely sources when you do not already have a concrete URL, then read only the pages needed to answer: `web_contents_tool` for clean page text (batch the URLs into one call), `web_fetch` when it is not available or you need the raw response.
-- For simple factual requests, one focused search plus one or two fetched sources is enough unless results are empty or contradictory.
-- Do not keep broadening, re-searching, or chasing tangents once you have source-backed evidence for the requested answer.
-- Prefer fetching authoritative or primary sources over reading many secondary summaries.
-- If search or fetch fails, return what happened under `Failed tool calls`; do not silently keep trying unrelated queries. A routed search error has already been through every provider's fallback, so retrying the same call will not help.
-
-## Output Contract
-
-- Always return an output to the orchestrator, even when the answer is incomplete.
-- If you could answer, put the answer first, then list the URLs you used.
-- If you could not answer, say exactly what is missing and what you tried.
-- Never finish with only tool calls or internal notes; the orchestrator needs a compact synthesis it can pass on or evaluate.
-
-## Long-horizon Artifacts
-
-You are search-and-fetch only, so you never write files yourself. What you can do is keep the handoff small.
-
-- Lead with the answer and the sources that support it. A long dossier pasted into your reply costs the orchestrator context on every later step of a long-horizon task.
-- If your synthesis is genuinely large, the harness persists it under the action directory's `outputs/` folder and hands the orchestrator a path plus your abstract instead of the whole body. Write the reply so its opening lines stand alone as that abstract.
-- If a delegated task hands you an artifact path to work from, treat that path as the source of record and quote it back in your answer rather than re-pasting its contents.
diff --git a/crates/openhuman-core/src/agent/registry/agents/researcher/prompt.rs b/crates/openhuman-core/src/agent/registry/agents/researcher/prompt.rs
deleted file mode 100644
index d867d2089c..0000000000
--- a/crates/openhuman-core/src/agent/registry/agents/researcher/prompt.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-//! System prompt builder for the `researcher` built-in agent.
-//!
-//! Returns the fully-assembled system prompt. Each agent's `build()`
-//! composes section helpers from [`crate::agent::prompts`]
-//! in the order it wants — so the output IS what the LLM sees, no
-//! post-processing in the runner.
-
-use crate::agent::prompts::{render_tools, render_user_files, PromptContext};
-use anyhow::Result;
-
-const ARCHETYPE: &str = include_str!("prompt.md");
-
-pub fn build(ctx: &PromptContext<'_>) -> Result<String> {
- let mut out = String::with_capacity(4096);
- out.push_str(ARCHETYPE.trim_end());
- out.push_str("\n\n");
-
- let user_files = render_user_files(ctx)?;
- if !user_files.trim().is_empty() {
- out.push_str(user_files.trim_end());
- out.push_str("\n\n");
- }
-
- let tools = render_tools(ctx)?;
- if !tools.trim().is_empty() {
- out.push_str(tools.trim_end());
- out.push_str("\n\n");
- }
-
- Ok(out)
-}
-
-#[cfg(test)]
-#[path = "prompt_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/agent/registry/agents/researcher/prompt_tests.rs b/crates/openhuman-core/src/agent/registry/agents/researcher/prompt_tests.rs
deleted file mode 100644
index 59b8a7a74e..0000000000
--- a/crates/openhuman-core/src/agent/registry/agents/researcher/prompt_tests.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-use super::*;
-use crate::agent::prompts::{LearnedContextData, ToolCallFormat};
-use std::collections::HashSet;
-
-#[test]
-fn build_returns_nonempty_body() {
- let visible: HashSet<String> = HashSet::new();
- let ctx = PromptContext {
- workspace_dir: std::path::Path::new("."),
- model_name: "test",
- agent_id: "researcher",
- tools: &[],
- workflows: &[],
- dispatcher_instructions: "",
- learned: LearnedContextData::default(),
- visible_tool_names: &visible,
- tool_call_format: ToolCallFormat::PFormat,
- connected_integrations: &[],
- connected_identities_md: String::new(),
- include_profile: false,
- include_memory_md: false,
- curated_snapshot: None,
- user_identity: None,
- personality_roster: vec![],
- agents_md_global: None,
- agents_md_local: None,
- };
- let body = build(&ctx).unwrap();
- assert!(
- !body.contains("file_read") && !body.contains("file_write"),
- "researcher must not advertise workspace tools outside its search+fetch allowlist"
- );
-}
diff --git a/crates/openhuman-core/src/agent/tinyagents/topology.rs b/crates/openhuman-core/src/agent/tinyagents/topology.rs
index d24316692f..fd856b9f7c 100644
--- a/crates/openhuman-core/src/agent/tinyagents/topology.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/topology.rs
@@ -57,10 +57,6 @@ pub(crate) fn all_graph_topologies() -> Vec<GraphTopologyReport> {
out.push(describe("workflow_runs:scheduler_preview", &t));
}
- if let Ok(t) = crate::agent::registry::agents::researcher::graph::topology() {
- out.push(describe("agent:researcher", &t));
- }
-
// Not exported: item-count-driven `map_reduce` fan-outs whose node set is
// determined per run rather than by a fixed named topology.