Skip to content

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

fix(core): preserve dispatch metadata when resolving core context

Steven Enamakele0615078995b
diff --git a/crates/openhuman-core/src/core/all_invoke.rs b/crates/openhuman-core/src/core/all_invoke.rs
index e4ac7f3f12..78c234b9b4 100644
--- a/crates/openhuman-core/src/core/all_invoke.rs
+++ b/crates/openhuman-core/src/core/all_invoke.rs
@@ -29,10 +29,10 @@ pub async fn try_invoke_registered_rpc(
method: &str,
params: Map<String, Value>,
) -> Option<Result<Value, String>> {
- let core = ctx.into_core().or_else(CoreContext::current);
+ let core = ctx.core().cloned().or_else(CoreContext::current);
let ctx = match &core {
- Some(core) => DispatchCtx::new(core.clone()),
- None => DispatchCtx::unbound(),
+ Some(core) => ctx.with_resolved_core(core.clone()),
+ None => ctx,
};
// Boxed so the concrete `TaskLocalFuture` type does not escape into this
// fn's future: without the type erasure the `Send` auto-trait solver
diff --git a/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs b/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs
index 1fe689cc4c..1ffb7bc8c5 100644
--- a/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs
+++ b/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs
@@ -37,6 +37,14 @@ impl DispatchCtx {
}
}
+ /// Binds the resolved core while preserving call-local dispatch metadata.
+ /// Used when a registered handler's context is scoped for execution after
+ /// the transport has already attached flags to the call.
+ pub(crate) fn with_resolved_core(mut self, core: Arc<CoreContext>) -> Self {
+ self.core = Some(core);
+ self
+ }
+
/// Dispatch with no context. Only for tests and pre-boot callers; every
/// reader of the context treats this as "nothing configured here".
pub fn unbound() -> Self {