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(agent): split monolithic test modules into focused files
Steven Enamakel6a5f63dc3e17
diff --git a/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs b/crates/openhuman-core/src/agent/attachments/mod_access_tests.rsindex 5f7a19a90c..47fbf08d42 100644--- a/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs+++ b/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs@@ -155,13 +155,13 @@ async fn thread_folder_upload_is_staged_where_the_turn_reads_it() {thread_in(&config, "gone", Some(&gone)).await;std::fs::remove_dir(&gone).unwrap();- let root = thread_action_dir(&config, &config.workspace_dir, Some("bound"))+ let root = thread_action_dir(&crate::core::runtime::DispatchCtx::ambient(), &config, &config.workspace_dir, Some("bound")).await.unwrap();assert_eq!(root, folder);for unbound in [Some("unbound"), Some("missing"), Some(""), None] {assert_eq!(- thread_action_dir(&config, &config.workspace_dir, unbound)+ thread_action_dir(&crate::core::runtime::DispatchCtx::ambient(), &config, &config.workspace_dir, unbound).await.unwrap(),config.action_dir@@ -170,7 +170,7 @@ async fn thread_folder_upload_is_staged_where_the_turn_reads_it() {// A folder that disappeared is an error, as in `run_task`, not a silent// fallback to the global dir.assert!(- thread_action_dir(&config, &config.workspace_dir, Some("gone"))+ thread_action_dir(&crate::core::runtime::DispatchCtx::ambient(), &config, &config.workspace_dir, Some("gone")).await.is_err());diff --git a/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs b/crates/openhuman-core/src/agent/debug/prompt_size_tests.rsindex 4d26883680..abd286fc3f 100644--- a/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs+++ b/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs@@ -87,7 +87,7 @@ fn session_report_measures_the_visible_belt_not_the_registry() {..crate::config::Config::default()};std::fs::create_dir_all(&config.workspace_dir).unwrap();- let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "critic")+ let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "critic").expect("critic session build");let dumped = crate::agent::debug::session_dump(&agent, "critic", String::new());diff --git a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rsindex d32a524a2f..8946029591 100644--- a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs@@ -266,7 +266,7 @@ async fn run_member_loop_drives_member_under_an_explicit_parent() {output: "did the thing".into(),fail: false,});- run_member_loop(+ run_member_loop(&crate::core::runtime::DispatchCtx::ambient(),&config,"team-1","m1",@@ -372,7 +372,7 @@ async fn start_member_run_blocks_on_unmet_dependency() {);// Explicit task-b: its dep task-a is not done → Blocked, no spawn.- let outcome = start_member_run(&config, "team-1", "m1", Some("task-b"), None)+ let outcome = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", Some("task-b"), None).await.unwrap();match outcome {@@ -399,7 +399,7 @@ async fn start_member_run_reports_already_claimed() {run_ledger::claim_agent_team_task(&config.workspace_dir, "team-1", "task-a", "m2", "tok").unwrap();- let outcome = start_member_run(&config, "team-1", "m1", Some("task-a"), None)+ let outcome = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", Some("task-a"), None).await.unwrap();assert_eq!(outcome, StartMemberOutcome::AlreadyClaimed);@@ -411,19 +411,19 @@ async fn start_member_run_no_claimable_and_unknown_task() {seed_team(&config, "team-1");seed_member(&config, "team-1", "m1", Some("task_manager_agent"));// No tasks at all → nothing claimable.- let none = start_member_run(&config, "team-1", "m1", None, None)+ let none = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", None, None).await.unwrap();assert_eq!(none, StartMemberOutcome::NoClaimableTask);// Explicit unknown task id → UnknownTask.- let unknown = start_member_run(&config, "team-1", "m1", Some("ghost"), None)+ let unknown = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", Some("ghost"), None).await.unwrap();assert_eq!(unknown, StartMemberOutcome::UnknownTask);// Unknown member → typed error.- let err = start_member_run(&config, "team-1", "ghost", None, None)+ let err = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "ghost", None, None).await.unwrap_err();assert_eq!(@@ -463,7 +463,7 @@ async fn start_member_run_rejects_already_active_member_without_side_effects() {vec![],);- let outcome = start_member_run(&config, "team-1", "m1", None, None)+ let outcome = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", None, None).await.unwrap();assert_eq!(outcome, StartMemberOutcome::AlreadyActive);diff --git a/crates/openhuman-core/src/agent/orchestration/parent_context/builder_tests.rs b/crates/openhuman-core/src/agent/orchestration/parent_context/builder_tests.rsindex 01123398de..7be9f4642c 100644--- a/crates/openhuman-core/src/agent/orchestration/parent_context/builder_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/parent_context/builder_tests.rs@@ -16,7 +16,7 @@ fn test_config() -> (tempfile::TempDir, Config) {#[tokio::test]async fn with_root_parent_hands_a_root_parent_to_the_closure() {let (_dir, config) = test_config();- let observed = with_root_parent(None, &config, "cron", "cron", "cron", |parent| async move {+ let observed = with_root_parent(&crate::core::runtime::DispatchCtx::ambient(), None, &config, "cron", "cron", "cron", |parent| async move {parent.agent_definition_id}).await@@ -33,10 +33,10 @@ async fn with_root_parent_hands_a_root_parent_to_the_closure() {#[tokio::test]async fn with_root_parent_uses_an_explicit_parent_override() {let (_dir, config) = test_config();- let outer = build_root_parent(&config, "outer", "outer", "outer")+ let outer = build_root_parent(&crate::core::runtime::DispatchCtx::ambient(), &config, "outer", "outer", "outer").await.expect("build explicit parent");- let observed = with_root_parent(+ let observed = with_root_parent(&crate::core::runtime::DispatchCtx::ambient(),Some(outer),&config,"inner",@@ -59,11 +59,11 @@ async fn with_root_parent_uses_an_explicit_parent_override() {async fn concurrent_root_parents_do_not_cross() {let (_dir, config) = test_config();let (a, b) = tokio::join!(- with_root_parent(None, &config, "surface_a", "a", "a", |parent| async move {+ with_root_parent(&crate::core::runtime::DispatchCtx::ambient(), None, &config, "surface_a", "a", "a", |parent| async move {tokio::task::yield_now().await;parent.agent_definition_id}),- with_root_parent(None, &config, "surface_b", "b", "b", |parent| async move {+ with_root_parent(&crate::core::runtime::DispatchCtx::ambient(), None, &config, "surface_b", "b", "b", |parent| async move {tokio::task::yield_now().await;parent.agent_definition_id}),diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rsindex 9170860ce2..8112983bfa 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs@@ -414,7 +414,7 @@ fn attach_workflow_proposal_persists_thread_message_and_extends_summary() {let history = vec![TranscriptMessage::tool(r#"{"type":"workflow_proposal","persisted":false,"name":"Daily X Trending Email","graph":{"nodes":[],"edges":[]}}"#,)];- let summary = attach_workflow_proposal(+ let summary = attach_workflow_proposal(&crate::core::runtime::DispatchCtx::ambient(),temp.path(),Some("thread-parent"),"sub-task-1",@@ -454,7 +454,7 @@ fn attach_workflow_proposal_persists_thread_message_and_extends_summary() {#[test]fn attach_workflow_proposal_without_proposal_returns_summary_unchanged() {let temp = tempfile::tempdir().expect("tempdir");- let summary = attach_workflow_proposal(+ let summary = attach_workflow_proposal(&crate::core::runtime::DispatchCtx::ambient(),temp.path(),Some("thread-x"),"sub-task-2",diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rsindex d65127cecf..f8a635a26d 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs@@ -95,7 +95,7 @@ fn render_worker_thread_result_carries_machine_readable_envelope() {fn persist_worker_thread_creates_thread_with_tasks_label_and_messages() {let temp = TempDir::new().expect("tempdir");let outcome = sample_outcome("the answer is 42");- let thread_id = persist_worker_thread(+ let thread_id = persist_worker_thread(&crate::core::runtime::DispatchCtx::ambient(),temp.path(),"task_manager_agent","draft a long research plan",diff --git a/crates/openhuman-core/src/agent/orchestration/tools/worker_thread_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/worker_thread_tests.rsindex da19cde5cd..b4e7682099 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/worker_thread_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/worker_thread_tests.rs@@ -5,7 +5,7 @@ fn creates_child_thread_linked_to_parent_and_seeds_prompt() {let dir = std::env::temp_dir().join(format!("wt-test-{}", uuid::Uuid::new_v4()));std::fs::create_dir_all(&dir).unwrap();- let id = create_worker_thread(+ let id = create_worker_thread(&crate::core::runtime::DispatchCtx::ambient(),dir.clone(),"parent-thread-1","researcher",@@ -44,7 +44,7 @@ fn creates_child_thread_linked_to_parent_and_seeds_prompt() {fn appends_follow_up_prompt_to_existing_worker_thread() {let dir = std::env::temp_dir().join(format!("wt-test-{}", uuid::Uuid::new_v4()));std::fs::create_dir_all(&dir).unwrap();- let id = create_worker_thread(+ let id = create_worker_thread(&crate::core::runtime::DispatchCtx::ambient(),dir.clone(),"parent-thread-1","researcher",@@ -53,7 +53,7 @@ fn appends_follow_up_prompt_to_existing_worker_thread() {).unwrap();- append_worker_user_message(dir.clone(), &id, "researcher", "sub-2", "Follow-up prompt")+ append_worker_user_message(&crate::core::runtime::DispatchCtx::ambient(), dir.clone(), &id, "researcher", "sub-2", "Follow-up prompt").unwrap();let messages = conversations::get_messages(diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rsindex 06e3285a38..5767e9207f 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs@@ -335,7 +335,7 @@ async fn an_empty_named_scope_advertises_no_tools_at_all() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let agent = OpenHumanSessionHost::from_config_for_agent(&config, "summarizer")+ let agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "summarizer").expect("summarizer is a shipped agent definition");let visible = agent.visible_tool_names_for_test();@@ -365,7 +365,7 @@ async fn a_zero_tool_agent_does_not_gain_the_compaction_recovery_tool() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let agent = OpenHumanSessionHost::from_config_for_agent(&config, "trigger_triage")+ let agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "trigger_triage").expect("trigger_triage is a shipped agent definition");assert!(@@ -421,7 +421,7 @@ async fn a_summarized_agent_sees_the_recovery_tool_with_compaction_off() {let mut config = test_config(&tmp);config.context.compaction_enabled = false;assert!(super::summarizes_tool_output("orchestrator", &config));- let agent = OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ let agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").expect("orchestrator is a shipped agent definition");let visible = agent.visible_tool_names_for_test();assert!(@@ -494,7 +494,7 @@ async fn a_curated_orchestrator_sees_and_holds_every_juice_tool_in_handle_mode()config.tokenjuice.repl_handle_enabled = true;assert!(crate::inference::tokenjuice::repl_handle_active(&config));- let agent = OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ let agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").expect("orchestrator is a shipped agent definition");let visible = agent.visible_tool_names_for_test();assert!(diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rsindex c1c40874c9..c67cc339d8 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs@@ -29,7 +29,7 @@ async fn from_config_with_definition_stamps_the_definition_on_the_session() {let config = test_config(&tmp);let def = explicit_definition("embedded-alpha");- let agent = OpenHumanSessionHost::from_config_with_definition(&config, &def)+ let agent = OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &def).expect("build from an explicit definition");assert_eq!(agent.agent_definition_id, "embedded-alpha");@@ -60,7 +60,7 @@ async fn resolved_definition_prefers_the_sessions_own_over_a_same_id_registry_en"the registry's orchestrator is not read-only, so a leak is observable");- let agent = OpenHumanSessionHost::from_config_with_definition(&config, &def)+ let agent = OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &def).expect("build from an explicit definition");assert_eq!(@@ -77,7 +77,7 @@ async fn registry_built_sessions_resolve_the_registry_definition() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let agent = OpenHumanSessionHost::from_config(&config).expect("orchestrator session");+ let agent = OpenHumanSessionHost::from_config(&crate::core::runtime::DispatchCtx::ambient(), &config).expect("orchestrator session");let resolved = agent.resolved_definition().expect("registry definition");assert_eq!(resolved.id, "orchestrator");let registry_mode = AgentDefinitionRegistry::global()diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rsindex fb5e1f4f90..30dcfd4cc8 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs@@ -75,7 +75,7 @@ fn a_host_only_session_registers_and_advertises_only_the_host_belt() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),&config,&orchestrator_def(),Some(&host_belt()),@@ -105,7 +105,7 @@ fn a_host_only_session_without_a_belt_has_no_tools() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),&config,&orchestrator_def(),None,@@ -122,7 +122,7 @@ fn a_host_only_session_runs_a_definition_that_cannot_delegate_or_act() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),&config,&orchestrator_def(),Some(&host_belt()),@@ -195,14 +195,14 @@ async fn the_host_only_policy_still_consults_the_hosts_own_gate() {fn only_a_host_only_session_accepts_untrusted_input() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let mut host_only = crate::agent::OpenHumanSessionHost::from_config_host_only(+ let mut host_only = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),&config,&orchestrator_def(),Some(&host_belt()),None,).expect("host-only session");- let mut normal = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let mut normal = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&orchestrator_def(),&host_belt(),@@ -222,7 +222,7 @@ fn only_a_host_only_session_accepts_untrusted_input() {async fn a_host_only_session_enforces_the_deny_by_default_gate() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),&config,&orchestrator_def(),Some(&host_belt()),diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rsindex 1de6e058fe..d7445f02fc 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs@@ -88,7 +88,7 @@ fn a_host_tool_is_on_the_belt_and_advertised() {crate::agent::HostTurnTools::advertised(vec![Box::new(Marker("oc_marker_tool"))])});- let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,@@ -112,7 +112,7 @@ fn a_host_can_withhold_a_config_tool_for_one_turn() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);let normally_visible =- crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, &definition())+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition()).expect("build a session without a host belt").visible_tool_specs_arc().first()@@ -129,7 +129,7 @@ fn a_host_can_withhold_a_config_tool_for_one_turn() {..Default::default()})};- let hidden_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let hidden_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,@@ -145,7 +145,7 @@ fn a_host_can_withhold_a_config_tool_for_one_turn() {"a per-turn host withholding must remove a config-derived tool from the provider view");- let visible_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let visible_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,@@ -170,7 +170,7 @@ fn withholding_tool_search_disables_wildcard_discovery() {..Default::default()});- let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,@@ -203,7 +203,7 @@ fn the_factory_runs_once_per_session_build() {};for _ in 0..2 {- crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,@@ -226,7 +226,7 @@ fn no_host_belt_leaves_the_advertised_set_alone() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);let agent =- crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, &definition())+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition()).expect("build a plain session");assert!(@@ -266,7 +266,7 @@ fn the_factory_is_told_the_session_it_is_building_for() {})};- let desked = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let desked = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,@@ -282,7 +282,7 @@ fn the_factory_is_told_the_session_it_is_building_for() {"the belt must be able to differ per conversation");- let unnamed = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let unnamed = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,@@ -325,7 +325,7 @@ fn a_host_tool_overrides_a_config_tool_of_the_same_name() {// A name the config-derived belt already carries, so the two collide.let contested =- crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, &definition())+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition()).expect("build a session without a host belt").visible_tool_specs_arc().first()@@ -341,7 +341,7 @@ fn a_host_tool_overrides_a_config_tool_of_the_same_name() {})};- let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,@@ -389,7 +389,7 @@ fn permanent_attachment_preserves_a_fresh_wildcard_belt() {let config = test_config(&tmp);let definition = definition();let baseline =- crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, &definition)+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition).unwrap();let original: std::collections::HashSet<_> = baseline.visible_tool_specs_arc()@@ -403,7 +403,7 @@ fn permanent_attachment_preserves_a_fresh_wildcard_belt() {tools.permanent.insert("attached_marker".into());tools});- let attached = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let attached = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition,&host,@@ -431,7 +431,7 @@ fn permanent_metadata_without_a_source_is_rejected_before_build() {permanent: std::collections::HashSet::from(["missing_source".into()]),..Default::default()});- let error = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ let error = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),&config,&definition(),&host,diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rsindex ad579d8b14..4a9a1e5c28 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs@@ -15,7 +15,7 @@ fn visible_names_for(let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);let agent =- crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, definition)+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, definition).unwrap_or_else(|e| panic!("{} session build: {e}", definition.id));agent.visible_tool_specs_arc()@@ -30,7 +30,7 @@ fn resetting_wildcard_visibility_keeps_collapsed_exposure() {let config = test_config(&tmp);let definition = super::wildcard_probe_def();let mut agent =- crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, &definition)+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition).expect("build wildcard agent");agent.set_visible_tool_names(std::collections::HashSet::new());@@ -46,7 +46,7 @@ fn hiding_and_reseeding_wildcard_visibility_keeps_collapsed_exposure() {let config = test_config(&tmp);let definition = super::wildcard_probe_def();let mut agent =- crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, &definition)+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition).expect("build wildcard agent");agent.set_visible_tool_names(std::collections::HashSet::new());@@ -224,7 +224,7 @@ fn orchestrator_reaches_the_replaced_specialists_tools_through_discovery() {.cloned().expect("orchestrator built-in definition");let agent =- crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, &definition)+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition).expect("orchestrator session build");let deferred = agent.deferred_tool_names_for_test();let visible = agent.visible_tool_names_for_test();diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rsindex a4ba59b28c..945591aff8 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs@@ -17,7 +17,7 @@ fn the_three_spec_views_share_their_leaf_schemas() {let tmp = tempfile::TempDir::new().unwrap();let config = test_config(&tmp);- let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").expect("orchestrator session build");let durable = agent.durable_tool_specs_arc();diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rsindex cbb1404a99..99f7b9e28c 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs@@ -490,7 +490,7 @@ fn a_subagent_thread_binding_claims_no_session_identity() {std::fs::create_dir_all(&config.workspace_dir).unwrap();let mut root =- super::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator").unwrap();+ super::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").unwrap();root.set_thread_id(Some("thread-1"));// The exact stem encoding (sanitisation, per-component digest, generation// suffix) belongs to tinyagents and is pinned by its own tests. What@@ -505,7 +505,7 @@ fn a_subagent_thread_binding_claims_no_session_identity() {);let mut child =- super::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator").unwrap();+ super::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").unwrap();child.session_parent_prefix = Some("1713000000_orchestrator".into());child.set_thread_id(Some("thread-1"));assert_eq!(child.session_id(), None);diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rsindex a330b03b4a..c3f552b685 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs@@ -22,7 +22,7 @@ fn a_session_composes_the_operator_and_definition_layers() {.find(|def| def.id == "orchestrator").expect("orchestrator");definition.disallowed_tools = vec!["web_*".to_string()];- let host = OpenHumanSessionHost::from_config_with_definition(&config, &definition)+ let host = OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition).expect("session builds");let rules = host.session_tool_rules();diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_juice_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_juice_tests.rsindex 14f880210f..323d1ec331 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_juice_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_juice_tests.rs@@ -56,7 +56,7 @@ async fn a_resumed_thread_keeps_recorded_juice_specs_and_executors_when_repl_is_current_config.tokenjuice.repl_handle_enabled = false;assert!(repl_tools_for(¤t_config).is_empty());let mut host =- crate::agent::OpenHumanSessionHost::from_config_for_agent(¤t_config, "summarizer")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), ¤t_config, "summarizer").expect("summarizer session");host.ensure_runtime_session().expect("runtime session");let prelude = host@@ -177,7 +177,7 @@ async fn resumed_juice_snapshot_does_not_add_live_repl_declarations() {recorded_spec.parameters = serde_json::json!({"type":"object","frozen":true});let recorded = ToolSnapshot::new(vec![recorded_spec.clone()]).expect("recorded snapshot");- let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "summarizer")+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "summarizer").expect("summarizer session");host.ensure_runtime_session().expect("runtime session");let prelude = host@@ -261,7 +261,7 @@ async fn juice_off_turn_loads_no_module_and_passes_tool_output_through() {config.tokenjuice.router_enabled = true;assert!(config.components.set("juice", false));- let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "summarizer")+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "summarizer").expect("summarizer session");host.ensure_runtime_session().expect("runtime session");let context_mw = hostdiff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rsindex 30d5a5ee25..b5e3890028 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs@@ -115,7 +115,7 @@ fn clearing_progress_releases_warm_prelude_sender() {..Default::default()};let mut host =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").expect("orchestrator");host.ensure_runtime_session().expect("warm runtime");@@ -203,7 +203,7 @@ fn connected_mcp_actions_enter_search_and_leave_on_disconnect() {..Default::default()};let mut host =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").expect("orchestrator");host.ensure_runtime_session().expect("runtime session");let prelude = host@@ -269,7 +269,7 @@ async fn resumed_mcp_snapshot_survives_a_cold_catalog_and_keeps_its_frozen_spec(..Default::default()};let mut host =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").expect("orchestrator");host.ensure_runtime_session().expect("runtime session");let prelude = host@@ -369,7 +369,7 @@ async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfaconfig.browser.enabled = true;config.http_request.allowed_domains = vec!["example.com".into()];let mut host =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").expect("desktop orchestrator");for name in ["browser", "browser_open"] {assert!(host.deferred_tool_names_for_test().contains(name), "{name}");@@ -409,7 +409,7 @@ async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfaconfig.browser.enabled = false;let disabled =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").expect("browser-disabled orchestrator");for name in ["browser", "browser_open"] {assert!(diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rsindex 5403e77bed..ec3b6cff1d 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs@@ -231,7 +231,7 @@ fn mirrored_tool_results_are_hidden_from_the_worker_thread_chat() {const RAW: &str = "{\"events\":[{\"title\":\"raw tool output the human never typed\"}]}";// The typed path (`TranscriptEntry::ToolResults`), used on a normal run.- mirror_worker_thread(+ mirror_worker_thread(&crate::core::runtime::DispatchCtx::ambient(),&dir,"worker-typed","researcher",@@ -258,7 +258,7 @@ fn mirrored_tool_results_are_hidden_from_the_worker_thread_chat() {);// The error-recovery path (`role: "tool"`), used when a run fails mid-turn.- mirror_worker_thread_from_history(+ mirror_worker_thread_from_history(&crate::core::runtime::DispatchCtx::ambient(),&dir,"worker-recovered","researcher",diff --git a/crates/openhuman-core/src/agent/triage/escalation_tests.rs b/crates/openhuman-core/src/agent/triage/escalation_tests.rsindex e6407d592e..cab29fa83f 100644--- a/crates/openhuman-core/src/agent/triage/escalation_tests.rs+++ b/crates/openhuman-core/src/agent/triage/escalation_tests.rs@@ -16,7 +16,7 @@ async fn build_triage_parent_scopes_allowed_subagents_to_target() {};let _ = AgentDefinitionRegistry::init_global_builtins();- let ctx = build_triage_parent(&config, "researcher")+ let ctx = build_triage_parent(&crate::core::runtime::DispatchCtx::ambient(), &config, "researcher").await.expect("build triage parent");diff --git a/crates/openhuman-core/src/agent/triage/routing_tests.rs b/crates/openhuman-core/src/agent/triage/routing_tests.rsindex 01fa9b82d5..6c470cfe62 100644--- a/crates/openhuman-core/src/agent/triage/routing_tests.rs+++ b/crates/openhuman-core/src/agent/triage/routing_tests.rs@@ -123,7 +123,7 @@ async fn resolve_provider_with_config_always_returns_remote() {// Even when runtime_enabled is true, triage must always use remote.let mut config = test_config();config.local_ai.runtime_enabled = true;- let resolved = resolve_provider_with_config(&config)+ let resolved = resolve_provider_with_config(&crate::core::runtime::DispatchCtx::ambient(), &config).await.expect("resolve should succeed");assert!(!resolved.used_local, "triage must never use local AI");@@ -134,7 +134,7 @@ async fn resolve_provider_with_config_always_returns_remote() {async fn resolve_provider_with_config_returns_remote_when_local_disabled() {let mut config = test_config();config.local_ai.runtime_enabled = false;- let resolved = resolve_provider_with_config(&config)+ let resolved = resolve_provider_with_config(&crate::core::runtime::DispatchCtx::ambient(), &config).await.expect("resolve should succeed");assert!(!resolved.used_local);diff --git a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rsindex 514ec50a0b..8261d3fb8b 100644--- a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs@@ -341,7 +341,7 @@ async fn cron_agent_job_uses_agent_definition_tool_scope() {job.name = Some("morning_briefing".into());job.agent_id = Some("morning_briefing".into());- let built = build_agent_for_cron_job(&config, &job).expect("build cron agent");+ let built = build_agent_for_cron_job(&crate::core::runtime::DispatchCtx::ambient(), &config, &job).expect("build cron agent");let visible = built.agent.visible_tool_names_for_test();assert!(diff --git a/crates/openhuman-core/src/cron/scheduler_host_agent_tests.rs b/crates/openhuman-core/src/cron/scheduler_host_agent_tests.rsindex 03973a2768..77d75edb54 100644--- a/crates/openhuman-core/src/cron/scheduler_host_agent_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_host_agent_tests.rs@@ -93,7 +93,7 @@ fn a_cron_job_for_a_host_agent_builds_with_its_host_tools_and_context() {});host_agents::install(Arc::clone(&installed));- let built = build_agent_for_cron_job(&config, &agent_job("cron-host-agent"));+ let built = build_agent_for_cron_job(&crate::core::runtime::DispatchCtx::ambient(), &config, &agent_job("cron-host-agent"));host_agents::clear_if(&installed);let built = built.expect("the host agent builds");@@ -122,7 +122,7 @@ fn an_id_the_host_does_not_know_falls_back_to_the_registries() {belt_builds: Arc::new(AtomicUsize::new(0)),});host_agents::install(Arc::clone(&installed));- let built = build_agent_for_cron_job(&config, &agent_job("orchestrator"));+ let built = build_agent_for_cron_job(&crate::core::runtime::DispatchCtx::ambient(), &config, &agent_job("orchestrator"));host_agents::clear_if(&installed);let built = built.expect("the orchestrator builds from the registries");assert!(built.context.is_none());diff --git a/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs b/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rsindex dff7ab55fa..ed4fcf3844 100644--- a/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs+++ b/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs@@ -27,7 +27,7 @@ async fn flows_discover_applies_the_flow_discovery_definitions_effective_iteratiassert_eq!(expected, 50);let agent =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "flow_discovery")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "flow_discovery").expect("build flow_discovery agent");assert_eq!(agent.agent_config().max_tool_iterations, expected);}diff --git a/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs b/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rsindex a59123ed7f..ac7b3bf944 100644--- a/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs+++ b/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs@@ -151,7 +151,7 @@ async fn flows_build_hides_the_live_run_tool_from_the_builder_belt() {).expect("agent registry init");let mut agent =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "workflow_builder")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "workflow_builder").expect("build workflow_builder agent");agent.set_agent_definition_name("workflow_builder".to_string());@@ -251,7 +251,7 @@ async fn flows_build_copilot_toolset_unhides_the_live_run_tools() {).expect("agent registry init");let mut agent =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "workflow_builder")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "workflow_builder").expect("build workflow_builder agent");agent.set_agent_definition_name("workflow_builder".to_string());@@ -329,7 +329,7 @@ async fn flows_build_applies_the_builder_definitions_effective_iteration_cap() {// definition's cap straight off the unmodified `config` — the session// builder resolves it internally now, no `flows_build`-side override.let agent =- crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "workflow_builder")+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "workflow_builder").expect("build workflow_builder agent");assert_eq!(agent.agent_config().max_tool_iterations, expected);assert_ne!(diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs b/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rsindex 678b46f156..429543979c 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs@@ -412,7 +412,7 @@ fn agent_node_runtime_resolves_to_the_definitions_effective_iteration_cap() {let expected = def.effective_max_iterations();assert_eq!(expected, 50);- let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "planner")+ let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "planner").expect("build planner agent");assert_eq!(agent.agent_config().max_tool_iterations, expected);diff --git a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs b/crates/openhuman-core/src/web_chat/session_checkout_tests.rsindex d4e3c43acc..313866b7eb 100644--- a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs+++ b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs@@ -88,7 +88,7 @@ fn prose(history: &[TranscriptEntry]) -> Vec<String> {}pub(super) fn host_seeded_with(config: &Config, marker: &str) -> OpenHumanSessionHost {- let mut host = OpenHumanSessionHost::from_config_for_agent(config, "orchestrator").unwrap();+ let mut host = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), config, "orchestrator").unwrap();host.seed_resume_from_messages(vec![("user".to_string(), marker.to_string()),