Skip to content

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

test(runtime): enforce minimum channel message timeout

Steven Enamakelc4917c28f918
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner_tests.rs
index 5f38967bb3..f6774fb15c 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner_tests.rs
@@ -1,5 +1,22 @@
use super::*;
+#[test]
+fn channel_deadline_respects_module_floor_and_web_backstop() {
+ let minimum = tinychannels_bus::MIN_CHANNEL_MESSAGE_TIMEOUT_SECS;
+ assert_eq!(
+ channel_turn_deadline(1, None),
+ std::time::Duration::from_secs(minimum)
+ );
+ assert_eq!(
+ channel_turn_deadline(minimum + 10, Some(std::time::Duration::from_secs(5))),
+ std::time::Duration::from_secs(5)
+ );
+ assert_eq!(
+ channel_turn_deadline(minimum + 10, Some(std::time::Duration::from_secs(60))),
+ std::time::Duration::from_secs(minimum + 10)
+ );
+}
+
#[test]
fn native_failure_classifier_preserves_localizable_error_metadata() {
let failure = NativeFailures.classify_failure("429 Too Many Requests: Retry-After: 12");
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
index 6e403da402..d49e071639 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -454,18 +454,27 @@ pub(crate) async fn process_channel_runtime_message(
}
#[cfg(test)]
None => {
- let result = super::bus_turn::dispatch_test_turn(
- ctx.as_ref(),
- &msg,
- &route,
- &enriched_message,
- active_turn_model_source,
- None,
- turn_origin,
- approval,
+ let timeout_secs = ctx
+ .message_timeout_secs
+ .max(tinychannels_bus::MIN_CHANNEL_MESSAGE_TIMEOUT_SECS);
+ let result = match tokio::time::timeout(
+ Duration::from_secs(timeout_secs),
+ super::bus_turn::dispatch_test_turn(
+ ctx.as_ref(),
+ &msg,
+ &route,
+ &enriched_message,
+ active_turn_model_source,
+ None,
+ turn_origin,
+ approval,
+ ),
)
.await
- .map_err(|error| error.to_string());
+ {
+ Ok(result) => result.map_err(|error| error.to_string()),
+ Err(_) => Err(crate::web_chat::turn_timeout_error_message(timeout_secs)),
+ };
super::super::native_runner::NativeTurnExecution {
result,
delivery_succeeded: None,
diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rs
index 93e3f7725c..7b1582265a 100644
--- a/crates/openhuman-core/src/channels/runtime/test_support.rs
+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs
@@ -368,7 +368,11 @@ pub async fn run_dispatch_harness(options: DispatchHarnessOptions) -> DispatchHa
reliability: Arc::new(ReliabilityConfig::default()),
provider_runtime_options: ProviderRuntimeOptions::default(),
workspace_dir: Arc::new(harness_workspace_dir),
- message_timeout_secs: options.timeout_secs,
+ // Mirror the owning TinyChannels runtime's validated floor even when
+ // a test supplies an undersized value directly.
+ message_timeout_secs: options
+ .timeout_secs
+ .max(tinychannels_bus::MIN_CHANNEL_MESSAGE_TIMEOUT_SECS),
multimodal: MultimodalConfig::default(),
multimodal_files: MultimodalFileConfig::default(),
config: None,
diff --git a/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs b/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs
index c06e22d40a..c9ecaebaac 100644
--- a/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs
+++ b/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs
@@ -670,13 +670,13 @@ async fn process_channel_message_hardens_against_relative_path_markers() {
assert!(!observed.allow_remote_fetch);
}
-#[tokio::test]
+#[tokio::test(start_paused = true)]
async fn dispatch_replies_with_timeout_notice_when_handler_exceeds_deadline() {
let timed_out = run_dispatch_harness(DispatchHarnessOptions {
channel_name: "email".to_string(),
content: "force timeout".to_string(),
- handler_delay_ms: 1_200,
- timeout_secs: 1,
+ handler_delay_ms: 31_000,
+ timeout_secs: tinychannels_bus::MIN_CHANNEL_MESSAGE_TIMEOUT_SECS,
..Default::default()
})
.await;