Skip to content

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

fix(composio): handle missing connection credentials gracefully

Steven Enamakel8e952dd0d80b
diff --git a/crates/openhuman-core/src/cron/scheduler/run_delivery.rs b/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
index 0065671102..a1279e449b 100644
--- a/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
@@ -101,7 +101,7 @@ impl TriggerSink for HostTriggers {
Err(_) => None,
}
.map_or_else(|| flow_id.to_string(), |job| job.id);
- return Ok(run_system_job(&job_id, name, run_id).await);
+ return Ok(run_system_job(&self.binding.dispatch_ctx(), &job_id, name, run_id).await);
}
// `[components] flows = false`: schedule-triggered flows stop
// while agent, shell and system jobs keep running. The tick is
@@ -149,10 +149,16 @@ impl TriggerSink for HostTriggers {
/// A host-owned system job (`system:<name>`): announced on the bus, then its
/// registered handler is awaited and its result is the run's result. Without a
/// handler the job is announce-only and `ok` on dispatch.
-async fn run_system_job(job_id: &str, name: &str, run_id: &str) -> Attempt {
+async fn run_system_job(
+ ctx: &crate::core::runtime::DispatchCtx,
+ job_id: &str,
+ name: &str,
+ run_id: &str,
+) -> Attempt {
tracing::info!(%job_id, job = %name, %run_id, "[cron] system job due — publishing CronSystemJobDue");
BUS.publish(DomainEvent::CronSystemJobDue {
job: name.to_string(),
+ tenant: ctx.event_tenant(),
});
let ctx = crate::cron::system_job_handlers::SystemJobContext {
job_id: job_id.to_string(),
diff --git a/crates/openhuman-core/src/integrations/composio/ops/connections.rs b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
index 57c99a714d..617826bee8 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
@@ -111,6 +111,7 @@ pub async fn composio_list_connections(
}
pub async fn composio_authorize(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
toolkit: &str,
extra_params: Option<serde_json::Value>,
@@ -139,6 +140,7 @@ pub async fn composio_authorize(
toolkit: toolkit.to_string(),
connection_id: resp.connection_id.clone(),
connect_url: resp.connect_url.clone(),
+ tenant: ctx.event_tenant(),
},
);
diff --git a/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs b/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
index 9c36586417..99fc1ae3d0 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
@@ -117,6 +117,7 @@ pub async fn composio_set_api_key(
crate::core::bus::BUS.publish(crate::core::events::DomainEvent::ComposioConfigChanged {
mode: effective_mode.clone(),
api_key_set: true,
+ tenant: ctx.event_tenant(),
});
tracing::debug!(
mode = %effective_mode,
@@ -157,6 +158,7 @@ pub async fn composio_clear_api_key(
crate::core::bus::BUS.publish(crate::core::events::DomainEvent::ComposioConfigChanged {
mode: "backend".to_string(),
api_key_set: false,
+ tenant: ctx.event_tenant(),
});
tracing::debug!("[composio-cache] published ComposioConfigChanged after clear_api_key");
diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
index 0608c892f9..734d269790 100644
--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
@@ -57,7 +57,7 @@ pub(super) fn handle_authorize(ctx: DispatchCtx, params: Map<String, Value>) ->
let config = ctx.load_config().await?;
let toolkit = read_required_non_empty(&params, "toolkit")?;
let extra_params = params.get("extra_params").cloned();
- to_json(ops::composio_authorize(&config, &toolkit, extra_params).await?)
+ to_json(ops::composio_authorize(&ctx, &config, &toolkit, extra_params).await?)
})
}
diff --git a/crates/openhuman-core/src/security/credentials/ops/credential.rs b/crates/openhuman-core/src/security/credentials/ops/credential.rs
index 033003d8a1..1a1ebf4176 100644
--- a/crates/openhuman-core/src/security/credentials/ops/credential.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/credential.rs
@@ -222,7 +222,7 @@ pub async fn set_credential(
"{LOG_PREFIX} api key stored"
);
let state = build_session_state(config)?;
- publish_credential_changed(CredentialKind::ApiKey.as_str());
+ publish_credential_changed(ctx, CredentialKind::ApiKey.as_str());
return Ok(Outcome::single_log(state, "api key stored"));
}
@@ -371,7 +371,7 @@ pub async fn set_credential(
);
let state = build_session_state(&effective_config)?;
- publish_credential_changed(resolved.kind.as_str());
+ publish_credential_changed(ctx, resolved.kind.as_str());
Ok(Outcome::new(state, logs))
}
@@ -491,7 +491,7 @@ pub async fn clear_credential(
}
if removed_session || removed_api_key {
- publish_credential_changed("cleared");
+ publish_credential_changed(ctx, "cleared");
}
Ok(Outcome::new(
json!({
@@ -629,10 +629,11 @@ pub(crate) fn process_credential_refusal(saas: bool, operation: &str) -> Result<
/// Tell credential-derived caches (the search module's managed routes) to
/// refresh. Carries only the kind, never the credential.
-fn publish_credential_changed(kind: &str) {
+fn publish_credential_changed(ctx: &DispatchCtx, kind: &str) {
tracing::debug!(kind, "{LOG_PREFIX} publishing CredentialChanged");
crate::core::bus::BUS.publish(crate::core::events::DomainEvent::CredentialChanged {
kind: kind.to_string(),
+ tenant: ctx.event_tenant(),
});
}