Skip to content

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

test: update relay and progress tests for accessor-based event API

Steven Enamakelbd5bcdf71297
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
index 14d3e8a61a..5c3d41b7a1 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
@@ -211,11 +211,21 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {
}
}
assert_eq!(outbound.len(), 2, "one channel_outbound per reply");
- assert!(outbound.iter().all(|e| e.event == CHANNEL_OUTBOUND_EVENT));
- assert!(outbound.iter().all(|e| e.thread_id == thread));
- assert_eq!(outbound[0].request_id, "req-m1");
- assert_eq!(outbound[0].full_response.as_deref(), Some("answer 1"));
- assert_eq!(outbound[0].structured.as_ref().unwrap()["chat_id"], "-100");
+ assert!(outbound
+ .iter()
+ .all(|event| event.event_name() == CHANNEL_OUTBOUND_EVENT));
+ assert!(outbound
+ .iter()
+ .all(|event| event.context().thread_id == thread));
+ assert_eq!(outbound[0].context().request_id, "req-m1");
+ assert!(matches!(
+ outbound[0].wire_event(),
+ crate::web_chat::WebChannelEvent::ChannelOutbound {
+ full_response: Some(text),
+ structured: Some(structured),
+ ..
+ } if text == "answer 1" && structured["chat_id"] == "-100"
+ ));
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/web_chat/progress_tests.rs b/crates/openhuman-core/src/web_chat/progress_tests.rs
index 89e8346ac4..1a1c860000 100644
--- a/crates/openhuman-core/src/web_chat/progress_tests.rs
+++ b/crates/openhuman-core/src/web_chat/progress_tests.rs
@@ -129,7 +129,10 @@ async fn tool_call_completed_forwards_real_output_on_tool_result() {
let event = tokio::time::timeout(std::time::Duration::from_secs(5), async {
loop {
match bus.recv().await {
- Ok(ev) if ev.thread_id == "thread-out" && ev.event == "tool_result" => {
+ Ok(ev)
+ if ev.context().thread_id == "thread-out"
+ && ev.event_name() == "tool_result" =>
+ {
return ev;
}
Ok(_) => continue,
@@ -140,9 +143,15 @@ async fn tool_call_completed_forwards_real_output_on_tool_result() {
.await
.expect("tool_result within timeout");
- assert_eq!(event.output.as_deref(), Some("real payload"));
- assert_eq!(event.success, Some(true));
- assert_eq!(event.tool_call_id.as_deref(), Some("call-1"));
+ assert!(matches!(
+ event.wire_event(),
+ crate::web_chat::WebChannelEvent::ToolResult {
+ output: Some(output),
+ success: Some(true),
+ tool_call_id: Some(call_id),
+ ..
+ } if output == "real payload" && call_id == "call-1"
+ ));
}
fn drain_test_config(tmp: &tempfile::TempDir) -> Config {