Skip to content

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

refactor(core): route dispatch through invoke layer

Steven Enamakelcd610cac7237
diff --git a/crates/openhuman-core/src/core/dispatch.rs b/crates/openhuman-core/src/core/dispatch.rs
index b0ae3e5d9c..5ec70c15fc 100644
--- a/crates/openhuman-core/src/core/dispatch.rs
+++ b/crates/openhuman-core/src/core/dispatch.rs
@@ -79,7 +79,7 @@ pub async fn dispatch(
}
// Tier 2: Registered domain controllers.
- if let Some(result) = try_registry_dispatch(method, params).await {
+ if let Some(result) = try_registry_dispatch(ctx, method, params).await {
log::debug!(
"[rpc:dispatch] routed method={} subsystem=controller_registry",
method
@@ -232,6 +232,7 @@ fn handle_events_subscribe_token(params: serde_json::Value) -> Result<Invocation
}
async fn try_registry_dispatch(
+ ctx: crate::core::runtime::DispatchCtx,
method: &str,
params: Value,
) -> Option<Result<serde_json::Value, String>> {
diff --git a/crates/openhuman-core/src/core/invoke.rs b/crates/openhuman-core/src/core/invoke.rs
index 318ac8718f..9e032dfffd 100644
--- a/crates/openhuman-core/src/core/invoke.rs
+++ b/crates/openhuman-core/src/core/invoke.rs
@@ -126,7 +126,7 @@ async fn invoke_method_inner(
}
// Phase 2: Fall back to dynamic dispatch (internal core methods or legacy paths).
- crate::core::dispatch::dispatch(state, method, params).await
+ crate::core::dispatch::dispatch(ctx, state, method, params).await
}
/// Returns the default application state.
diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rs
index e5fc37521f..d22a6dada1 100644
--- a/crates/openhuman-core/src/core/runtime/builder.rs
+++ b/crates/openhuman-core/src/core/runtime/builder.rs
@@ -441,6 +441,7 @@ impl CoreRuntime {
CoreContext::scope(
ctx,
crate::core::invoke::invoke_method(
+ crate::core::runtime::DispatchCtx::new(ctx),
crate::core::invoke::default_state(),
method,
params,