Skip to content

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

chore(flows): update agent route doc links and add test module

Steven Enamakel4f6d640d829f
diff --git a/crates/openhuman-core/src/flows/agent_route.rs b/crates/openhuman-core/src/flows/agent_route.rs
index cebf9815e6..aa9a3960e3 100644
--- a/crates/openhuman-core/src/flows/agent_route.rs
+++ b/crates/openhuman-core/src/flows/agent_route.rs
@@ -2,7 +2,7 @@
use crate::inference::provider::{is_raw_passthrough_model, role_for_model_tier};
-/// Which execution path an `agent_ref` routes to (see [`crate::flows::tinyflows::caps::OpenHumanAgentRunner`]).
+/// Which execution path an `agent_ref` routes to (see [`crate::flows::caps_host::OpenHumanAgentRunner`]).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum AgentRoute {
/// A host-registered agent (`agent::host_agents`) — run the full agent
@@ -45,7 +45,8 @@ pub(crate) fn route_for_agent_ref(agent_ref: &str) -> AgentRoute {
/// the session builder's generic `chat` role — which inherits
/// `config.default_model` — to `make_openhuman_backend`, which forwards non-tier
/// ids to the backend unchanged. Mirrors the per-node routing
-/// [`crate::flows::tinyflows::caps::OpenHumanLlm::complete`] applies via `agent_prompt::resolve_completion_model`.
+/// [`crate::flows::caps_host::OpenHumanLlm::complete`] applies through the
+/// TinyFlows portability contract.
pub(crate) fn harness_model_default_override(node_model: &str) -> String {
if is_raw_passthrough_model(node_model) {
return node_model.to_string();
@@ -71,3 +72,7 @@ pub(crate) fn route_custom_entry_lookup(
_ => AgentRoute::RegistryFallback,
}
}
+
+#[cfg(test)]
+#[path = "agent_route_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/flows/agent_route_tests.rs b/crates/openhuman-core/src/flows/agent_route_tests.rs
new file mode 100644
index 0000000000..18239fc7a5
--- /dev/null
+++ b/crates/openhuman-core/src/flows/agent_route_tests.rs
@@ -0,0 +1,72 @@
+use super::*;
+
+use serde_json::json;
+
+fn custom_registry_entry(enabled: bool) -> crate::agent::registry::AgentRegistryEntry {
+ use crate::agent::registry::types::{AgentRegistrySource, AgentSubagentPolicy};
+ crate::agent::registry::AgentRegistryEntry {
+ id: "finance_analyst".to_string(),
+ name: "Finance Analyst".to_string(),
+ description: "Reviews spend and drafts finance summaries.".to_string(),
+ source: AgentRegistrySource::Custom,
+ enabled,
+ model: Some("hint:reasoning".to_string()),
+ system_prompt: Some("You are a meticulous finance analyst.".to_string()),
+ tool_allowlist: vec!["memory_search".to_string()],
+ tool_denylist: Vec::new(),
+ tool_rules: None,
+ subagents: AgentSubagentPolicy::default(),
+ tags: Vec::new(),
+ metadata: json!(null),
+ }
+}
+
+#[test]
+fn harness_model_default_override_normalises_tiers_to_hint_roles() {
+ assert_eq!(
+ harness_model_default_override("reasoning-v1"),
+ "hint:reasoning"
+ );
+ assert_eq!(harness_model_default_override("chat-v1"), "hint:chat");
+ assert_eq!(
+ harness_model_default_override("hint:reasoning"),
+ "hint:reasoning"
+ );
+}
+
+#[test]
+fn harness_model_default_override_forwards_raw_models_verbatim() {
+ assert_eq!(
+ harness_model_default_override("claude-opus-4"),
+ "claude-opus-4"
+ );
+ assert_eq!(
+ harness_model_default_override("openai:gpt-4o"),
+ "openai:gpt-4o"
+ );
+ assert_eq!(harness_model_default_override(" "), "hint:chat");
+}
+
+#[test]
+fn route_for_agent_ref_selects_harness_for_definitions_else_fallback() {
+ let _ = crate::agent::harness::host_definition::AgentDefinitionRegistry::init_global_builtins();
+ assert_eq!(route_for_agent_ref("workflow_builder"), AgentRoute::Harness);
+ assert_eq!(route_for_agent_ref("planner"), AgentRoute::Harness);
+ assert_eq!(
+ route_for_agent_ref("totally_unknown_custom_agent_xyz"),
+ AgentRoute::RegistryFallback
+ );
+}
+
+#[test]
+fn custom_agent_route_requires_an_enabled_registry_entry() {
+ assert_eq!(
+ route_custom_entry_lookup(Some(&custom_registry_entry(true))),
+ AgentRoute::Harness
+ );
+ assert_eq!(
+ route_custom_entry_lookup(Some(&custom_registry_entry(false))),
+ AgentRoute::RegistryFallback
+ );
+ assert_eq!(route_custom_entry_lookup(None), AgentRoute::RegistryFallback);
+}
diff --git a/crates/openhuman-core/src/flows/caps_host/binding_tests.rs b/crates/openhuman-core/src/flows/caps_host/binding_tests.rs
new file mode 100644
index 0000000000..0018b15315
--- /dev/null
+++ b/crates/openhuman-core/src/flows/caps_host/binding_tests.rs
@@ -0,0 +1,47 @@
+use super::*;
+
+use super::binding::CapsHostBinding;
+use crate::config::Config;
+use crate::core::runtime::{ComponentSet, CoreContext, DispatchCtx, DomainSet};
+use std::sync::Arc;
+use tempfile::TempDir;
+
+fn binding(ctx: DispatchCtx, temp: &TempDir) -> CapsHostBinding {
+ let config = Config {
+ workspace_dir: temp.path().join("workspace"),
+ action_dir: temp.path().join("workspace"),
+ config_path: temp.path().join("config.toml"),
+ ..Config::default()
+ };
+ CapsHostBinding {
+ ctx,
+ config: Arc::new(config.clone()),
+ flow_id: "flow-1".into(),
+ run_id: "run-1".into(),
+ security: Arc::new(crate::security::SecurityPolicy::from_config(
+ &config.autonomy,
+ &config.workspace_dir,
+ &config.action_dir,
+ )),
+ approval: Default::default(),
+ cancellation: tokio_util::sync::CancellationToken::new(),
+ agent_runs: tokio::sync::Mutex::new(std::collections::HashMap::new()),
+ }
+}
+
+#[tokio::test]
+async fn callback_reenters_the_captured_context_instead_of_ambient_context() {
+ let temp = TempDir::new().unwrap();
+ let handed_off = DispatchCtx::new(CoreContext::for_test_with_components(ComponentSet {
+ sandbox: false,
+ ..ComponentSet::default()
+ }));
+ let ambient = CoreContext::for_test(DomainSet::full(), None);
+ let binding = binding(handed_off, &temp);
+
+ CoreContext::scope(ambient, async {
+ assert!(DispatchCtx::ambient().components().sandbox);
+ assert!(!binding.within(async { DispatchCtx::ambient().components().sandbox }).await);
+ })
+ .await;
+}