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
refactor(cron): simplify origin context validation
Steven Enamakel9d3cab02e408
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_context.rs b/crates/openhuman-core/src/cron/scheduler/origin_context.rsindex be6cd403ae..c66a18f705 100644--- a/crates/openhuman-core/src/cron/scheduler/origin_context.rs+++ b/crates/openhuman-core/src/cron/scheduler/origin_context.rs@@ -90,7 +90,7 @@ async fn origin_messages(channel,..} => match validated_channel_session(ctx, config, channel, identity) {- Ok(Some((session_key, agent_id, tenant))) => {+ Ok((session_key, agent_id, tenant)) => {let Some(core) = ctx.core() else {tracing::warn!("[cron] channel origin has no resolved core context");return Vec::new();@@ -105,6 +105,7 @@ async fn origin_messages(let head = locator.head_generation(&session);locator.read_session_transcript(&head)+ .ok().and_then(|read| read.read_session().ok().flatten()).map(|history| {history@@ -122,7 +123,6 @@ async fn origin_messages(}).unwrap_or_default()}- Ok(None) => Vec::new(),Err(error) => {tracing::warn!(%error, "[cron] refusing unscoped channel origin context");Vec::new()@@ -139,7 +139,7 @@ pub(super) fn validated_channel_session(config: &Config,channel: &str,identity: &ChannelSessionIdentity,-) -> Result<Option<(String, String, crate::core::runtime::Tenant)>, String> {+) -> Result<(String, String, crate::core::runtime::Tenant), String> {let tenant = ctx.tenant().map_err(|error| error.to_string())?;let tenant_scope = crate::core::runtime::tenant_key(&tenant, "");if identity.tenant_key != tenant_scope {@@ -179,11 +179,11 @@ pub(super) fn validated_channel_session(if selected_agent != identity.agent_id {return Err("channel origin agent no longer matches its configured route".into());}- Ok(Some((+ Ok((crate::core::runtime::tenant_key(&tenant, &identity.session_key),identity.agent_id.clone(),tenant,- )))+ ))}/// Prompt for a `current` run: tagged task, unattended preamble, the boundeddiff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rsindex d5afc367f5..4265745ffd 100644--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs@@ -161,6 +161,18 @@ pub(crate) async fn deliver_to_origin());};let text = output.trim();+ if let JobOrigin::Channel {+ channel,+ channel_session,+ ..+ } = origin+ {+ let identity = channel_session+ .as_deref()+ .ok_or_else(|| anyhow!("channel origin has no durable session identity"))?;+ super::origin_context::validated_channel_session(ctx, config, channel, identity)+ .map_err(|error| anyhow!("invalid channel origin: {error}"))?;+ }// The job's tenant: a hosted profile's or an embedded agent's host routes// the reply itself; otherwise it keys the transcript store below.@@ -231,8 +243,7 @@ pub(crate) async fn deliver_to_origin(.ok_or_else(|| anyhow!("channel origin has no durable session identity"))?;let (session_key, agent_id, _tenant) =super::origin_context::validated_channel_session(ctx, config, channel, identity)- .map_err(|error| anyhow!("invalid channel origin: {error}"))?- .ok_or_else(|| anyhow!("channel origin has no durable session identity"))?;+ .map_err(|error| anyhow!("invalid channel origin: {error}"))?;let text = strip_openhuman_link_markup(text);channel_bridge::send_to_channel(channel,@@ -279,8 +290,7 @@ async fn append_channel_transcript() -> Result<()> {let (session_key, agent_id, _) =super::origin_context::validated_channel_session(ctx, config, channel, identity)- .map_err(|error| anyhow!("invalid channel origin: {error}"))?- .ok_or_else(|| anyhow!("channel origin has no durable session identity"))?;+ .map_err(|error| anyhow!("invalid channel origin: {error}"))?;let transcripts = origin_channel_transcripts(ctx, config, identity, &agent_id)?;append_to_origin_transcript(transcripts.as_ref(),