Skip to content

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

test(native_channel_session_restart_e2e): report observed state on completion timeout

Steven Enamakel2ca83a267006
diff --git a/tests/native_channel_session_restart_e2e.rs b/tests/native_channel_session_restart_e2e.rs
index e94f5a4969..2d3b14fb68 100644
--- a/tests/native_channel_session_restart_e2e.rs
+++ b/tests/native_channel_session_restart_e2e.rs
@@ -9,7 +9,7 @@
//! linked TinyChannels module implementation so it exercises the native
//! Telegram listener rather than a host-side REST adapter.
-use std::collections::{HashMap, VecDeque};
+use std::collections::VecDeque;
use std::fs::File;
use std::path::Path;
use std::process::{Child, Command, Stdio};
@@ -372,10 +372,26 @@ async fn wait_healthy(base: &str, process: &mut CoreProcess, log_path: &Path) {
}
async fn wait_for_completion(state: &MockState, count: usize) {
- wait_until("model request", || {
- state.completions.lock().expect("model requests").len() >= count
- })
- .await;
+ let deadline = Instant::now() + Duration::from_secs(45);
+ while state.completions.lock().expect("model requests").len() < count {
+ if Instant::now() >= deadline {
+ let model_requests = state.completions.lock().expect("model requests").len();
+ let offsets = state
+ .update_offsets
+ .lock()
+ .expect("Telegram offsets")
+ .clone();
+ let sent_messages = state
+ .sent_messages
+ .lock()
+ .expect("Telegram sent messages")
+ .len();
+ panic!(
+ "timed out waiting for model request {count}; observed {model_requests} model requests, Telegram offsets {offsets:?}, and {sent_messages} outbound messages"
+ );
+ }
+ sleep(Duration::from_millis(50)).await;
+ }
wait_until("final Telegram reply", || {
state
.sent_messages