Skip to content

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

test(saas_isolation): pair request ids with their owning thread

Steven Enamakel9bed3a7a10aa
diff --git a/tests/saas_isolation/generators.rs b/tests/saas_isolation/generators.rs
index 0812edd68f..8bca74ea65 100644
--- a/tests/saas_isolation/generators.rs
+++ b/tests/saas_isolation/generators.rs
@@ -76,7 +76,8 @@ pub const GENERATORS: &[(&str, Generator)] = &[
json!({ "thread_id": w.thread_for(a, false) })
}),
("openhuman.threads_turn_state_get_turn", |w, a| {
- json!({ "thread_id": w.thread_for(a, false), "request_id": w.request_for(a) })
+ let (request, thread) = w.request_on_thread(a);
+ json!({ "thread_id": thread, "request_id": request })
}),
("openhuman.threads_turn_state_clear", |w, a| {
json!({ "thread_id": w.thread_for(a, true) })
@@ -127,11 +128,12 @@ pub const GENERATORS: &[(&str, Generator)] = &[
params
}),
("openhuman.channel_web_cancel", |w, a| {
- let mut params = json!({ "client_id": w.client_for(a), "thread_id": w.thread_for(a, true) });
if w.rng.chance(70) {
- params["request_id"] = json!(w.request_for(a));
+ let (request, thread) = w.request_on_thread(a);
+ json!({ "client_id": w.client_for(a), "thread_id": thread, "request_id": request })
+ } else {
+ json!({ "client_id": w.client_for(a), "thread_id": w.thread_for(a, true) })
}
- params
}),
("openhuman.channel_web_queue_status", |w, a| {
json!({ "thread_id": w.thread_for(a, false) })
diff --git a/tests/saas_isolation/world.rs b/tests/saas_isolation/world.rs
index 0139b45210..3ae5013d7d 100644
--- a/tests/saas_isolation/world.rs
+++ b/tests/saas_isolation/world.rs
@@ -263,6 +263,21 @@ impl World {
}
}
+ /// A request id and, when known, the thread it ran on: a cancel aimed
+ /// at exactly another user's `(thread, request)`.
+ pub fn request_on_thread(&mut self, actor: usize) -> (String, String) {
+ let request = self.request_for(actor);
+ let thread = self
+ .pools
+ .requests
+ .iter()
+ .find(|o| o.value == request)
+ .and_then(|o| o.thread.clone())
+ .filter(|t| !self.protected[actor].contains(t) && self.rng.chance(70));
+ let thread = thread.unwrap_or_else(|| self.thread_for(actor, true));
+ (request, thread)
+ }
+
pub fn message_for(&mut self, actor: usize) -> String {
self.foreign_first(actor, |p| &p.messages)
}
diff --git a/tests/saas_mode/mock_llm.rs b/tests/saas_mode/mock_llm.rs
index d22360be94..f178b6fef3 100644
--- a/tests/saas_mode/mock_llm.rs
+++ b/tests/saas_mode/mock_llm.rs
@@ -68,10 +68,6 @@ pub struct MockLlm {
}
impl MockLlm {
- pub fn url(&self) -> String {
- format!("http://127.0.0.1:{}", self.port)
- }
-
pub fn recorded(&self) -> Vec<Recorded> {
self.requests.lock().unwrap().clone()
}