The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(agent): add flow builder and discovery operations
Steven Enamakelcbca892593e4
diff --git a/crates/openhuman-core/src/agent/registry/ops.rs b/crates/openhuman-core/src/agent/registry/ops.rsindex 3e9acd28c0..b65c570fa6 100644--- a/crates/openhuman-core/src/agent/registry/ops.rs+++ b/crates/openhuman-core/src/agent/registry/ops.rs@@ -158,7 +158,7 @@ pub async fn available_tools(ctx: &DispatchCtx) -> Result<Vec<AgentToolInfo>, Stlet config = ctx.load_config().await?;AgentDefinitionRegistry::init_global(&config.workspace_dir).map_err(|e| format!("failed to initialise AgentDefinitionRegistry: {e}"))?;- let agent = OpenHumanSessionHost::from_config_for_agent(&config, ORCHESTRATOR_AGENT_ID)+ let agent = OpenHumanSessionHost::from_config_for_agent(ctx, &config, ORCHESTRATOR_AGENT_ID).map_err(|e| format!("failed to build tools-catalog agent: {e}"))?;let mut tools: Vec<AgentToolInfo> = agentdiff --git a/crates/openhuman-core/src/flows/ops/builder.rs b/crates/openhuman-core/src/flows/ops/builder.rsindex ae7284a018..2ea3ce11f5 100644--- a/crates/openhuman-core/src/flows/ops/builder.rs+++ b/crates/openhuman-core/src/flows/ops/builder.rs@@ -86,7 +86,7 @@ pub(crate) async fn flows_build_with_extra_hidden_tools(// resolves the per-agent iteration cap from the `workflow_builder`// `AgentDefinition` itself (`iteration_policy = "extended"` ->// `effective_max_iterations()` = 50), so no override is needed here.- let mut agent = OpenHumanSessionHost::from_config_for_agent(config, "workflow_builder")+ let mut agent = OpenHumanSessionHost::from_config_for_agent(ctx, config, "workflow_builder").map_err(|e| format!("failed to build workflow_builder agent: {e:#}"))?;agent.set_agent_definition_name("workflow_builder".to_string());start_builder_turn_clean(&mut agent);diff --git a/crates/openhuman-core/src/flows/ops/discovery.rs b/crates/openhuman-core/src/flows/ops/discovery.rsindex 00d5d6c988..0e9518ad27 100644--- a/crates/openhuman-core/src/flows/ops/discovery.rs+++ b/crates/openhuman-core/src/flows/ops/discovery.rs@@ -58,7 +58,7 @@ pub async fn flows_discover().map_err(|e| format!("failed to initialise agent registry: {e}"))?;- let mut agent = OpenHumanSessionHost::from_config_for_agent(config, "flow_discovery")+ let mut agent = OpenHumanSessionHost::from_config_for_agent(ctx, config, "flow_discovery").map_err(|e| format!("failed to build flow_discovery agent: {e:#}"))?;agent.set_agent_definition_name("flow_discovery".to_string());diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rsindex 977a1920ab..eb990d17c1 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs@@ -268,16 +268,17 @@ fn definition_for_turn(}fn build_turn_agent(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,target: &AgentChatTarget<'_>,session_id: Option<&str>,temperature: Option<f64>,) -> Result<OpenHumanSessionHost, String> {match target {- AgentChatTarget::Orchestrator => OpenHumanSessionHost::from_config(config),+ AgentChatTarget::Orchestrator => OpenHumanSessionHost::from_config(ctx, config),AgentChatTarget::AgentId(id) => {log::debug!("[inference] agent_chat building agent_id={id}");- OpenHumanSessionHost::from_config_for_agent(config, id)+ OpenHumanSessionHost::from_config_for_agent(ctx, config, id)}AgentChatTarget::Definition {definition,@@ -286,7 +287,7 @@ fn build_turn_agent(..} => {let definition = definition_for_turn(definition, temperature);- OpenHumanSessionHost::from_config_host_only(config, &definition, *host, session_id)+ OpenHumanSessionHost::from_config_host_only(ctx, config, &definition, *host, session_id)}AgentChatTarget::Definition {definition, host, ..@@ -294,12 +295,13 @@ fn build_turn_agent(let definition = definition_for_turn(definition, temperature);match host {Some(host) => OpenHumanSessionHost::from_config_with_host_tools(+ ctx,config,&definition,host,session_id,),- None => OpenHumanSessionHost::from_config_with_definition(config, &definition),+ None => OpenHumanSessionHost::from_config_with_definition(ctx, config, &definition),}}}@@ -428,6 +430,8 @@ pub async fn agent_chat_reply_for(.map(str::trim).filter(|id| !id.is_empty());let turn_cwd = resolve_turn_cwd(cwd)?;+ // The turn's context: the host environment's bound one, else the task's.+ let turn_ctx = crate::core::runtime::DispatchCtx::from_weak(env.host.core.as_ref());let mut agent = match turn_cwd.as_ref() {// Per-turn root. Building from a config clone whose `action_dir` is the// requested directory is what makes this a *turn-scoped* override: the@@ -445,14 +449,14 @@ pub async fn agent_chat_reply_for("[inference] agent_chat rooting turn tools at cwd={}",root.display());- let mut agent = build_turn_agent(&scoped, &target, turn_session_id, temperature)?;+ let mut agent = build_turn_agent(&turn_ctx, &scoped, &target, turn_session_id, temperature)?;// Also thread it as the turn's workspace descriptor so acting tools// that read `ToolExecutionContext::workspace` (shell) resolve their// default cwd here, and so spawned sub-agents inherit the same root.agent.set_workspace_descriptor(Some(tinytools::WorkspaceDescriptor::new(root.clone())));agent}- None => build_turn_agent(config, &target, turn_session_id, temperature)?,+ None => build_turn_agent(&turn_ctx, config, &target, turn_session_id, temperature)?,};// Thread-correct resume. `OpenHumanSessionHost::turn` would otherwise auto-load the// newest transcript for the agent *name*, which is another thread'sdiff --git a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs b/crates/openhuman-core/src/mcp/server/tools/dispatch.rsindex b7d82454ff..d0d081c7f7 100644--- a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs+++ b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs@@ -225,7 +225,7 @@ async fn load_config_and_init_registry(ctx: &DispatchCtx) -> Result<crate::confiasync fn build_orchestrator_agent(ctx: &DispatchCtx) -> Result<OpenHumanSessionHost, ToolCallError> {let config = load_config_and_init_registry(ctx).await?;let mut agent =- OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator").map_err(|err| {+ OpenHumanSessionHost::from_config_for_agent(ctx, &config, "orchestrator").map_err(|err| {ToolCallError::Internal(format!("failed to build orchestrator agent: {err}"))})?;agent.fetch_connected_integrations().await;@@ -342,7 +342,7 @@ async fn run_subagent_tool(ctx: &DispatchCtx, params: &Map<String, Value>) -> Relet config = load_config_and_init_registry(ctx).await?;let mut agent =- OpenHumanSessionHost::from_config_for_agent(&config, agent_id).map_err(|err| {+ OpenHumanSessionHost::from_config_for_agent(ctx, &config, agent_id).map_err(|err| {ToolCallError::InvalidParams(format!("failed to build agent `{agent_id}`: {err}"))})?;agent.set_event_context(diff --git a/crates/openhuman-core/src/web_chat/session.rs b/crates/openhuman-core/src/web_chat/session.rsindex 15c53e7e8b..cb0c9b746d 100644--- a/crates/openhuman-core/src/web_chat/session.rs+++ b/crates/openhuman-core/src/web_chat/session.rs@@ -132,6 +132,7 @@ fn effective_session_config(}pub(super) fn build_session_agent(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,client_id: &str,thread_id: &str,@@ -151,6 +152,7 @@ pub(super) fn build_session_agent();let agent_result = OpenHumanSessionHost::from_config_for_agent_session(+ ctx,&effective,target_agent_id,Some(thread_id),@@ -448,6 +450,7 @@ pub(crate) async fn checkout_session_agent();(build_session_agent(+ ctx,config,client_id,thread_id,@@ -460,6 +463,7 @@ pub(crate) async fn checkout_session_agent(}None => (build_session_agent(+ ctx,config,client_id,thread_id,