Skip to content

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

feat(config): add inbound host configuration schema

Steven Enamakeld784a3d8cf21
diff --git a/crates/openhuman-core/src/config/ops/loader/snapshot.rs b/crates/openhuman-core/src/config/ops/loader/snapshot.rs
index b91294c245..cbe466f377 100644
--- a/crates/openhuman-core/src/config/ops/loader/snapshot.rs
+++ b/crates/openhuman-core/src/config/ops/loader/snapshot.rs
@@ -15,6 +15,11 @@ pub fn snapshot_config_json(config: &Config) -> Result<serde_json::Value, String
value["search"][provider]["api_key"] = serde_json::Value::Null;
}
value["seltz"]["api_key"] = serde_json::Value::Null;
+ // A broker URL may carry credentials too; show it redacted.
+ if let Some(url) = config.inbound.queue_url.as_deref() {
+ value["inbound"]["queue_url"] =
+ serde_json::Value::String(crate::config::schema::storage::redact_url(url));
+ }
// A storage URL may carry database credentials; show it redacted.
if let Some(url) = config.storage.url.as_deref() {
value["storage"]["url"] =
diff --git a/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs b/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs
index ef46cfdbad..8ae686eee1 100644
--- a/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs
+++ b/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs
@@ -364,6 +364,18 @@ fn snapshot_config_json_redacts_the_storage_url_credentials() {
);
}
+#[test]
+fn snapshot_config_json_redacts_the_inbound_queue_url_credentials() {
+ let mut cfg = Config::default();
+ cfg.inbound.queue_url = Some("amqp://app:[email protected]/vhost".into());
+ let snapshot = snapshot_config_json(&cfg).unwrap();
+ assert!(!snapshot.to_string().contains("hunter2"));
+ assert_eq!(
+ snapshot["config"]["inbound"]["queue_url"],
+ "amqp://***@broker.internal/vhost"
+ );
+}
+
// ── agent_server_status ────────────────────────────────────────
#[test]
diff --git a/crates/openhuman-core/src/config/schema/inbound.rs b/crates/openhuman-core/src/config/schema/inbound.rs
index 00d9d3c3b9..425a53c3de 100644
--- a/crates/openhuman-core/src/config/schema/inbound.rs
+++ b/crates/openhuman-core/src/config/schema/inbound.rs
@@ -15,19 +15,23 @@
//! | `queues_path` | a `queues.json` replacing the shipped one |
//! | `pipeline_path` | a `pipeline.json` replacing the shipped one |
//! | `queue_url` | where the queues live: `storage` (default) or a broker URL |
-//! | `triage_timeout_ms` | how long one delivered event's triage may take |
+//! | `triage_timeout_ms` | how long one delivered event's triage may take (at most 25 s) |
use std::path::PathBuf;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
-/// Default bound on one delivered event's triage: below the module's shortest
-/// lane lease (two minutes), so a slow triage retries rather than racing a
-/// redelivery of the same turn.
-pub const DEFAULT_TRIAGE_TIMEOUT_MS: u64 = 90_000;
+/// The longest one delivered event's triage may take. The module waits 30 s
+/// for a host callback before it treats the delivery as failed and retries
+/// it; a triage still running then would decide (and act) a second time on
+/// the redelivery. Staying under that deadline keeps one decision per turn.
+pub const MAX_TRIAGE_TIMEOUT_MS: u64 = 25_000;
-#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
+/// Default bound on one delivered event's triage: [`MAX_TRIAGE_TIMEOUT_MS`].
+pub const DEFAULT_TRIAGE_TIMEOUT_MS: u64 = MAX_TRIAGE_TIMEOUT_MS;
+
+#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct InboundConfig {
/// Route Composio triggers and agent webhooks through the inbound event
@@ -44,10 +48,36 @@ pub struct InboundConfig {
/// (only in builds with the storage `rabbitmq` driver). Never logged.
pub queue_url: Option<String>,
/// How long one delivered event's triage may take, in milliseconds,
- /// before the delivery is retried.
+ /// before the delivery is retried. Capped at [`MAX_TRIAGE_TIMEOUT_MS`];
+ /// read when the host callbacks are served (the next core start).
pub triage_timeout_ms: u64,
}
+impl InboundConfig {
+ /// [`Self::triage_timeout_ms`], capped below the module's callback
+ /// deadline.
+ #[must_use]
+ pub fn triage_timeout(&self) -> std::time::Duration {
+ std::time::Duration::from_millis(self.triage_timeout_ms.clamp(1, MAX_TRIAGE_TIMEOUT_MS))
+ }
+}
+
+impl std::fmt::Debug for InboundConfig {
+ /// Redacts credentials: a broker URL carries the broker password.
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("InboundConfig")
+ .field("enabled", &self.enabled)
+ .field("queues_path", &self.queues_path)
+ .field("pipeline_path", &self.pipeline_path)
+ .field(
+ "queue_url",
+ &self.queue_url.as_deref().map(super::storage::redact_url),
+ )
+ .field("triage_timeout_ms", &self.triage_timeout_ms)
+ .finish()
+ }
+}
+
impl Default for InboundConfig {
fn default() -> Self {
Self {
diff --git a/crates/openhuman-core/src/config/schema/inbound_tests.rs b/crates/openhuman-core/src/config/schema/inbound_tests.rs
index 9c8fe207e4..cc9e522377 100644
--- a/crates/openhuman-core/src/config/schema/inbound_tests.rs
+++ b/crates/openhuman-core/src/config/schema/inbound_tests.rs
@@ -18,3 +18,26 @@ fn a_partial_section_keeps_the_other_defaults() {
assert_eq!(c.queues_path, Some(PathBuf::from("/etc/oh/queues.json")));
assert_eq!(c.triage_timeout_ms, DEFAULT_TRIAGE_TIMEOUT_MS);
}
+
+#[test]
+fn the_triage_timeout_stays_under_the_module_callback_deadline() {
+ let mut c = InboundConfig::default();
+ assert_eq!(c.triage_timeout().as_millis(), u128::from(MAX_TRIAGE_TIMEOUT_MS));
+ c.triage_timeout_ms = 90_000;
+ assert_eq!(c.triage_timeout().as_millis(), u128::from(MAX_TRIAGE_TIMEOUT_MS));
+ c.triage_timeout_ms = 0;
+ assert_eq!(c.triage_timeout().as_millis(), 1);
+ c.triage_timeout_ms = 5_000;
+ assert_eq!(c.triage_timeout().as_millis(), 5_000);
+}
+
+#[test]
+fn debug_redacts_the_broker_credentials() {
+ let c = InboundConfig {
+ queue_url: Some("amqp://user:[email protected]/vhost".into()),
+ ..InboundConfig::default()
+ };
+ let shown = format!("{c:?}");
+ assert!(!shown.contains("hunter2"), "{shown}");
+ assert!(shown.contains("broker.internal"), "{shown}");
+}
diff --git a/crates/openhuman-core/src/inbound/host.rs b/crates/openhuman-core/src/inbound/host.rs
index f6e1c47485..27ea51cdf9 100644
--- a/crates/openhuman-core/src/inbound/host.rs
+++ b/crates/openhuman-core/src/inbound/host.rs
@@ -7,7 +7,6 @@
//! back off until it is served.
use std::sync::Arc;
-use std::time::Duration;
use tinybus::ObjectPath;
use tinyeventqueues_bus::names::host::{INTERFACE as NAME, OBJECT_PATH as PATH};
@@ -57,18 +56,16 @@ impl InboundHost {
/// Serve the callbacks on `connection`, triaging under the host's own context.
pub(crate) async fn install(connection: &tinybus::Connection) -> tinybus::Result<()> {
let ctx = DispatchCtx::host_default();
- let timeout_ms = match ctx.load_config().await {
- Ok(config) => config.inbound.triage_timeout_ms,
+ // Read once, when the callbacks are served: a change takes effect on the
+ // next core start.
+ let timeout = match ctx.load_config().await {
+ Ok(config) => config.inbound.triage_timeout(),
Err(error) => {
tracing::debug!(error = %error, "[inbound] config unavailable; default triage timeout");
- crate::config::schema::InboundConfig::default().triage_timeout_ms
+ crate::config::schema::InboundConfig::default().triage_timeout()
}
};
- let deliverer = Deliverer::new(
- Arc::new(RemoteTriage),
- ctx,
- Duration::from_millis(timeout_ms),
- );
+ let deliverer = Deliverer::new(Arc::new(RemoteTriage), ctx, timeout);
connection
.serve_at(
ObjectPath::new(PATH)?,