Skip to content

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

test: wait for persisted turn state instead of fixed sleep

Steven Enamakel5126466bae89
diff --git a/crates/openhuman-core/src/flows/caps_host/agent_harness_tests.rs b/crates/openhuman-core/src/flows/caps_host/agent_harness_tests.rs
index 94ae67745c..cff78cb67f 100644
--- a/crates/openhuman-core/src/flows/caps_host/agent_harness_tests.rs
+++ b/crates/openhuman-core/src/flows/caps_host/agent_harness_tests.rs
@@ -2,14 +2,10 @@ use super::*;
#[test]
fn host_agent_context_takes_precedence_over_flow_dispatch_context() {
- let dispatch_context = crate::core::runtime::CoreContext::for_test(
- crate::core::runtime::DomainSet::none(),
- None,
- );
- let host_context = crate::core::runtime::CoreContext::for_test(
- crate::core::runtime::DomainSet::none(),
- None,
- );
+ let dispatch_context =
+ crate::core::runtime::CoreContext::for_test(crate::core::runtime::DomainSet::none(), None);
+ let host_context =
+ crate::core::runtime::CoreContext::for_test(crate::core::runtime::DomainSet::none(), None);
let dispatch = crate::core::runtime::DispatchCtx::new(dispatch_context);
let selected = host_core_context(&dispatch, Some(&host_context))
@@ -20,10 +16,8 @@ fn host_agent_context_takes_precedence_over_flow_dispatch_context() {
#[test]
fn an_unhosted_harness_uses_the_flow_dispatch_context() {
- let dispatch_context = crate::core::runtime::CoreContext::for_test(
- crate::core::runtime::DomainSet::none(),
- None,
- );
+ let dispatch_context =
+ crate::core::runtime::CoreContext::for_test(crate::core::runtime::DomainSet::none(), None);
let dispatch = crate::core::runtime::DispatchCtx::new(dispatch_context.clone());
let selected = host_core_context(&dispatch, None)
diff --git a/crates/openhuman-core/src/inference/auth_error_registry.rs b/crates/openhuman-core/src/inference/auth_error_registry.rs
index 5d93fe0c36..778841c8e3 100644
--- a/crates/openhuman-core/src/inference/auth_error_registry.rs
+++ b/crates/openhuman-core/src/inference/auth_error_registry.rs
@@ -89,7 +89,9 @@ fn record_in_scope(provider: &str, status: u16, scope: CurrentScope) -> bool {
origins.entry(provider.to_owned()).or_default().unscoped = true;
}
CurrentScope::Unresolved(error) => {
- log::warn!("[auth-errors] record provider={provider} skipped: scope unresolved ({error})");
+ log::warn!(
+ "[auth-errors] record provider={provider} skipped: scope unresolved ({error})"
+ );
}
}
changed
diff --git a/crates/openhuman-core/src/inference/auth_error_registry_tests.rs b/crates/openhuman-core/src/inference/auth_error_registry_tests.rs
index 7923b963d1..4fa42a6c60 100644
--- a/crates/openhuman-core/src/inference/auth_error_registry_tests.rs
+++ b/crates/openhuman-core/src/inference/auth_error_registry_tests.rs
@@ -39,12 +39,18 @@ fn an_unscoped_saas_auth_error_is_not_attributed_to_every_profile() {
record_in_scope("saas-unscoped-provider", 401, scope);
let workspace = tempfile::tempdir().expect("profile workspace");
- let (errors, has_unscoped) =
- snapshot_for_scope(workspace.path(), &workspace.path().join("config.toml"), None);
+ let (errors, has_unscoped) = snapshot_for_scope(
+ workspace.path(),
+ &workspace.path().join("config.toml"),
+ None,
+ );
assert!(errors.is_empty(), "an unscoped SaaS failure has no owner");
assert!(!has_unscoped, "a SaaS failure is never marked single-user");
assert!(
- !origins().lock().unwrap().contains_key("saas-unscoped-provider"),
+ !origins()
+ .lock()
+ .unwrap()
+ .contains_key("saas-unscoped-provider"),
"the unresolved call must not create a process-wide origin"
);
reset_for_tests();
diff --git a/tests/agent_harness_e2e.rs b/tests/agent_harness_e2e.rs
index 2fe054a311..14b6b2058d 100644
--- a/tests/agent_harness_e2e.rs
+++ b/tests/agent_harness_e2e.rs
@@ -2013,8 +2013,25 @@ async fn delegated_background_task_completion_flow_inner() {
"the child's best-effort result was never delivered to the parent; requests: {}",
dump()
);
- // Let the relay turn commit to the thread before the user replies.
- tokio::time::sleep(Duration::from_secs(1)).await;
+ // Queue exhaustion only proves that the delivery call took its scripted
+ // response. Wait for its persisted turn state to report completion before
+ // asking the parent to resume the thread.
+ let deadline = std::time::Instant::now() + Duration::from_secs(120);
+ loop {
+ let history = turn_state_history(&stack.rpc_base, 402, "thread-clarify").await;
+ let completed = history
+ .iter()
+ .filter(|turn| turn["lifecycle"] == "completed")
+ .count();
+ if completed >= 2 {
+ break;
+ }
+ assert!(
+ std::time::Instant::now() < deadline,
+ "delivery turn did not commit before turn 2; persisted turns: {history:#?}"
+ );
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ }
// ── turn 2: the user's answer resumes the thread ──
let request_id = send_web_chat(