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
chore(threads): pass dispatch context by reference in tests
Steven Enamakelefe1fec8b8d4
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 77f815a2c3..f43e692a9a 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@@ -396,7 +396,7 @@ fn attach_workflow_proposal_persists_thread_message_and_extends_summary() {use crate::threads::store::CreateConversationThread;let temp = tempfile::tempdir().expect("tempdir");conversations::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),temp.path().to_path_buf(),CreateConversationThread {id: "thread-parent".into(),@@ -431,7 +431,7 @@ fn attach_workflow_proposal_persists_thread_message_and_extends_summary() {// Proposal is durably persisted in the parent thread with rehydratable// metadata (this is what survives reload / a dropped socket event).let messages =- conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf(), "thread-parent").expect("messages");+ conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf(), "thread-parent").expect("messages");let proposal_msg = messages.iter().find(|m| m.id == "workflow-proposal:sub-task-1")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 02c5f2a452..f95d3ccca1 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@@ -105,7 +105,7 @@ fn persist_worker_thread_creates_thread_with_tasks_label_and_messages() {assert!(thread_id.starts_with("worker-"));- let threads = conversations::list_threads(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("list threads");+ let threads = conversations::list_threads(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("list threads");let worker = threads.iter().find(|t| t.id == thread_id)@@ -114,7 +114,7 @@ fn persist_worker_thread_creates_thread_with_tasks_label_and_messages() {assert!(worker.title.starts_with("draft a long research plan"));let messages =- conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf(), &thread_id).expect("messages");+ conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf(), &thread_id).expect("messages");assert_eq!(messages.len(), 2);assert_eq!(messages[0].sender, "user");assert_eq!(messages[0].content, "draft a long research plan");diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread_tests.rsindex adca9fd175..bfe5833de8 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread_tests.rs@@ -45,7 +45,7 @@ async fn rejects_if_already_worker_thread() {let temp = TempDir::new().unwrap();let thread_id = "worker-123";conversations::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),temp.path().to_path_buf(),CreateConversationThread {id: thread_id.to_string(),@@ -72,7 +72,7 @@ async fn rejects_if_has_parent_thread_id() {let temp = TempDir::new().unwrap();let thread_id = "sub-123";conversations::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),temp.path().to_path_buf(),CreateConversationThread {id: thread_id.to_string(),diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rsindex 66286a5a08..ec31ecedaa 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs@@ -466,14 +466,14 @@ async fn spawn_worker_thread_tool_persists_worker_thread_e2e() {assert!(provider.saw(WORKER_THREAD_CANARY));let threads =- conversations::list_threads(crate::core::runtime::DispatchCtx::ambient(), workspace.path().to_path_buf()).expect("worker threads");+ conversations::list_threads(&crate::core::runtime::DispatchCtx::ambient(), workspace.path().to_path_buf()).expect("worker threads");let worker = threads.iter().find(|thread| thread.labels.contains(&"tasks".to_string())).expect("worker thread was persisted");assert_eq!(worker.title, "Long delegated task");- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), workspace.path().to_path_buf(), &worker.id)+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), workspace.path().to_path_buf(), &worker.id).expect("worker messages");assert_eq!(messages.len(), 2);assert_eq!(messages[0].sender, "user");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 96ce771888..f74e49b3a3 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@@ -16,7 +16,7 @@ fn creates_child_thread_linked_to_parent_and_seeds_prompt() {// The new thread is labelled `tasks` and linked to the parent so it// stays grouped with delegated task work in the chat sidebar.- let threads = conversations::list_threads(crate::core::runtime::DispatchCtx::ambient(), dir.clone()).unwrap();+ let threads = conversations::list_threads(&crate::core::runtime::DispatchCtx::ambient(), dir.clone()).unwrap();let thread = threads.iter().find(|t| t.id == id)@@ -26,7 +26,7 @@ fn creates_child_thread_linked_to_parent_and_seeds_prompt() {// It opens with the delegation prompt as the user message, so the// drawer can render the parent↔subagent chat from memory on reopen.- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), dir.clone(), &id).unwrap();+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), dir.clone(), &id).unwrap();assert_eq!(messages.len(), 1);assert_eq!(messages[0].sender, "user");assert_eq!(messages[0].content, "Find Q3");@@ -49,7 +49,7 @@ fn appends_follow_up_prompt_to_existing_worker_thread() {append_worker_user_message(dir.clone(), &id, "researcher", "sub-2", "Follow-up prompt").unwrap();- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), dir.clone(), &id).unwrap();+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), dir.clone(), &id).unwrap();assert_eq!(messages.len(), 2);assert_eq!(messages[1].sender, "user");assert_eq!(messages[1].content, "Follow-up prompt");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 bee646ebc9..7a3eb08439 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@@ -213,7 +213,7 @@ fn mirrored_tool_results_are_hidden_from_the_worker_thread_chat() {let now = chrono::Utc::now().to_rfc3339();for id in ["worker-typed", "worker-recovered"] {store::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),dir.clone(),CreateConversationThread {id: id.to_string(),@@ -274,7 +274,7 @@ fn mirrored_tool_results_are_hidden_from_the_worker_thread_chat() {// failure names every path that is still painting a tool result as chat.let mut painted_as_user_chat: Vec<String> = Vec::new();for thread_id in ["worker-typed", "worker-recovered"] {- let rows = store::get_messages(crate::core::runtime::DispatchCtx::ambient(), dir.clone(), thread_id).unwrap();+ let rows = store::get_messages(&crate::core::runtime::DispatchCtx::ambient(), dir.clone(), thread_id).unwrap();assert!(rows.iter().any(|r| r.content == RAW),"{thread_id}: the mirror wrote no tool-result row to assert on"diff --git a/crates/openhuman-core/src/channels/host/adapters.rs b/crates/openhuman-core/src/channels/host/adapters.rsindex 04d54acfad..b500b70c4c 100644--- a/crates/openhuman-core/src/channels/host/adapters.rs+++ b/crates/openhuman-core/src/channels/host/adapters.rs@@ -208,7 +208,7 @@ impl ConversationStore for ConversationHistoryStore {session_key: &str,limit: usize,) -> anyhow::Result<Vec<ConversationMessage>> {- let messages = crate::threads::store::get_messages(crate::core::runtime::DispatchCtx::ambient(), self.workspace_dir.clone(), session_key)+ let messages = crate::threads::store::get_messages(&crate::core::runtime::DispatchCtx::ambient(), self.workspace_dir.clone(), session_key).map_err(|e| anyhow::anyhow!(e))?;let start = messages.len().saturating_sub(limit);Ok(messages[start..]@@ -225,7 +225,7 @@ impl ConversationStore for ConversationHistoryStore {let now = chrono::Utc::now().to_rfc3339();// `append_message` requires the thread to exist; create-or-noop first.crate::threads::store::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),self.workspace_dir.clone(),crate::threads::store::CreateConversationThread {id: session_key.to_string(),@@ -246,7 +246,7 @@ impl ConversationStore for ConversationHistoryStore {sender: message.role,created_at: now,};- crate::threads::store::append_message(crate::core::runtime::DispatchCtx::ambient(), self.workspace_dir.clone(), session_key, stored)+ crate::threads::store::append_message(&crate::core::runtime::DispatchCtx::ambient(), self.workspace_dir.clone(), session_key, stored).map_err(|e| anyhow::anyhow!(e))?;Ok(())}diff --git a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rsindex 62f7d757ef..ef0b80b780 100644--- a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs@@ -127,7 +127,7 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {let p = params(id, text);let thread = p.thread_id();assert_eq!(- store::record_inbound(crate::core::runtime::DispatchCtx::ambient(), &workspace, &p, &thread).await,+ store::record_inbound(&crate::core::runtime::DispatchCtx::ambient(), &workspace, &p, &thread).await,Ok(Recorded::New));let replies = run_relay_turn(crate::core::runtime::DispatchCtx::ambient(), config.clone(), p, thread, format!("req-{id}")).await;@@ -173,7 +173,7 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {);let thread = params("m1", "x").thread_id();- let messages = crate::threads::store::get_messages(crate::core::runtime::DispatchCtx::ambient(), workspace.clone(), &thread).unwrap();+ let messages = crate::threads::store::get_messages(&crate::core::runtime::DispatchCtx::ambient(), workspace.clone(), &thread).unwrap();let ids: Vec<&str> = messages.iter().map(|m| m.id.as_str()).collect();assert_eq!(ids,@@ -212,7 +212,7 @@ async fn invalid_or_repeated_messages_start_no_turn() {let p = params("m1", "hello");let thread = p.thread_id();- store::record_inbound(crate::core::runtime::DispatchCtx::ambient(), &workspace, &p, &thread)+ store::record_inbound(&crate::core::runtime::DispatchCtx::ambient(), &workspace, &p, &thread).await.unwrap();let outcome = channel_relay_inbound(&crate::core::runtime::DispatchCtx::ambient(), p)diff --git a/crates/openhuman-core/src/channels/providers/relay/store_tests.rs b/crates/openhuman-core/src/channels/providers/relay/store_tests.rsindex 933bd20f3a..9c444d84f2 100644--- a/crates/openhuman-core/src/channels/providers/relay/store_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/store_tests.rs@@ -18,20 +18,20 @@ async fn an_inbound_message_is_recorded_once() {let p = params("m1", "hello");let thread = p.thread_id();assert_eq!(- record_inbound(crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &p, &thread).await,+ record_inbound(&crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &p, &thread).await,Ok(Recorded::New));assert_eq!(- record_inbound(crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &p, &thread).await,+ record_inbound(&crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &p, &thread).await,Ok(Recorded::Duplicate),"a gateway retry is not recorded twice");- let threads = crate::threads::store::list_threads(crate::core::runtime::DispatchCtx::ambient(), tmp.path().to_path_buf()).unwrap();+ let threads = crate::threads::store::list_threads(&crate::core::runtime::DispatchCtx::ambient(), tmp.path().to_path_buf()).unwrap();assert_eq!(threads.len(), 1);assert_eq!(threads[0].id, thread);assert_eq!(threads[0].title, "telegram · 42 · -100");- let messages = crate::threads::store::get_messages(crate::core::runtime::DispatchCtx::ambient(), tmp.path().to_path_buf(), &thread).unwrap();+ let messages = crate::threads::store::get_messages(&crate::core::runtime::DispatchCtx::ambient(), tmp.path().to_path_buf(), &thread).unwrap();assert_eq!(messages.len(), 1);assert_eq!(messages[0].id, "user:m1");assert_eq!(messages[0].sender, "user");@@ -43,17 +43,17 @@ async fn replies_are_recorded_and_seed_the_next_turn() {let tmp = tempfile::tempdir().unwrap();let first = params("m1", "hello");let thread = first.thread_id();- record_inbound(crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &first, &thread).await.unwrap();- record_reply(crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &first, &thread, &[])+ record_inbound(&crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &first, &thread).await.unwrap();+ record_reply(&crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &first, &thread, &[]).await.expect("nothing sent, nothing recorded");- record_reply(crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &first, &thread, &["hi".into(), "there".into()])+ record_reply(&crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &first, &thread, &["hi".into(), "there".into()]).await.unwrap();let second = params("m2", "again");- record_inbound(crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &second, &thread).await.unwrap();+ record_inbound(&crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &second, &thread).await.unwrap();- let prior = prior_turns(crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &thread, "m2", 10).await.unwrap();+ let prior = prior_turns(&crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &thread, "m2", 10).await.unwrap();let rows: Vec<(String, String)> = prior.iter().map(|m| (m.role.clone(), m.content.clone()))@@ -66,7 +66,7 @@ async fn replies_are_recorded_and_seed_the_next_turn() {],"earlier turns only, not the message being answered");- let limited = prior_turns(crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &thread, "m2", 1).await.unwrap();+ let limited = prior_turns(&crate::core::runtime::DispatchCtx::ambient(), tmp.path(), &thread, "m2", 1).await.unwrap();assert_eq!(limited.len(), 1);assert_eq!(limited[0].content, "hi\n\nthere", "the most recent rows");}@@ -81,7 +81,7 @@ async fn concurrent_retries_of_one_message_record_it_once() {let dir = tmp.path().to_path_buf();let (p, thread) = (p.clone(), thread.clone());tasks.push(tokio::spawn(async move {- record_inbound(crate::core::runtime::DispatchCtx::ambient(), &dir, &p, &thread).await+ record_inbound(&crate::core::runtime::DispatchCtx::ambient(), &dir, &p, &thread).await}));}let mut new = 0;@@ -91,6 +91,6 @@ async fn concurrent_retries_of_one_message_record_it_once() {}}assert_eq!(new, 1, "exactly one concurrent retry is the new message");- let messages = crate::threads::store::get_messages(crate::core::runtime::DispatchCtx::ambient(), tmp.path().to_path_buf(), &thread).unwrap();+ let messages = crate::threads::store::get_messages(&crate::core::runtime::DispatchCtx::ambient(), tmp.path().to_path_buf(), &thread).unwrap();assert_eq!(messages.len(), 1);}diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rsindex b27502892c..913709c490 100644--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs@@ -60,7 +60,7 @@ fn web(thread: &str) -> JobOrigin {fn seed_thread(config: &Config, id: &str) {conversations::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),config.workspace_dir.clone(),CreateConversationThread {id: id.into(),@@ -95,7 +95,7 @@ async fn no_reply_is_suppressed_without_writing_anything() {.unwrap();assert_eq!(status, DeliveryStatus::Suppressed);assert!(- conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), cfg.workspace_dir.clone(), "t-1")+ conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), cfg.workspace_dir.clone(), "t-1").unwrap().is_empty());@@ -114,7 +114,7 @@ async fn web_delivery_stores_one_row_under_the_run_reply_id_and_is_idempotent().unwrap();assert_eq!(status, DeliveryStatus::Delivered);}- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), cfg.workspace_dir.clone(), "t-1").unwrap();+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), cfg.workspace_dir.clone(), "t-1").unwrap();assert_eq!(messages.len(), 1, "same run collapses onto one row");assert_eq!(messages[0].id,@@ -127,7 +127,7 @@ async fn web_delivery_stores_one_row_under_the_run_reply_id_and_is_idempotent().await.unwrap();assert_eq!(- conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), cfg.workspace_dir.clone(), "t-1")+ conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), cfg.workspace_dir.clone(), "t-1").unwrap().len(),2diff --git a/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs b/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rsindex 1d0dd29590..350df0f6c0 100644--- a/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs+++ b/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs@@ -29,7 +29,7 @@ async fn append_with_test_config(config: &crate::config::Config,origin: Option<&crate::agent::turn_origin::AgentTurnOrigin>,) -> Result<Outcome<ApiEnvelope<ConversationMessageRecord>>, ThreadsError> {- message_append_with_config(crate::core::runtime::DispatchCtx::ambient(), request, config, origin, &config.workspace_dir).await+ message_append_with_config(&crate::core::runtime::DispatchCtx::ambient(), request, config, origin, &config.workspace_dir).await}fn request(id: &str, content: &str, sender: &str) -> AppendConversationMessageRequest {@@ -229,7 +229,7 @@ async fn append_uses_host_persistence_workspace_separate_from_rpc_config() {.unwrap();message_append_with_config(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),request("host-store", "saved in host workspace", "assistant"),&config,None,diff --git a/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs b/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rsindex 4094ab5827..8802da6ce8 100644--- a/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs+++ b/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs@@ -155,7 +155,7 @@ async fn next_reply_request_id_after_finds_the_correlated_turn() {let thread_id = "thread-reply-lookup";seed_message_log(dir.path(), thread_id).await;- let found = next_reply_request_id_after(crate::core::runtime::DispatchCtx::ambient(), dir.path(), thread_id, "user-1")+ let found = next_reply_request_id_after(&crate::core::runtime::DispatchCtx::ambient(), dir.path(), thread_id, "user-1").await.expect("lookup");assert_eq!(found, Some("turn-1".to_string()));@@ -168,7 +168,7 @@ async fn next_reply_request_id_after_none_when_message_is_the_log_tail() {seed_message_log(dir.path(), thread_id).await;let last_reply_id = run_reply_message_id("turn-2");- let found = next_reply_request_id_after(crate::core::runtime::DispatchCtx::ambient(), dir.path(), thread_id, &last_reply_id)+ let found = next_reply_request_id_after(&crate::core::runtime::DispatchCtx::ambient(), dir.path(), thread_id, &last_reply_id).await.expect("lookup");assert_eq!(@@ -183,7 +183,7 @@ async fn next_reply_request_id_after_none_when_message_id_unknown() {let thread_id = "thread-reply-lookup-unknown";seed_message_log(dir.path(), thread_id).await;- let found = next_reply_request_id_after(crate::core::runtime::DispatchCtx::ambient(), dir.path(), thread_id, "does-not-exist")+ let found = next_reply_request_id_after(&crate::core::runtime::DispatchCtx::ambient(), dir.path(), thread_id, "does-not-exist").await.expect("lookup");assert_eq!(found, None);diff --git a/crates/openhuman-core/src/threads/ops/search_tests.rs b/crates/openhuman-core/src/threads/ops/search_tests.rsindex f83435b2be..1ec0f95ad8 100644--- a/crates/openhuman-core/src/threads/ops/search_tests.rs+++ b/crates/openhuman-core/src/threads/ops/search_tests.rs@@ -47,7 +47,7 @@ fn request_limit_is_optional() {#[tokio::test]async fn blank_query_answers_no_hits() {- let out = thread_search(crate::core::runtime::DispatchCtx::ambient(), ThreadSearchRequest {+ let out = thread_search(&crate::core::runtime::DispatchCtx::ambient(), ThreadSearchRequest {query: " ".into(),limit: None,})diff --git a/crates/openhuman-core/src/threads/ops_conversion_tests.rs b/crates/openhuman-core/src/threads/ops_conversion_tests.rsindex 9b5dd3f124..7c510948eb 100644--- a/crates/openhuman-core/src/threads/ops_conversion_tests.rs+++ b/crates/openhuman-core/src/threads/ops_conversion_tests.rs@@ -219,7 +219,7 @@ async fn generate_title_returns_typed_not_found_for_stale_thread() {let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let thread_id = "thread-missing";- let err = thread_generate_title(crate::core::runtime::DispatchCtx::ambient(), GenerateConversationThreadTitleRequest {+ let err = thread_generate_title(&crate::core::runtime::DispatchCtx::ambient(), GenerateConversationThreadTitleRequest {thread_id: thread_id.to_string(),assistant_message: None,})@@ -247,7 +247,7 @@ async fn generate_title_leaves_custom_title_unchanged() {.expect("load config").workspace_dir;conversations_store::append_message(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),dir,thread_id,ConversationMessage {@@ -261,7 +261,7 @@ async fn generate_title_leaves_custom_title_unchanged() {).unwrap();- let outcome = thread_generate_title(crate::core::runtime::DispatchCtx::ambient(), GenerateConversationThreadTitleRequest {+ let outcome = thread_generate_title(&crate::core::runtime::DispatchCtx::ambient(), GenerateConversationThreadTitleRequest {thread_id: thread_id.to_string(),assistant_message: None,})@@ -283,7 +283,7 @@ async fn generate_title_returns_existing_title_when_no_user_message_exists() {let thread_id = "thread-no-user";create_thread_with_title(&workspace, thread_id, "Chat Jan 1 1:00 AM").await;- let outcome = thread_generate_title(crate::core::runtime::DispatchCtx::ambient(), GenerateConversationThreadTitleRequest {+ let outcome = thread_generate_title(&crate::core::runtime::DispatchCtx::ambient(), GenerateConversationThreadTitleRequest {thread_id: thread_id.to_string(),assistant_message: Some("assistant reply".into()),})@@ -309,7 +309,7 @@ async fn generate_title_falls_back_to_first_user_message_when_assistant_missing(.workspace_dir;let user_message = "Please summarize the latest five email threads for me.";conversations_store::append_message(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),dir,thread_id,ConversationMessage {@@ -323,7 +323,7 @@ async fn generate_title_falls_back_to_first_user_message_when_assistant_missing().unwrap();- let outcome = thread_generate_title(crate::core::runtime::DispatchCtx::ambient(), GenerateConversationThreadTitleRequest {+ let outcome = thread_generate_title(&crate::core::runtime::DispatchCtx::ambient(), GenerateConversationThreadTitleRequest {thread_id: thread_id.to_string(),assistant_message: None,})@@ -437,7 +437,7 @@ async fn threads_purge_removes_every_turn_state_snapshot() {).await;- threads_purge(crate::core::runtime::DispatchCtx::ambient(), EmptyRequest {})+ threads_purge(&crate::core::runtime::DispatchCtx::ambient(), EmptyRequest {}).await.expect("purge threads should also clear snapshots");@@ -474,7 +474,7 @@ async fn thread_update_title_rejects_empty_and_whitespace_only_titles() {let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());for title in ["", " "] {- let err = thread_update_title(crate::core::runtime::DispatchCtx::ambient(), crate::threads::UpdateConversationThreadTitleRequest {+ let err = thread_update_title(&crate::core::runtime::DispatchCtx::ambient(), crate::threads::UpdateConversationThreadTitleRequest {thread_id: "t-1".to_string(),title: title.to_string(),})diff --git a/crates/openhuman-core/src/threads/ops_tests.rs b/crates/openhuman-core/src/threads/ops_tests.rsindex e52d9c6194..b5a70cb205 100644--- a/crates/openhuman-core/src/threads/ops_tests.rs+++ b/crates/openhuman-core/src/threads/ops_tests.rs@@ -48,7 +48,7 @@ async fn create_thread_with_title(_workspace: &tempfile::TempDir, thread_id: &st.expect("load config").workspace_dir;conversations_store::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),dir,CreateConversationThread {id: thread_id.to_string(),diff --git a/crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rs b/crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rsindex c2b175b8fc..0bfc7fc571 100644--- a/crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rs+++ b/crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rs@@ -9,7 +9,7 @@ async fn thread_update_title_persists_new_title() {let thread_id = "t-title";create_thread_with_title(&workspace, thread_id, "Original title").await;- let outcome = thread_update_title(crate::core::runtime::DispatchCtx::ambient(), crate::threads::UpdateConversationThreadTitleRequest {+ let outcome = thread_update_title(&crate::core::runtime::DispatchCtx::ambient(), crate::threads::UpdateConversationThreadTitleRequest {thread_id: thread_id.to_string(),title: " Invoice follow-up ".to_string(),})@@ -30,7 +30,7 @@ async fn thread_update_title_returns_error_for_missing_thread() {let workspace = tempfile::tempdir().expect("workspace");let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());- let err = thread_update_title(crate::core::runtime::DispatchCtx::ambient(), crate::threads::UpdateConversationThreadTitleRequest {+ let err = thread_update_title(&crate::core::runtime::DispatchCtx::ambient(), crate::threads::UpdateConversationThreadTitleRequest {thread_id: "nonexistent-thread".to_string(),title: "New title".to_string(),})diff --git a/crates/openhuman-core/src/threads/store/bus_tests.rs b/crates/openhuman-core/src/threads/store/bus_tests.rsindex fb8708529d..abc84f27ee 100644--- a/crates/openhuman-core/src/threads/store/bus_tests.rs+++ b/crates/openhuman-core/src/threads/store/bus_tests.rs@@ -62,11 +62,11 @@ async fn persists_inbound_and_processed_turns_into_workspace_thread() {}).await;- let threads = crate::threads::store::list_threads(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");+ let threads = crate::threads::store::list_threads(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");assert_eq!(threads.len(), 1);assert_eq!(threads[0].id, "channel:slack_alice_general_thread:thread-1");- let messages = crate::threads::store::get_messages(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf(), &threads[0].id)+ let messages = crate::threads::store::get_messages(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf(), &threads[0].id).expect("messages");assert_eq!(messages.len(), 2);assert_eq!(messages[0].id, "user:m1");@@ -113,7 +113,7 @@ async fn telegram_thread_ts_does_not_split_persisted_thread() {}).await;- let threads = crate::threads::store::list_threads(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");+ let threads = crate::threads::store::list_threads(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");assert_eq!(threads.len(), 1);assert_eq!(threads[0].id, "channel:telegram_alice_chat-1");}@@ -138,7 +138,7 @@ async fn duplicate_events_do_not_append_duplicate_messages() {subscriber.handle(&event).await;let messages = crate::threads::store::get_messages(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),temp.path().to_path_buf(),"channel:discord_alice_room-1",)@@ -196,7 +196,7 @@ async fn received_matching_workspace_is_persisted() {.await;let messages =- crate::threads::store::get_messages(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf(), "channel:slack_bob_dev")+ crate::threads::store::get_messages(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf(), "channel:slack_bob_dev").expect("messages");assert_eq!(messages.len(), 1);assert_eq!(messages[0].id, "user:m1");@@ -224,7 +224,7 @@ async fn received_stale_workspace_is_dropped() {.await;// No thread should have been created in temp (the subscriber's workspace).- let threads = crate::threads::store::list_threads(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");+ let threads = crate::threads::store::list_threads(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");assert!(threads.is_empty(),"stale-workspace event must not create a thread"@@ -270,7 +270,7 @@ async fn processed_matching_workspace_is_appended() {.await;let messages = crate::threads::store::get_messages(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),temp.path().to_path_buf(),"channel:slack_alice_general",)@@ -321,7 +321,7 @@ async fn processed_stale_workspace_is_dropped() {.await;let messages = crate::threads::store::get_messages(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),temp.path().to_path_buf(),"channel:slack_alice_general",)@@ -394,7 +394,7 @@ async fn workspace_switch_mid_conversation() {.await;let messages = crate::threads::store::get_messages(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),workspace_a.path().to_path_buf(),"channel:telegram_alice_chat-1",)@@ -434,7 +434,7 @@ async fn multiple_stale_workspaces_all_dropped() {.await;}- let threads = crate::threads::store::list_threads(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");+ let threads = crate::threads::store::list_threads(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");assert!(threads.is_empty(),"no events from wrong workspaces should create a thread"@@ -478,7 +478,7 @@ async fn correct_workspace_after_stale_events() {.await;let messages = crate::threads::store::get_messages(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),temp.path().to_path_buf(),"channel:slack_alice_general",)@@ -529,7 +529,7 @@ async fn claimed_channel_turns_are_left_to_their_caller() {subscriber.handle(&event).await;}- let threads = crate::threads::store::list_threads(crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");+ let threads = crate::threads::store::list_threads(&crate::core::runtime::DispatchCtx::ambient(), temp.path().to_path_buf()).expect("threads");assert!(threads.is_empty(),"a claimed turn is not mirrored: {threads:?}"diff --git a/crates/openhuman-core/src/threads/welcome_migration_tests.rs b/crates/openhuman-core/src/threads/welcome_migration_tests.rsindex c64f411bef..bc6a5ecf00 100644--- a/crates/openhuman-core/src/threads/welcome_migration_tests.rs+++ b/crates/openhuman-core/src/threads/welcome_migration_tests.rs@@ -28,7 +28,7 @@ fn migration_updates_thread_labels_and_transcripts() {let workspace = tmp.path();ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),workspace.to_path_buf(),make_thread("welcome-thread",@@ -50,7 +50,7 @@ fn migration_updates_thread_labels_and_transcripts() {assert_eq!(result.transcript_files_renamed, 1);assert_eq!(result.markdown_files_renamed, 1);- let threads = list_threads(crate::core::runtime::DispatchCtx::ambient(), workspace.to_path_buf()).unwrap();+ let threads = list_threads(&crate::core::runtime::DispatchCtx::ambient(), workspace.to_path_buf()).unwrap();let thread = threads.iter().find(|thread| thread.id == "welcome-thread")diff --git a/crates/openhuman-core/src/web_chat/presentation_tests.rs b/crates/openhuman-core/src/web_chat/presentation_tests.rsindex 90ad14bd2a..20fac41995 100644--- a/crates/openhuman-core/src/web_chat/presentation_tests.rs+++ b/crates/openhuman-core/src/web_chat/presentation_tests.rs@@ -134,7 +134,7 @@ async fn delivery_stores_the_reply_before_announcing_it() {let ws = std::env::temp_dir().join(format!("deliver-persist-{}", uuid::Uuid::new_v4()));std::fs::create_dir_all(&ws).unwrap();conversations::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),ws.clone(),CreateConversationThread {id: "t-deliver".to_string(),@@ -171,7 +171,7 @@ async fn delivery_stores_the_reply_before_announcing_it() {// a row present here proves the write happened no later than the announce.// A client that never receives that event, or fails to append it, no longer// decides whether the reply exists.- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-deliver").expect("messages");+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-deliver").expect("messages");assert_eq!(messages.len(), 1, "delivery must leave exactly one row");assert_eq!(messages[0].id, "agent:req-deliver");assert_eq!(messages[0].content, "Here is the summary you asked for.");@@ -207,7 +207,7 @@ async fn delivery_still_announces_when_the_reply_cannot_be_stored() {// `get_messages` answers `Ok(vec![])` for a thread it has never seen — only// `append_message` refuses one — so absence is what proves the write was// rejected and swallowed rather than silently creating a thread.- let messages = crate::threads::store::get_messages(crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "absent-thread")+ let messages = crate::threads::store::get_messages(&crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "absent-thread").expect("reading an unknown thread is not an error");assert!(messages.is_empty(),diff --git a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rsindex a259efae9f..2caf0fed6e 100644--- a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs+++ b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs@@ -12,7 +12,7 @@ fn temp_ws() -> PathBuf {fn seed_thread(ws: &Path, thread_id: &str) {conversations::ensure_thread(- crate::core::runtime::DispatchCtx::ambient(),+ &crate::core::runtime::DispatchCtx::ambient(),ws.to_path_buf(),CreateConversationThread {id: thread_id.to_string(),@@ -32,11 +32,11 @@ fn persists_the_reply_under_the_id_the_client_will_reuse() {let ws = temp_ws();seed_thread(&ws, "t-1");- let stored = persist_delivered_reply(crate::core::runtime::DispatchCtx::ambient(), &ws, "t-1", "req-1", "Done, the draft is updated.", &[])+ let stored = persist_delivered_reply(&crate::core::runtime::DispatchCtx::ambient(), &ws, "t-1", "req-1", "Done, the draft is updated.", &[]).expect("append succeeds");assert!(stored, "a non-empty reply must report that it was stored");- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-1").expect("messages");+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-1").expect("messages");assert_eq!(messages.len(), 1);// The id is what makes the client's own append collapse onto this row// instead of adding a duplicate bubble (#5933 / #6034).@@ -52,14 +52,14 @@ fn a_second_write_of_the_same_turn_does_not_add_a_row() {let ws = temp_ws();seed_thread(&ws, "t-2");- persist_delivered_reply(crate::core::runtime::DispatchCtx::ambient(), &ws, "t-2", "req-2", "First", &[]).expect("first append");+ persist_delivered_reply(&crate::core::runtime::DispatchCtx::ambient(), &ws, "t-2", "req-2", "First", &[]).expect("first append");// The client persists the same reply from the `chat_done` it received. The// store's idempotency for deterministic ids is what keeps the thread at one// row; assert the second write here so a change to the id shape (which// would silently opt out of that lookup) fails loudly.- persist_delivered_reply(crate::core::runtime::DispatchCtx::ambient(), &ws, "t-2", "req-2", "First", &[]).expect("second append");+ persist_delivered_reply(&crate::core::runtime::DispatchCtx::ambient(), &ws, "t-2", "req-2", "First", &[]).expect("second append");- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-2").expect("messages");+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-2").expect("messages");assert_eq!(messages.len(), 1, "one turn must never leave two rows");}@@ -68,9 +68,9 @@ fn an_empty_reply_is_not_stored() {let ws = temp_ws();seed_thread(&ws, "t-3");- let stored = persist_delivered_reply(crate::core::runtime::DispatchCtx::ambient(), &ws, "t-3", "req-3", " \n ", &[]).expect("no error");+ let stored = persist_delivered_reply(&crate::core::runtime::DispatchCtx::ambient(), &ws, "t-3", "req-3", " \n ", &[]).expect("no error");assert!(!stored, "an empty reply reports that nothing was stored");- assert!(conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-3")+ assert!(conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-3").expect("messages").is_empty());}@@ -80,9 +80,9 @@ fn content_is_trimmed_the_way_the_autonomous_path_trims_it() {let ws = temp_ws();seed_thread(&ws, "t-4");- persist_delivered_reply(crate::core::runtime::DispatchCtx::ambient(), &ws, "t-4", "req-4", " padded reply\n", &[]).expect("append");+ persist_delivered_reply(&crate::core::runtime::DispatchCtx::ambient(), &ws, "t-4", "req-4", " padded reply\n", &[]).expect("append");- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-4").expect("messages");+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-4").expect("messages");assert_eq!(messages[0].content, "padded reply");}@@ -90,7 +90,7 @@ fn content_is_trimmed_the_way_the_autonomous_path_trims_it() {fn a_missing_thread_is_reported_rather_than_silently_dropped() {let ws = temp_ws();- let err = persist_delivered_reply(crate::core::runtime::DispatchCtx::ambient(), &ws, "nope", "req-5", "text", &[])+ let err = persist_delivered_reply(&crate::core::runtime::DispatchCtx::ambient(), &ws, "nope", "req-5", "text", &[]).expect_err("a missing thread must not look like a successful store");assert!(err.contains("nope"), "error names the thread: {err}");}@@ -108,13 +108,13 @@ fn citations_ride_on_the_authoritative_row() {timestamp: "2026-09-04T00:00:00Z".to_string(),snippet: "The draft lives in Notion.".to_string(),};- persist_delivered_reply(crate::core::runtime::DispatchCtx::ambient(), &ws, "t-6", "req-6", "Updated the draft.", &[citation])+ persist_delivered_reply(&crate::core::runtime::DispatchCtx::ambient(), &ws, "t-6", "req-6", "Updated the draft.", &[citation]).expect("append");// The client's append is deduped onto this row, so whatever is missing here// is missing from the rendered message — citation chips included. Losing// them was a real regression caught in review of #6034.- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-6").expect("messages");+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-6").expect("messages");let cites = messages[0].extra_metadata["citations"].as_array().expect("citations are stored as an array");@@ -127,9 +127,9 @@ fn a_reply_without_citations_stores_no_citations_key() {let ws = temp_ws();seed_thread(&ws, "t-7");- persist_delivered_reply(crate::core::runtime::DispatchCtx::ambient(), &ws, "t-7", "req-7", "No sources for this one.", &[]).expect("append");+ persist_delivered_reply(&crate::core::runtime::DispatchCtx::ambient(), &ws, "t-7", "req-7", "No sources for this one.", &[]).expect("append");- let messages = conversations::get_messages(crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-7").expect("messages");+ let messages = conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(), ws.clone(), "t-7").expect("messages");assert!(messages[0].extra_metadata.get("citations").is_none(),"an empty citation list must not add an empty array the client never wrote"