Skip to content

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

fix(modules): handle missing module config gracefully

Steven Enamakel2bc57ffa5d35
diff --git a/crates/openhuman-core/src/mcp/module_client.rs b/crates/openhuman-core/src/mcp/module_client.rs
index 853c43da4f..bdef0e0063 100644
--- a/crates/openhuman-core/src/mcp/module_client.rs
+++ b/crates/openhuman-core/src/mcp/module_client.rs
@@ -464,7 +464,7 @@ impl McpConfiguredClient {
// Servers and audit rows from before the storage contract
// move into the module's storage before it reads them.
// Best effort: a failure is retried at the next open.
- crate::modules::import_legacy_mcp(std::path::Path::new(&self.data_dir)).await;
+ crate::modules::import_legacy_mcp(&crate::core::runtime::DispatchCtx::ambient(), std::path::Path::new(&self.data_dir)).await;
let reply = self.port.open_configured(&self.data_dir, &config).await;
state.open_replied(reply.clone().map_err(|_| ()));
reply?;
diff --git a/crates/openhuman-core/src/modules/connectors.rs b/crates/openhuman-core/src/modules/connectors.rs
index 0f9e830747..2fc2dd8854 100644
--- a/crates/openhuman-core/src/modules/connectors.rs
+++ b/crates/openhuman-core/src/modules/connectors.rs
@@ -283,7 +283,7 @@ async fn ensure_routed(config: &Config, proxy: &Proxy) -> Result<(), String> {
// Preferences and trigger history from before the storage contract move
// into the module's storage before it first serves a call. Once per state
// directory, best effort: a failure is retried on the next call.
- super::import_legacy_connectors(&config.workspace_dir.join("state")).await;
+ super::import_legacy_connectors(&crate::core::runtime::DispatchCtx::ambient(), &config.workspace_dir.join("state")).await;
let current = fingerprint(&route);
if *last_route()
diff --git a/crates/openhuman-core/src/modules/import_once_tests.rs b/crates/openhuman-core/src/modules/import_once_tests.rs
index 70e548cee3..86909ef9a1 100644
--- a/crates/openhuman-core/src/modules/import_once_tests.rs
+++ b/crates/openhuman-core/src/modules/import_once_tests.rs
@@ -14,7 +14,7 @@ async fn a_concurrent_caller_waits_for_the_running_import() {
let dir = std::path::PathBuf::from("/import-once/concurrent");
let finished = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false));
let flag = finished.clone();
- let first = import_once("test-concurrent", MODULE_FOR_TEST, &dir, async move {
+ let first = import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-concurrent", MODULE_FOR_TEST, &dir, async move {
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
flag.store(true, std::sync::atomic::Ordering::SeqCst);
Ok(Done(true))
@@ -22,7 +22,7 @@ async fn a_concurrent_caller_waits_for_the_running_import() {
let flag = finished.clone();
let second = async {
tokio::time::sleep(std::time::Duration::from_millis(20)).await;
- import_once("test-concurrent", MODULE_FOR_TEST, &dir, async {
+ import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-concurrent", MODULE_FOR_TEST, &dir, async {
panic!("a settled import must not run a second time");
#[allow(unreachable_code)]
Ok(Done(true))
@@ -42,26 +42,26 @@ async fn an_unsettled_outcome_and_a_cancelled_import_are_retried() {
let dir = std::path::PathBuf::from("/import-once/retry");
let runs = std::sync::atomic::AtomicUsize::new(0);
let count = || runs.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
- import_once("test-retry", MODULE_FOR_TEST, &dir, async {
+ import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-retry", MODULE_FOR_TEST, &dir, async {
count();
Ok(Done(false))
})
.await;
let cancelled = tokio::time::timeout(
std::time::Duration::from_millis(500),
- import_once("test-retry", MODULE_FOR_TEST, &dir, async {
+ import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-retry", MODULE_FOR_TEST, &dir, async {
count();
std::future::pending::<anyhow::Result<Done>>().await
}),
)
.await;
assert!(cancelled.is_err());
- import_once("test-retry", MODULE_FOR_TEST, &dir, async {
+ import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-retry", MODULE_FOR_TEST, &dir, async {
count();
Ok(Done(true))
})
.await;
- import_once("test-retry", MODULE_FOR_TEST, &dir, async {
+ import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-retry", MODULE_FOR_TEST, &dir, async {
count();
Ok(Done(true))
})
diff --git a/crates/openhuman-core/src/modules/tinybox.rs b/crates/openhuman-core/src/modules/tinybox.rs
index c4322d528d..30fdead365 100644
--- a/crates/openhuman-core/src/modules/tinybox.rs
+++ b/crates/openhuman-core/src/modules/tinybox.rs
@@ -435,7 +435,7 @@ where
{
// A registry index from before the storage contract moves into the
// module's storage before its first call. Once per workspace, best effort.
- super::import_legacy_tinybox(&config.workspace_dir).await;
+ super::import_legacy_tinybox(&crate::core::runtime::DispatchCtx::ambient(), &config.workspace_dir).await;
call_with_client(&module_client(config), member, request, confidential).await
}
diff --git a/crates/openhuman-core/src/modules/x402_service.rs b/crates/openhuman-core/src/modules/x402_service.rs
index 67e0881fda..9e35a342bd 100644
--- a/crates/openhuman-core/src/modules/x402_service.rs
+++ b/crates/openhuman-core/src/modules/x402_service.rs
@@ -144,7 +144,7 @@ async fn ensure_service(
if active.is_none() {
// The module's ledger opens on its storage: bring the payments file of
// an earlier install across first (once per workspace, best effort).
- if !super::import_legacy_x402(&workspace).await {
+ if !super::import_legacy_x402(ctx, &workspace).await {
// Opening the ledger without the earlier payments would restore the
// spending allowance; stay inactive and retry on the next call.
return Err(WalletCallError::Unavailable(