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
test(flows): cover concurrent copilot callbacks keeping profile scope
Steven Enamakel37ae479b398e
diff --git a/crates/openhuman-core/src/flows/copilot_bus_tests.rs b/crates/openhuman-core/src/flows/copilot_bus_tests.rsindex c8aef79001..6006cda9cc 100644--- a/crates/openhuman-core/src/flows/copilot_bus_tests.rs+++ b/crates/openhuman-core/src/flows/copilot_bus_tests.rs@@ -51,3 +51,84 @@ async fn model_arguments_cannot_replace_the_scoped_host_callback_address() {let output: Value = serde_json::from_str(&result.output()).expect("tool JSON result");assert!(output.get("agent_definitions").is_some(), "{output}");}++fn tool_context(+ core: Arc<crate::core::runtime::CoreContext>,+ id: &str,+) -> tinyagents_harness::tool::ToolExecutionContext {+ let run = crate::agent::tinyagents::host::run_context::OpenHumanRunContext::new()+ .with_core(Some(core))+ .into_tinyagents(tinyagents_harness::context::RunConfig::new(id));+ tinyagents_harness::tool::ToolExecutionContext::from_run_context(+ &run,+ tinyagents_harness::ids::CallId::new(format!("{id}-call")),+ )+}++#[tokio::test]+async fn concurrent_tool_callbacks_keep_each_explicit_profile_scope() {+ use crate::core::runtime::{ContextOverlay, CoreContext, DispatchCtx, DomainSet, ToolGroups};++ let workspace = tempfile::tempdir().expect("temporary workspace");+ let mut config = Config::default();+ config.workspace_dir = workspace.path().join("workspace");+ config.action_dir = config.workspace_dir.clone();+ config.config_path = workspace.path().join("config.toml");+ std::fs::create_dir_all(&config.workspace_dir).expect("workspace directory");++ let root = CoreContext::for_test_with_config(DomainSet::full(), config.clone());+ let alice = root.derive_with(+ ContextOverlay::new(config.clone(), DomainSet::full(), ToolGroups::default())+ .profile("copilot-alice"),+ );+ let bob = root.derive_with(+ ContextOverlay::new(config.clone(), DomainSet::full(), ToolGroups::default())+ .profile("copilot-bob"),+ );+ let graph = json!({+ "nodes": [{"id":"trigger","kind":"trigger","name":"Trigger","config":{}}],+ "edges": []+ });+ for (context, name) in [(&alice, "Alice only"), (&bob, "Bob only")] {+ let context = Arc::clone(context);+ let config = config.clone();+ let graph = graph.clone();+ let name = name.to_string();+ CoreContext::scope(context.clone(), async move {+ crate::flows::ops::flows_create(+ &DispatchCtx::new(context),+ &config,+ name,+ graph,+ false,+ )+ .await+ .expect("profile flow creation");+ })+ .await;+ }++ let catalog = CopilotToolCatalog::load(Arc::new(config)).expect("module tool catalog loads");+ let tool = catalog.tool("list_flows").expect("list_flows is catalogued");+ let alice_call = tool_context(alice, "copilot-alice");+ let bob_call = tool_context(bob, "copilot-bob");+ let alice_future = tool.execute_with_context(+ json!({}),+ tinytools::ToolCallOptions::default(),+ Some(&alice_call),+ );+ let bob_future = tool.execute_with_context(+ json!({}),+ tinytools::ToolCallOptions::default(),+ Some(&bob_call),+ );+ let (alice_result, bob_result) = tokio::join!(alice_future, bob_future);+ let alice_result = alice_result.expect("Alice callback result");+ let bob_result = bob_result.expect("Bob callback result");+ assert!(!alice_result.is_error, "{}", alice_result.output());+ assert!(!bob_result.is_error, "{}", bob_result.output());+ assert!(alice_result.output().contains("Alice only"));+ assert!(!alice_result.output().contains("Bob only"));+ assert!(bob_result.output().contains("Bob only"));+ assert!(!bob_result.output().contains("Alice only"));+}