Skip to content

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

feat(agent,cron): enable channels feature support in agent and cron logic

Steven Enamakel9a2ac27e0b87
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rs
index 9ce2819396..519dc2bbe7 100644
--- a/crates/openhuman-core/src/agent/host_agents.rs
+++ b/crates/openhuman-core/src/agent/host_agents.rs
@@ -85,6 +85,7 @@ impl HostAgent {
/// account/conversation); TinyAgents adds the agent id through
/// `set_thread_id` when it binds the SessionRef.
#[allow(clippy::too_many_arguments)]
+ #[cfg(feature = "channels")]
pub(crate) async fn run_external_channel_turn(
self,
session_key: &str,
diff --git a/crates/openhuman-core/src/agent/turn_host.rs b/crates/openhuman-core/src/agent/turn_host.rs
index 7677dd2e28..13751313e9 100644
--- a/crates/openhuman-core/src/agent/turn_host.rs
+++ b/crates/openhuman-core/src/agent/turn_host.rs
@@ -34,10 +34,12 @@ pub(crate) struct TrustedAgentTurn {
pub(crate) approval: ApprovalTurnContext,
pub(crate) relay_thread: Option<String>,
pub(crate) imported_history: Vec<tinyagents_session::transcript::TranscriptMessage>,
+ #[cfg(feature = "channels")]
pub(crate) legacy_history: Option<crate::channels::providers::relay::LegacyHistoryImport>,
/// Captured configured compiled-module target for native turns. The
/// progressive handle itself is opened at runner checkout per admitted
/// request, so queued follow-ups never reuse a finished handle.
+ #[cfg(feature = "channels")]
pub(crate) native_target:
Option<Arc<crate::channels::runtime::dispatch::NativeProgressiveTarget>>,
}
@@ -50,7 +52,9 @@ impl std::fmt::Debug for TrustedAgentTurn {
.field("session_scoped", &!self.session_key.is_empty())
.field("relay_thread", &self.relay_thread)
.field("imported_history_rows", &self.imported_history.len())
+ #[cfg(feature = "channels")]
.field("has_legacy_history", &self.legacy_history.is_some())
+ #[cfg(feature = "channels")]
.field("native_target", &self.native_target.is_some())
.finish_non_exhaustive()
}
diff --git a/crates/openhuman-core/src/cron/mod.rs b/crates/openhuman-core/src/cron/mod.rs
index 994110d418..ff65343000 100644
--- a/crates/openhuman-core/src/cron/mod.rs
+++ b/crates/openhuman-core/src/cron/mod.rs
@@ -23,6 +23,7 @@ pub(crate) mod bus_host;
deprecated,
reason = "v21 ChannelMessage/SendMessage shims stay until the native channel path moves to canonical v22 content"
)]
+#[cfg(feature = "channels")]
pub mod channel_bridge;
pub(crate) mod client;
pub mod completion_owner;
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
index 4cf76f7707..bddad78041 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
@@ -17,10 +17,9 @@ use crate::core::runtime::DispatchCtx;
use crate::web_chat::{publish_web_channel_event, WebChannelEvent};
use anyhow::{anyhow, Result};
use std::path::Path;
-use {
- crate::cron::channel_bridge, tinyflows_bus::schedule::types::CronJob,
- tinyflows_bus::schedule::types::DeliveryStatus, tinyflows_bus::schedule::types::JobOrigin,
-};
+use tinyflows_bus::schedule::types::{CronJob, DeliveryStatus, JobOrigin};
+#[cfg(feature = "channels")]
+use crate::cron::channel_bridge;
/// What a scheduled run replies when it has nothing worth sending.
pub(crate) const NO_REPLY: &str = "NO_REPLY";
@@ -237,6 +236,13 @@ pub(crate) async fn deliver_to_origin(
channel_session,
..
} => {
+ #[cfg(not(feature = "channels"))]
+ {
+ let _ = (channel, reply_target, channel_session);
+ return Err(anyhow!("channel delivery requires the channels feature"));
+ }
+ #[cfg(feature = "channels")]
+ {
let identity = channel_session
.as_deref()
.ok_or_else(|| anyhow!("channel origin has no durable session identity"))?;
@@ -274,6 +280,7 @@ pub(crate) async fn deliver_to_origin(
"[cron] origin delivery sent to channel"
);
Ok(DeliveryStatus::Delivered)
+ }
}
}
}