Skip to content

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

chore: remove unused imports across core modules

Steven Enamakel9fbdc931a0ee
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
index 3dca4b95f4..5d81cff90c 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
@@ -263,7 +263,7 @@ async fn deliver_to_web_thread(
let persist_request = request_id.clone();
let persist_text = text.to_string();
let persist_ctx = ctx.clone();
- crate::core::runtime::spawn_blocking_scoped(move || {
+ persist_ctx.spawn_blocking(move || {
crate::web_chat::persist_delivered_reply(
&persist_ctx,
&workspace,
diff --git a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs
index 0d3a910ef5..daf3b0ba54 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs
@@ -287,7 +287,7 @@ impl ModuleReplTool {
);
return Ok(ToolResult::error(not_a_handle_message()));
};
- let read = crate::core::runtime::spawn_blocking_scoped(move || {
+ let read = tokio::task::spawn_blocking(move || {
read_tool_result_artifact(&dir, &path, MAX_ARTIFACT_BYTES)
})
.await
diff --git a/crates/openhuman-core/src/integrations/composio/file_store.rs b/crates/openhuman-core/src/integrations/composio/file_store.rs
index 7fbe4cc54c..a635f058c1 100644
--- a/crates/openhuman-core/src/integrations/composio/file_store.rs
+++ b/crates/openhuman-core/src/integrations/composio/file_store.rs
@@ -31,7 +31,7 @@ async fn import_legacy(
) -> Result<(), String> {
let marker_docs = docs.clone();
let done =
- crate::core::runtime::spawn_blocking_scoped(move || marker_docs.legacy_imported(name))
+ tokio::task::spawn_blocking(move || marker_docs.legacy_imported(name))
.await
.map_err(|error| format!("[composio:store] checking legacy {name} failed: {error}"))?
.map_err(|error| {
@@ -54,7 +54,7 @@ async fn import_legacy(
.map_err(|error| format!("[composio:store] parsing legacy {name} failed: {error}"))?;
let docs = docs.clone();
let wrote =
- crate::core::runtime::spawn_blocking_scoped(move || docs.import_if_absent(name, value))
+ tokio::task::spawn_blocking(move || docs.import_if_absent(name, value))
.await
.map_err(|error| format!("[composio:store] importing legacy {name} failed: {error}"))?
.map_err(|error| {
@@ -78,7 +78,7 @@ where
import_legacy(config, &docs, name).await?;
// The document port is reached through a blocking bridge; keep it off the
// async worker, under the caller's context.
- crate::core::runtime::spawn_blocking_scoped(move || docs.load(name))
+ tokio::task::spawn_blocking(move || docs.load(name))
.await
.map_err(|error| format!("[composio:store] reading {name} failed: {error}"))?
.map_err(|error| format!("[composio:store] reading {name} failed: {error:#}"))
@@ -103,7 +103,7 @@ where
let docs = super::file_store_documents::current(&config.workspace_dir)
.map_err(|e| format!("[composio:store] {e:#}"))?;
import_legacy(config, &docs, name).await?;
- crate::core::runtime::spawn_blocking_scoped(move || docs.update(name, change))
+ tokio::task::spawn_blocking(move || docs.update(name, change))
.await
.map_err(|error| format!("[composio:store] updating {name} failed: {error}"))?
.map_err(|error| format!("[composio:store] updating {name} failed: {error:#}"))
@@ -123,7 +123,7 @@ where
.map_err(|e| format!("[composio:store] {e:#}"))?;
let value = serde_json::to_value(value)
.map_err(|error| format!("[composio:store] serializing failed: {error}"))?;
- crate::core::runtime::spawn_blocking_scoped(move || docs.save(name, &value))
+ tokio::task::spawn_blocking(move || docs.save(name, &value))
.await
.map_err(|error| format!("[composio:store] writing {name} failed: {error}"))?
.map_err(|error| format!("[composio:store] writing {name} failed: {error:#}"))
diff --git a/crates/openhuman-core/src/mcp/ui/tools.rs b/crates/openhuman-core/src/mcp/ui/tools.rs
index 48a3fcce63..e1f8d9a148 100644
--- a/crates/openhuman-core/src/mcp/ui/tools.rs
+++ b/crates/openhuman-core/src/mcp/ui/tools.rs
@@ -110,7 +110,7 @@ pub fn confine_path_in(roots: &[PathBuf], path: &str) -> Result<(PathBuf, PathBu
///
/// When the open is refused, the file is not regular, or it is too large.
pub async fn read_confined(root: PathBuf, resolved: PathBuf) -> Result<String, String> {
- crate::core::runtime::spawn_blocking_scoped(move || {
+ tokio::task::spawn_blocking(move || {
use std::io::Read;
let file = crate::agent::attachments::provider::open::secure_open(&resolved, &root)
.map_err(|error| {
diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rs
index a1136ff1b8..10c660133a 100644
--- a/crates/openhuman-core/src/memory/import.rs
+++ b/crates/openhuman-core/src/memory/import.rs
@@ -325,7 +325,7 @@ async fn launch(
let driver = importer(config, bound.engine, consent, paused);
let begin = {
let driver = driver.clone();
- crate::core::runtime::spawn_blocking_scoped(move || match mode {
+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || match mode {
Mode::Import => driver.begin(),
Mode::Retry => driver.begin_retry(),
Mode::ResumeRetry => Ok(driver.begin_retry_resume()),
diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
index e188b76d9c..3039938f7b 100644
--- a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
@@ -11,7 +11,7 @@ use futures::future::BoxFuture;
use tinymemory_tools::prefetch::{Limits, PrefetchRuntime, Prefetcher, WorkerPool};
use crate::config::Config;
-use crate::core::runtime::{slot_for, spawn_scoped, DispatchCtx};
+use crate::core::runtime::{slot_for, DispatchCtx};
use crate::memory::scope::ResolvedIdentity;
use super::hooks::{self, PreTurnInput, TurnPack};
@@ -28,7 +28,7 @@ struct HostRuntime;
impl PrefetchRuntime for HostRuntime {
fn spawn(&self, task: BoxFuture<'static, ()>) {
- drop(spawn_scoped(task));
+ drop(DispatchCtx::ambient().spawn(task));
}
fn sleep(&self, duration: Duration) -> BoxFuture<'static, ()> {
@@ -166,12 +166,12 @@ pub(crate) fn pre_turn(
key,
guard_turn_work(
&config.clone(),
- Box::pin(crate::core::runtime::spawn::scoped(async move {
+ Box::pin(dispatch.enter(async move {
if config.memory.conversations.enabled {
if let Some(channel) = channel {
let workspace = config.workspace_dir.clone();
let thread = input.thread_id.clone();
- let _ = crate::core::runtime::spawn_blocking_scoped(move || {
+ let _ = tokio::task::spawn_blocking(move || {
crate::memory::channels::record(&workspace, &channel, &thread)
})
.await;
@@ -215,7 +215,7 @@ pub(crate) fn compaction(
enqueue(
cache,
key,
- Box::pin(crate::core::runtime::spawn::scoped(async move {
+ Box::pin(dispatch.enter(async move {
hooks::compaction_work(&config, &identity, &thread, dropped).await
})),
);
diff --git a/crates/openhuman-core/src/memory/tools.rs b/crates/openhuman-core/src/memory/tools.rs
index 93ce425440..82b532d549 100644
--- a/crates/openhuman-core/src/memory/tools.rs
+++ b/crates/openhuman-core/src/memory/tools.rs
@@ -391,7 +391,7 @@ impl Tool for MemoryTool {
let config = self.config.clone();
let write_args = args.clone();
let queued_root = facts.reach.at.clone();
- let queued = crate::core::runtime::spawn_blocking_scoped(move || {
+ let queued = crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {
super::tool_writes::enqueue(&config, &write_args, &facts)
})
.await;
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
index 6604eb0c3e..5e44c61a55 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
@@ -92,7 +92,7 @@ async fn import_into(scoped: &ScopedStorage, state_dir: &Path) -> Result<Outcome
}
let legacy =
- crate::core::runtime::spawn_blocking_scoped(move || read_legacy(&prefs_dir, &triggers_dir))
+ tokio::task::spawn_blocking(move || read_legacy(&prefs_dir, &triggers_dir))
.await
.context("the legacy reader panicked")??;
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
index f41eec91d9..d69e5a9652 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
@@ -93,7 +93,7 @@ async fn import_into(
let dir = root.to_owned();
let (originals, mut skipped) =
- crate::core::runtime::spawn_blocking_scoped(move || read_originals(&dir, now))
+ tokio::task::spawn_blocking(move || read_originals(&dir, now))
.await
.context("the legacy reader panicked")??;
diff --git a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs b/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
index db517d7bdf..be5dd84741 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
@@ -110,7 +110,7 @@ async fn import_into(
// The files are read on a blocking thread, from copies.
let (legacy_servers, legacy_audit) =
- crate::core::runtime::spawn_blocking_scoped(move || -> Result<_> {
+ tokio::task::spawn_blocking(move || -> Result<_> {
let servers = if clients.exists() {
read_servers(&clients)?
} else {
diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
index 6cbde7552a..a615833920 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
@@ -66,7 +66,7 @@ async fn import_into(scoped: &ScopedStorage, workspace_dir: &Path) -> Result<Out
if !ledger.is_file() {
return Ok(Outcome::NoSource);
}
- let (records, skipped) = crate::core::runtime::spawn_blocking_scoped(move || -> Result<_> {
+ let (records, skipped) = tokio::task::spawn_blocking(move || -> Result<_> {
let text = std::fs::read_to_string(&ledger)
.with_context(|| format!("read {}", ledger.display()))?;
Ok(support::parse_jsonl(&text))
diff --git a/crates/openhuman-core/src/storage/import/mod.rs b/crates/openhuman-core/src/storage/import/mod.rs
index 0b96c862ef..233f895c4a 100644
--- a/crates/openhuman-core/src/storage/import/mod.rs
+++ b/crates/openhuman-core/src/storage/import/mod.rs
@@ -191,7 +191,7 @@ pub async fn run(config: &Config) -> Vec<Report> {
}
let config = config.clone();
let joined =
- crate::core::runtime::spawn_blocking_scoped(move || run_all(&backend, &config)).await;
+ tokio::task::spawn_blocking(move || run_all(&backend, &config)).await;
match joined {
Ok(reports) => reports,
Err(error) => {
diff --git a/crates/openhuman-core/src/threads/ops/edit.rs b/crates/openhuman-core/src/threads/ops/edit.rs
index ba1386f75c..d4e2616398 100644
--- a/crates/openhuman-core/src/threads/ops/edit.rs
+++ b/crates/openhuman-core/src/threads/ops/edit.rs
@@ -109,7 +109,7 @@ pub async fn edit_message(
let store_owned = store.clone();
let thread_id_owned = thread_id.clone();
let cut_request_id_owned = cut_request_id.clone();
- crate::core::runtime::spawn_blocking_scoped(move || {
+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {
truncate_transcript_before_turn(&store_owned, &thread_id_owned, &cut_request_id_owned)
})
.await
@@ -181,7 +181,7 @@ pub async fn regenerate(
let store_for_blocking = store.clone();
let thread_id_for_blocking = thread_id.clone();
let target_for_blocking = target_request_id.clone();
- let (prompt, cut_request_id) = crate::core::runtime::spawn_blocking_scoped(move || {
+ let (prompt, cut_request_id) = crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {
truncate_transcript_for_regenerate(
&store_for_blocking,
&thread_id_for_blocking,
diff --git a/crates/openhuman-core/src/threads/store/blocking.rs b/crates/openhuman-core/src/threads/store/blocking.rs
index b9ddf290b7..f497204dc9 100644
--- a/crates/openhuman-core/src/threads/store/blocking.rs
+++ b/crates/openhuman-core/src/threads/store/blocking.rs
@@ -70,7 +70,7 @@ where
F: FnOnce() -> Result<T, String> + Send + 'static,
T: Send + 'static,
{
- match crate::core::runtime::spawn_blocking_scoped(f).await {
+ match crate::core::runtime::DispatchCtx::ambient().spawn_blocking(f).await {
Ok(result) => result,
Err(error) => {
tracing::warn!(
diff --git a/crates/openhuman-core/src/tinymemes/callbacks.rs b/crates/openhuman-core/src/tinymemes/callbacks.rs
index 2296c80829..0e69b16d4f 100644
--- a/crates/openhuman-core/src/tinymemes/callbacks.rs
+++ b/crates/openhuman-core/src/tinymemes/callbacks.rs
@@ -257,7 +257,7 @@ async fn search(
async fn load_index(session: &Session, request: LoadIndexRequest) -> HostResult<Option<String>> {
let config = session.config.clone();
let kind: IndexKind = request.kind;
- match crate::core::runtime::spawn_blocking_scoped(move || docs::load(&config, kind)).await {
+ match tokio::task::spawn_blocking(move || docs::load(&config, kind)).await {
Ok(Ok(document)) => Ok(document),
Ok(Err(error)) => {
log::warn!("[tinymemes] cannot read index: {error}");
@@ -272,7 +272,7 @@ async fn load_index(session: &Session, request: LoadIndexRequest) -> HostResult<
async fn save_index(session: &Session, request: SaveIndexRequest) -> HostResult<()> {
let config = session.config.clone();
- match crate::core::runtime::spawn_blocking_scoped(move || {
+ match tokio::task::spawn_blocking(move || {
docs::save(&config, request.kind, request.json)
})
.await
diff --git a/crates/openhuman-core/src/tinymemes/mod.rs b/crates/openhuman-core/src/tinymemes/mod.rs
index 46640d2238..2462771472 100644
--- a/crates/openhuman-core/src/tinymemes/mod.rs
+++ b/crates/openhuman-core/src/tinymemes/mod.rs
@@ -196,7 +196,7 @@ async fn load(
let config = config.clone();
let thread_id = thread_id.to_owned();
let ctx = ctx.clone();
- crate::core::runtime::spawn_blocking_scoped(move || {
+ ctx.spawn_blocking(move || {
crate::threads::store::get_messages(
&ctx,
config.workspace_dir.clone(),
diff --git a/crates/openhuman-core/src/web_chat/turn_close.rs b/crates/openhuman-core/src/web_chat/turn_close.rs
index e17a190391..dfc5f3c489 100644
--- a/crates/openhuman-core/src/web_chat/turn_close.rs
+++ b/crates/openhuman-core/src/web_chat/turn_close.rs
@@ -289,7 +289,7 @@ async fn read_snapshot(
request_id: &str,
) -> Option<TurnState> {
let (thread_id, request_id) = (thread_id.to_string(), request_id.to_string());
- let read = crate::core::runtime::spawn_blocking_scoped(move || {
+ let read = crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {
crate::agent::session_store::turn_states_for(&workspace).get_turn(&thread_id, &request_id)
})
.await;