Skip to content

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

fix(task_sources): load config per scope when firing connection events

Steven Enamakelf1b5b670def6
diff --git a/crates/openhuman-core/src/integrations/task_sources/bus.rs b/crates/openhuman-core/src/integrations/task_sources/bus.rs
index 0d9c4806ac..3abffbf4fb 100644
--- a/crates/openhuman-core/src/integrations/task_sources/bus.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/bus.rs
@@ -49,26 +49,33 @@ impl EventHandler<DomainEvent> for TaskSourcesConnectionSubscriber {
return;
};
- let config = match config_rpc::load_config_with_timeout().await {
- Ok(config) => config,
- Err(e) => {
- tracing::debug!(error = %e, "[task_sources:bus] load_config failed, skipping");
- return;
- }
- };
- if !config.task_sources.enabled {
- return;
- }
-
// Every scope may hold sources for this toolkit (`crate::storage`):
- // fire each scope's under its own agent.
+ // handle each scope as its own agent, with that agent's config.
crate::storage::agents::for_each_live_scope("task_sources connection", || {
- fire_for_connection(&config, provider, toolkit, connection_id)
+ fire_in_scope(provider, toolkit, connection_id)
})
.await;
}
}
+/// [`fire_for_connection`] for the current scope, with the configuration
+/// loaded inside it — so an agent whose own config disables task sources is
+/// skipped even when the process config enables them, and the other way
+/// round.
+async fn fire_in_scope(provider: ProviderSlug, toolkit: &str, connection_id: &str) {
+ let config = match config_rpc::load_config_with_timeout().await {
+ Ok(config) => config,
+ Err(e) => {
+ tracing::debug!(error = %e, "[task_sources:bus] load_config failed, skipping scope");
+ return;
+ }
+ };
+ if !config.task_sources.enabled {
+ return;
+ }
+ fire_for_connection(&config, provider, toolkit, connection_id).await;
+}
+
/// Starts a one-shot fetch for every enabled source of `provider` in the
/// current storage scope that the new connection serves.
async fn fire_for_connection(
diff --git a/crates/openhuman-core/src/security/devices/owner.rs b/crates/openhuman-core/src/security/devices/owner.rs
index 4867abc1cb..ada467040b 100644
--- a/crates/openhuman-core/src/security/devices/owner.rs
+++ b/crates/openhuman-core/src/security/devices/owner.rs
@@ -86,14 +86,18 @@ pub(super) async fn owner_of(
.await
{
Some(Ok(true)) => return Ok(owner),
- Some(Err(error)) => return Err(OwnerLookupFailed { agent: owner, error }),
+ Some(Err(error)) => {
+ return Err(OwnerLookupFailed {
+ agent: owner,
+ error,
+ })
+ }
Some(Ok(false)) | None => forget(channel_id),
}
}
- let lookups = crate::storage::agents::for_each_scope("device owner", || {
- has_live_device(channel_id)
- })
- .await;
+ let lookups =
+ crate::storage::agents::for_each_scope("device owner", || has_live_device(channel_id))
+ .await;
let owner = decide(lookups)?;
if let Some(owner) = &owner {
log::debug!(