Skip to content

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

feat(runtime): introduce channel turn deadline calculation

Steven Enamakel43b070668bf1
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
index 432cb3a3f4..7229902079 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
@@ -540,6 +540,16 @@ impl Default for NativeRuntime {
}
}
+fn channel_turn_deadline(
+ message_timeout_secs: u64,
+ web_backstop: Option<std::time::Duration>,
+) -> std::time::Duration {
+ let channel_deadline = std::time::Duration::from_secs(
+ message_timeout_secs.max(tinychannels_bus::MIN_CHANNEL_MESSAGE_TIMEOUT_SECS),
+ );
+ web_backstop.map_or(channel_deadline, |backstop| backstop.min(channel_deadline))
+}
+
pub(crate) struct NativeTurnExecution {
pub(crate) result: Result<crate::agent::bus::AgentTurnResponse, String>,
pub(crate) delivery_succeeded: Option<bool>,
@@ -551,6 +561,7 @@ pub(crate) async fn run(
thread_id: String,
request_id: String,
text: String,
+ message_timeout_secs: u64,
trusted: Arc<crate::agent::turn_host::TrustedAgentTurn>,
) -> NativeTurnExecution {
let runtime = crate::core::runtime::slot_for::<NativeRuntime>(dispatch);
@@ -565,6 +576,10 @@ pub(crate) async fn run(
}
};
runtime.shared.begin_delivery_wait(&request_id);
+ let deadline = channel_turn_deadline(
+ message_timeout_secs,
+ crate::agent::session_host::turn_backstop::configured_backstop(),
+ );
let request = TurnRequest {
scope: ScopeKey {
agent_id: trusted.host_agent.definition.id.clone(),
@@ -580,7 +595,7 @@ pub(crate) async fn run(
},
host_authored: false,
disposition: QueueDisposition::Interrupt,
- deadline: crate::agent::session_host::turn_backstop::configured_backstop(),
+ deadline: Some(deadline),
idle_timeout: Some(crate::agent::turn_policy::configured_idle_window()),
};
let runner_result = runtime.runner.run(request).await;
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 242db4488d..6e403da402 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -439,6 +439,7 @@ pub(crate) async fn process_channel_runtime_message(
session_key.clone(),
request_id,
enriched_message.clone(),
+ ctx.message_timeout_secs,
trusted,
)
.await