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
fix(modules): preserve call timeout on pinned and derived object clients
Steven Enamakel53ee360857a4
diff --git a/crates/openhuman-core/src/mcp/module_client_owner_tests.rs b/crates/openhuman-core/src/mcp/module_client_owner_tests.rsindex 4af9880fe6..3d0cd37b6b 100644--- a/crates/openhuman-core/src/mcp/module_client_owner_tests.rs+++ b/crates/openhuman-core/src/mcp/module_client_owner_tests.rs@@ -54,10 +54,10 @@ async fn cancelled_close_retries_its_receipt_on_the_original_owner() {}original.request_name(names::INTERFACE).await.unwrap();let port = TinyMcpPort::new(ModuleClient::fixture(- caller- .proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)- .unwrap(),- ));+ caller+ .proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)+ .unwrap(),+ ));assert_eq!(port.transition_status("original-open").await,Ok(TransitionStatus::Complete)diff --git a/crates/openhuman-core/src/mcp/module_port.rs b/crates/openhuman-core/src/mcp/module_port.rsindex c48fcd0ecf..76480c0475 100644--- a/crates/openhuman-core/src/mcp/module_port.rs+++ b/crates/openhuman-core/src/mcp/module_port.rs@@ -11,27 +11,48 @@ pub(super) struct TinyMcpPort {impl TinyMcpPort {pub(super) fn new(root: ModuleClient) -> Self {- Self { root, #[cfg(feature = "modules")] pinned: tokio::sync::OnceCell::new() }+ Self {+ root,+ #[cfg(feature = "modules")]+ pinned: tokio::sync::OnceCell::new(),+ }}#[cfg(feature = "modules")]async fn pinned(&self) -> Result<&ModuleObjectClient, ModuleCallError> {- self.pinned.get_or_try_init(|| async {- self.root.object_client(MODULE, names::OBJECT_PATH).await?.pin_owner().await- }).await+ self.pinned+ .get_or_try_init(|| async {+ self.root+ .object_client(MODULE, names::OBJECT_PATH)+ .await?+ .pin_owner()+ .await+ })+ .await}- async fn root_call<R: DeserializeOwned>(&self, member: &str, args: impl Serialize, confidential: bool) -> Result<R, ModuleCallError> {+ async fn root_call<R: DeserializeOwned>(+ &self,+ member: &str,+ args: impl Serialize,+ confidential: bool,+ ) -> Result<R, ModuleCallError> {#[cfg(feature = "modules")]{let root = self.pinned().await?;- if confidential { root.call_confidential(member, args).await }- else { root.call(member, args).await }+ if confidential {+ root.call_confidential(member, args).await+ } else {+ root.call(member, args).await+ }}#[cfg(not(feature = "modules"))]{- if confidential { self.root.call_confidential(MODULE, member, args).await }- else { self.root.call(MODULE, member, args).await }+ if confidential {+ self.root.call_confidential(MODULE, member, args).await+ } else {+ self.root.call(MODULE, member, args).await+ }}}}@@ -44,14 +65,14 @@ impl McpModulePort for TinyMcpPort {config: &McpClientConfig,) -> Result<OpenConfiguredResponse, ModuleCallError> {self.root_call(- names::methods::OPEN_CONFIGURED,- (OpenConfiguredRequest {- data_dir: data_dir.to_owned(),- client: config.clone(),- },),- true,- )- .await+ names::methods::OPEN_CONFIGURED,+ (OpenConfiguredRequest {+ data_dir: data_dir.to_owned(),+ client: config.clone(),+ },),+ true,+ )+ .await}async fn close(&self, data_dir: &str) -> Result<Option<String>, ModuleCallError> {@@ -64,11 +85,11 @@ impl McpModulePort for TinyMcpPort {transition_id: &str,) -> Result<TransitionStatus, ModuleCallError> {self.root_call(- names::methods::TRANSITION_STATUS,- (transition_id.to_owned(),),- false,- )- .await+ names::methods::TRANSITION_STATUS,+ (transition_id.to_owned(),),+ false,+ )+ .await}async fn call_object(@@ -106,11 +127,7 @@ impl McpModulePort for TinyMcpPort {&self,request: ValidateServerArgumentsRequest,) -> Result<ServerArgumentsValidation, ModuleCallError> {- self.root_call(- names::methods::VALIDATE_SERVER_ARGUMENTS,- (request,),- true,- )+ self.root_call(names::methods::VALIDATE_SERVER_ARGUMENTS, (request,), true).await}@@ -118,11 +135,7 @@ impl McpModulePort for TinyMcpPort {&self,arguments: Option<Value>,) -> Result<Map<String, Value>, ModuleCallError> {- self.root_call(- names::methods::NORMALIZE_TOOL_ARGUMENTS,- (arguments,),- true,- )+ self.root_call(names::methods::NORMALIZE_TOOL_ARGUMENTS, (arguments,), true).await}@@ -134,4 +147,3 @@ impl McpModulePort for TinyMcpPort {.await}}-diff --git a/crates/openhuman-core/src/modules/client.rs b/crates/openhuman-core/src/modules/client.rsindex 9ce2849042..a18ecc2b8f 100644--- a/crates/openhuman-core/src/modules/client.rs+++ b/crates/openhuman-core/src/modules/client.rs@@ -165,7 +165,11 @@ impl ModuleClient {let proxy = self.timeout.map_or(proxy.clone(), |timeout| proxy.with_timeout(timeout));- return Ok(ModuleObjectClient { record, proxy });+ return Ok(ModuleObjectClient {+ record,+ proxy,+ timeout: self.timeout,+ });}super::ops::ensure_loaded(&self.config, module).await@@ -181,7 +185,11 @@ impl ModuleClient {let proxy = self.timeout.map_or(proxy.clone(), |timeout| proxy.with_timeout(timeout));- Ok(ModuleObjectClient { record, proxy })+ Ok(ModuleObjectClient {+ record,+ proxy,+ timeout: self.timeout,+ })}/// Report a structurally invalid reply from a known module invocation.@@ -266,6 +274,7 @@ impl ModuleClient {pub(crate) struct ModuleObjectClient {record: &'static super::types::ModuleRecord,proxy: tinybus::Proxy,+ timeout: Option<Duration>,}#[cfg(feature = "modules")]@@ -273,19 +282,51 @@ impl ModuleObjectClient {/// Capture the current unique peer before starting an owned lifecycle./// Later alias replacement cannot redirect operations on this client.pub(crate) async fn pin_owner(&self) -> Result<Self, ModuleCallError> {- let owner = self.proxy.connection().name_owner(self.proxy.destination()).await+ let owner = self+ .proxy+ .connection()+ .name_owner(self.proxy.destination())+ .await.map_err(|error| report_proxy_failure(self.record, &error))?.ok_or(ModuleCallError::Unavailable)?;- let proxy = self.proxy.connection().proxy(owner.as_str(), self.proxy.path().as_str(), self.proxy.interface().as_str())+ let proxy = self+ .proxy+ .connection()+ .proxy(+ owner.as_str(),+ self.proxy.path().as_str(),+ self.proxy.interface().as_str(),+ ).map_err(|error| report_proxy_failure(self.record, &error))?;- Ok(Self { record: self.record, proxy })+ let proxy = self+ .timeout+ .map_or(proxy.clone(), |timeout| proxy.with_timeout(timeout));+ Ok(Self {+ record: self.record,+ proxy,+ timeout: self.timeout,+ })}/// Derive a private child on the already captured module peer.pub(crate) fn object_at(&self, path: &str) -> Result<Self, ModuleCallError> {- let proxy = self.proxy.connection().proxy(self.proxy.destination().as_str(), path, self.proxy.interface().as_str())+ let proxy = self+ .proxy+ .connection()+ .proxy(+ self.proxy.destination().as_str(),+ path,+ self.proxy.interface().as_str(),+ ).map_err(|error| report_proxy_failure(self.record, &error))?;- Ok(Self { record: self.record, proxy })+ let proxy = self+ .timeout+ .map_or(proxy.clone(), |timeout| proxy.with_timeout(timeout));+ Ok(Self {+ record: self.record,+ proxy,+ timeout: self.timeout,+ })}pub(crate) async fn call<R: DeserializeOwned>(diff --git a/crates/openhuman-core/src/modules/client_tests.rs b/crates/openhuman-core/src/modules/client_tests.rsindex ae607ed4f6..541c8d24f1 100644--- a/crates/openhuman-core/src/modules/client_tests.rs+++ b/crates/openhuman-core/src/modules/client_tests.rs@@ -325,7 +325,11 @@ async fn private_object_clients_dispatch_only_to_the_configured_object() {).unwrap();let record = registry::find("tinysearch").unwrap();- let object = ModuleObjectClient { record, proxy };+ let object = ModuleObjectClient {+ record,+ proxy,+ timeout: None,+ };assert_eq!(object.call::<u32>("Sum", (20_u32, 22_u32)).await, Ok(42));assert_eq!(root_calls.load(std::sync::atomic::Ordering::SeqCst), 0);