Skip to content

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

feat(inbound): add event ingestion pipeline with settings and routing

Steven Enamakel35fe3fe7a497
diff --git a/crates/openhuman-core/src/config/schema/mod.rs b/crates/openhuman-core/src/config/schema/mod.rs
index fcd24cd9ba..e08a894046 100644
--- a/crates/openhuman-core/src/config/schema/mod.rs
+++ b/crates/openhuman-core/src/config/schema/mod.rs
@@ -59,8 +59,8 @@ pub(crate) use load::resolve_config_dir_for_workspace;
pub(crate) use load::CONFIG_OWNER_MISMATCH_MARKER;
pub mod claude_agent_sdk;
pub use claude_agent_sdk::ClaudeAgentSdkConfig;
-mod local_ai;
mod inbound;
+mod local_ai;
mod memes;
pub(crate) mod memory;
mod modules;
@@ -96,8 +96,8 @@ pub use dashboard::{DashboardConfig, DiagramViewerConfig, EventStreamConfig, Mod
pub use identity_cost::{
BudgetAction, BudgetPeriod, BudgetPolicy, BudgetScope, CostConfig, ModelPricing,
};
-pub use local_ai::{LocalAiConfig, LocalAiUsage};
pub use inbound::InboundConfig;
+pub use local_ai::{LocalAiConfig, LocalAiUsage};
pub use memes::MemesConfig;
pub use memory::{
migrate_legacy_source, MemoryAgentConfig, MemoryConfig, MemoryConversationsConfig,
diff --git a/crates/openhuman-core/src/inbound/deliver_tests.rs b/crates/openhuman-core/src/inbound/deliver_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/inbound/deliver_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/inbound/events.rs b/crates/openhuman-core/src/inbound/events.rs
index 61381344da..1a7ba1b4c3 100644
--- a/crates/openhuman-core/src/inbound/events.rs
+++ b/crates/openhuman-core/src/inbound/events.rs
@@ -183,7 +183,13 @@ pub fn webhook(
payload: envelope.payload.clone(),
received_at_ms: envelope.received_at.timestamp_millis(),
};
- event(source.clone(), id_or_fresh(correlation_id), source, raw, envelope)
+ event(
+ source.clone(),
+ id_or_fresh(correlation_id),
+ source,
+ raw,
+ envelope,
+ )
}
/// The envelope an inbound event was queued from, or `None` for an event
diff --git a/crates/openhuman-core/src/inbound/events_tests.rs b/crates/openhuman-core/src/inbound/events_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/inbound/events_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/inbound/host.rs b/crates/openhuman-core/src/inbound/host.rs
index ddf0ff9271..24bf4ec5da 100644
--- a/crates/openhuman-core/src/inbound/host.rs
+++ b/crates/openhuman-core/src/inbound/host.rs
@@ -64,13 +64,12 @@ pub(crate) async fn install(connection: &tinybus::Connection) -> tinybus::Result
crate::config::schema::InboundConfig::default().triage_timeout_ms
}
};
- let deliverer = Deliverer::new(
- Arc::new(LiveTriage),
- ctx,
- Duration::from_millis(timeout_ms),
- );
+ let deliverer = Deliverer::new(Arc::new(LiveTriage), ctx, Duration::from_millis(timeout_ms));
connection
- .serve_at(ObjectPath::new(PATH)?, InboundHost::new(Arc::new(deliverer)))
+ .serve_at(
+ ObjectPath::new(PATH)?,
+ InboundHost::new(Arc::new(deliverer)),
+ )
.await?;
connection.request_name(NAME).await?;
tracing::debug!("[inbound] serving the tinyeventqueues host callbacks");
diff --git a/crates/openhuman-core/src/inbound/host_tests.rs b/crates/openhuman-core/src/inbound/host_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/inbound/host_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/inbound/ops.rs b/crates/openhuman-core/src/inbound/ops.rs
index c98a23a3cd..356c8e7711 100644
--- a/crates/openhuman-core/src/inbound/ops.rs
+++ b/crates/openhuman-core/src/inbound/ops.rs
@@ -37,7 +37,10 @@ fn require(config: &Config) -> Result<(), String> {
/// # Errors
///
/// The component is off, or the module is unavailable or failed the call.
-pub async fn stats(config: &Config, client: &ModuleClient) -> Result<Outcome<StatsResponse>, String> {
+pub async fn stats(
+ config: &Config,
+ client: &ModuleClient,
+) -> Result<Outcome<StatsResponse>, String> {
require(config)?;
let stats = event_queues::stats(client)
.await
diff --git a/crates/openhuman-core/src/inbound/ops_tests.rs b/crates/openhuman-core/src/inbound/ops_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/inbound/ops_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/inbound/route_tests.rs b/crates/openhuman-core/src/inbound/route_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/inbound/route_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/inbound/schemas_tests.rs b/crates/openhuman-core/src/inbound/schemas_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/inbound/schemas_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/inbound/settings.rs b/crates/openhuman-core/src/inbound/settings.rs
index d02cb2ab30..1cd526eaed 100644
--- a/crates/openhuman-core/src/inbound/settings.rs
+++ b/crates/openhuman-core/src/inbound/settings.rs
@@ -49,7 +49,9 @@ impl Resolved {
#[must_use]
pub fn max_attempts(&self, lane: Lane) -> Option<u32> {
let queue = &self.pipeline.lanes.get(lane).queue;
- self.manifest.get(queue).map(|declared| declared.max_attempts)
+ self.manifest
+ .get(queue)
+ .map(|declared| declared.max_attempts)
}
}
@@ -75,7 +77,10 @@ pub fn shipped() -> Resolved {
/// a queue URL that is not `storage`, `amqp://…` or `amqps://…`.
pub fn resolve(config: &Config) -> Result<Resolved, String> {
let queues = read_or(config.inbound.queues_path.as_deref(), SHIPPED_QUEUES_JSON)?;
- let pipeline = read_or(config.inbound.pipeline_path.as_deref(), SHIPPED_PIPELINE_JSON)?;
+ let pipeline = read_or(
+ config.inbound.pipeline_path.as_deref(),
+ SHIPPED_PIPELINE_JSON,
+ )?;
resolve_texts(&queues, &pipeline, config.inbound.queue_url.as_deref())
}
diff --git a/crates/openhuman-core/src/inbound/settings_tests.rs b/crates/openhuman-core/src/inbound/settings_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/inbound/settings_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
index 9a2b0e7d2f..8b8b4e407b 100644
--- a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
@@ -254,67 +254,67 @@ pub(super) fn triage_directly(
runner: Arc<dyn TriageRunner>,
) -> tokio::task::JoinHandle<()> {
tokio::spawn(async move {
- match runner.run(&ctx, &envelope).await {
- Ok(TriageOutcome::Decision(run)) => {
- // Remote payload: a Composio trigger body is
- // attacker-influenceable, so the runner applies the decision
- // under the remote-trigger origin (#5634), inside this task.
- if let Err(e) = runner.apply(&ctx, run, &envelope).await {
- tracing::error!(
- label = %envelope.display_label,
- error = %e,
- "[composio][triage] apply_decision failed"
- );
- }
- }
- Ok(TriageOutcome::Deferred {
- defer_until_ms,
- reason,
- }) => {
- // Tiered fallback exhausted both arms. The direct path has
- // no scheduler of its own, so the deferral is logged and
- // dropped; with the inbound event queues on (the default)
- // triggers do not come here: `Deliver` retries a deferral
- // at `defer_until_ms` (crate::inbound::deliver).
- tracing::warn!(
- label = %envelope.display_label,
- defer_until_ms = defer_until_ms,
- reason = %reason,
- "[composio][triage] run_triage deferred"
- );
- }
- Ok(TriageOutcome::Terminal { reason }) => {
- tracing::warn!(
+ match runner.run(&ctx, &envelope).await {
+ Ok(TriageOutcome::Decision(run)) => {
+ // Remote payload: a Composio trigger body is
+ // attacker-influenceable, so the runner applies the decision
+ // under the remote-trigger origin (#5634), inside this task.
+ if let Err(e) = runner.apply(&ctx, run, &envelope).await {
+ tracing::error!(
label = %envelope.display_label,
- reason = %reason,
- "[composio][triage] run_triage reached terminal state"
- );
- }
- Err(e) => {
- // Route through the central observability classifier
- // so user-config / budget-exhausted / provider-state
- // rollups from `reliable.rs` (e.g. `The model
- // \`<id>\` may not be available on your provider …`)
- // get demoted to info-level breadcrumbs instead of
- // surfacing as raw Sentry errors. Previously this
- // call used `tracing::error!` directly and bypassed
- // the classifier — 10.7k events / 14d on self-hosted
- // Sentry TAURI-RUST-1V, dominated by
- // ProviderConfigRejection-class rollups whose inner
- // attempts the provider layer already demoted.
- let detail = format!(
- "[composio][triage] run_triage failed (label={}): {e:#}",
- envelope.display_label
- );
- crate::core::observability::report_error_or_expected(
- detail.as_str(),
- "composio",
- "trigger_triage",
- &[("label", envelope.display_label.as_str())],
+ error = %e,
+ "[composio][triage] apply_decision failed"
);
}
}
- })
+ Ok(TriageOutcome::Deferred {
+ defer_until_ms,
+ reason,
+ }) => {
+ // Tiered fallback exhausted both arms. The direct path has
+ // no scheduler of its own, so the deferral is logged and
+ // dropped; with the inbound event queues on (the default)
+ // triggers do not come here: `Deliver` retries a deferral
+ // at `defer_until_ms` (crate::inbound::deliver).
+ tracing::warn!(
+ label = %envelope.display_label,
+ defer_until_ms = defer_until_ms,
+ reason = %reason,
+ "[composio][triage] run_triage deferred"
+ );
+ }
+ Ok(TriageOutcome::Terminal { reason }) => {
+ tracing::warn!(
+ label = %envelope.display_label,
+ reason = %reason,
+ "[composio][triage] run_triage reached terminal state"
+ );
+ }
+ Err(e) => {
+ // Route through the central observability classifier
+ // so user-config / budget-exhausted / provider-state
+ // rollups from `reliable.rs` (e.g. `The model
+ // \`<id>\` may not be available on your provider …`)
+ // get demoted to info-level breadcrumbs instead of
+ // surfacing as raw Sentry errors. Previously this
+ // call used `tracing::error!` directly and bypassed
+ // the classifier — 10.7k events / 14d on self-hosted
+ // Sentry TAURI-RUST-1V, dominated by
+ // ProviderConfigRejection-class rollups whose inner
+ // attempts the provider layer already demoted.
+ let detail = format!(
+ "[composio][triage] run_triage failed (label={}): {e:#}",
+ envelope.display_label
+ );
+ crate::core::observability::report_error_or_expected(
+ detail.as_str(),
+ "composio",
+ "trigger_triage",
+ &[("label", envelope.display_label.as_str())],
+ );
+ }
+ }
+ })
}
/// Returns `true` when `OPENHUMAN_TRIGGER_TRIAGE_DISABLED` is set to a
diff --git a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber_tests.rs b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/lib.rs b/crates/openhuman-core/src/lib.rs
index 1e9202d55e..bc13b8bb93 100644
--- a/crates/openhuman-core/src/lib.rs
+++ b/crates/openhuman-core/src/lib.rs
@@ -68,6 +68,8 @@ pub mod flows;
pub mod hooks;
#[cfg(feature = "hosting")]
pub mod hosting;
+#[cfg(feature = "inbound-queues")]
+pub mod inbound;
pub mod inference;
pub mod integrations;
pub mod mcp;
@@ -91,8 +93,6 @@ pub mod test_support;
pub mod threads;
#[cfg(feature = "tinymemes")]
pub mod tinymemes;
-#[cfg(feature = "inbound-queues")]
-pub mod inbound;
pub mod tools;
pub mod triage;
pub mod util;
diff --git a/crates/openhuman-core/src/modules/event_queues.rs b/crates/openhuman-core/src/modules/event_queues.rs
index 80e6f92ee5..b556f74ab2 100644
--- a/crates/openhuman-core/src/modules/event_queues.rs
+++ b/crates/openhuman-core/src/modules/event_queues.rs
@@ -50,9 +50,16 @@ pub async fn stats(client: &ModuleClient) -> Result<StatsResponse, ModuleCallErr
/// # Errors
///
/// As [`ingest`].
-pub async fn list_dead(client: &ModuleClient, limit: u32) -> Result<Vec<DeadItem>, ModuleCallError> {
+pub async fn list_dead(
+ client: &ModuleClient,
+ limit: u32,
+) -> Result<Vec<DeadItem>, ModuleCallError> {
let response: ListDeadResponse = client
- .call(MODULE_ID, methods::LIST_DEAD, (ListDeadRequest::new(limit),))
+ .call(
+ MODULE_ID,
+ methods::LIST_DEAD,
+ (ListDeadRequest::new(limit),),
+ )
.await?;
Ok(response.dead)
}
diff --git a/crates/openhuman-core/src/modules/event_queues_tests.rs b/crates/openhuman-core/src/modules/event_queues_tests.rs
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/crates/openhuman-core/src/modules/event_queues_tests.rs
@@ -0,0 +1 @@
+
diff --git a/crates/openhuman-core/src/modules/registry.rs b/crates/openhuman-core/src/modules/registry.rs
index 02095126cd..3a99488f8b 100644
--- a/crates/openhuman-core/src/modules/registry.rs
+++ b/crates/openhuman-core/src/modules/registry.rs
@@ -53,12 +53,12 @@ mod records_voice;
use crate::modules::types::ModuleRecord;
use records_computer::TINYCOMPUTER;
-#[cfg(feature = "inbound-queues")]
-use records_eventqueues::TINYEVENTQUEUES;
#[cfg(feature = "documents")]
use records_docs_wallet::TINYDOCS;
#[cfg(feature = "web3")]
use records_docs_wallet::TINYWALLET;
+#[cfg(feature = "inbound-queues")]
+use records_eventqueues::TINYEVENTQUEUES;
#[cfg(feature = "modules")]
use records_extra::TINYBOX;
use records_extra::TINYCHANNELS;
diff --git a/crates/openhuman-core/src/skills/webhooks/bus.rs b/crates/openhuman-core/src/skills/webhooks/bus.rs
index 0029b8f123..3aede05971 100644
--- a/crates/openhuman-core/src/skills/webhooks/bus.rs
+++ b/crates/openhuman-core/src/skills/webhooks/bus.rs
@@ -161,7 +161,8 @@ impl EventHandler<DomainEvent> for WebhookRequestSubscriber {
correlation_id: correlation_id.clone(),
status_code: 202,
headers: HashMap::new(),
- body: serde_json::json!({"status": "accepted", "message": message}).to_string(),
+ body: serde_json::json!({"status": "accepted", "message": message})
+ .to_string(),
};
let skill_id = reg.agent_id.clone().or_else(|| Some(reg.skill_id.clone()));
(resp, skill_id, None)
@@ -271,7 +272,10 @@ pub(super) async fn route_agent_trigger(
match crate::inbound::events::webhook(envelope, correlation_id) {
Ok(event) => {
let client = client.unwrap_or_else(|| crate::modules::ops::client(config.clone()));
- if crate::inbound::route::offer(config, &client, event).await.is_queued() {
+ if crate::inbound::route::offer(config, &client, event)
+ .await
+ .is_queued()
+ {
tracing::debug!(
correlation_id = %correlation_id,
"[webhook] handed to the inbound event queues"
@@ -302,57 +306,56 @@ pub(super) fn triage_agent_directly(
// Spawn the triage pipeline so we don't block the broadcast channel's
// dispatch task during LLM calls.
tokio::spawn(async move {
- let result =
- tokio::time::timeout(std::time::Duration::from_secs(60), async {
- run_agent_trigger(&ctx, &envelope, runner.as_ref()).await
- })
- .await;
- let (resp, err) = match result {
- Ok(Ok(output)) => (build_agent_response(&corr, 200, &output), None),
- Ok(Err(e)) => {
- crate::core::observability::report_error(
- e.as_str(),
- "webhooks",
- "agent_trigger",
- &[
- ("correlation_id", corr.as_str()),
- ("failure", "agent_error"),
- ],
- );
- (
- build_agent_response(&corr, 500, &format!("Agent error: {e}")),
- Some(e),
- )
- }
- Err(_) => {
- crate::core::observability::report_error(
- "agent triage timed out after 60s",
- "webhooks",
- "agent_trigger",
- &[("correlation_id", corr.as_str()), ("failure", "timeout")],
- );
- (
- build_agent_response(&corr, 504, "Agent triage timed out"),
- Some("timed out after 60s".to_string()),
- )
- }
- };
- // Emit response from the spawned task.
- if let Some(mgr) = global_socket_manager() {
- let response_data = serde_json::json!({
- "correlationId": resp.correlation_id,
- "statusCode": resp.status_code,
- "headers": resp.headers,
- "body": resp.body,
- });
- if let Err(e) = mgr.emit("webhook:response", response_data).await {
- tracing::error!("[webhook] failed to emit spawned response: {}", e);
- }
- }
- if let Some(e) = err {
- tracing::warn!("[webhook] agent trigger error: {}", e);
- }
- });
+ let result = tokio::time::timeout(std::time::Duration::from_secs(60), async {
+ run_agent_trigger(&ctx, &envelope, runner.as_ref()).await
+ })
+ .await;
+ let (resp, err) = match result {
+ Ok(Ok(output)) => (build_agent_response(&corr, 200, &output), None),
+ Ok(Err(e)) => {
+ crate::core::observability::report_error(
+ e.as_str(),
+ "webhooks",
+ "agent_trigger",
+ &[
+ ("correlation_id", corr.as_str()),
+ ("failure", "agent_error"),
+ ],
+ );
+ (
+ build_agent_response(&corr, 500, &format!("Agent error: {e}")),
+ Some(e),
+ )
+ }
+ Err(_) => {
+ crate::core::observability::report_error(
+ "agent triage timed out after 60s",
+ "webhooks",
+ "agent_trigger",
+ &[("correlation_id", corr.as_str()), ("failure", "timeout")],
+ );
+ (
+ build_agent_response(&corr, 504, "Agent triage timed out"),
+ Some("timed out after 60s".to_string()),
+ )
+ }
+ };
+ // Emit response from the spawned task.
+ if let Some(mgr) = global_socket_manager() {
+ let response_data = serde_json::json!({
+ "correlationId": resp.correlation_id,
+ "statusCode": resp.status_code,
+ "headers": resp.headers,
+ "body": resp.body,
+ });
+ if let Err(e) = mgr.emit("webhook:response", response_data).await {
+ tracing::error!("[webhook] failed to emit spawned response: {}", e);
+ }
+ }
+ if let Some(e) = err {
+ tracing::warn!("[webhook] agent trigger error: {}", e);
+ }
+ })
}
/// Decode a base64-encoded webhook request body into a JSON value.