The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(tools): correct plan exit test assertions
Steven Enamakel719b7ebfe033
diff --git a/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs b/crates/openhuman-core/src/agent/tools/plan_exit_tests.rsindex fa2da3defa..299bdec15c 100644--- a/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs+++ b/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs@@ -1,5 +1,78 @@use super::*;+struct ThreadContext(&'static str);+impl ToolRunContext for ThreadContext {+ fn thread_id(&self) -> Option<&str> {+ Some(self.0)+ }+}++/// `plan_exit` must not flip a thread to Build while a plan review is still+/// parked on it — flipping early would unlock every tool before the user+/// actually approved anything. Uses the process-global plan-review gate+/// (the same one `plan_exit` reads) parked on a dedicated thread id so this+/// test doesn't collide with others sharing the singleton.+#[tokio::test]+async fn plan_exit_does_not_flip_while_a_review_is_parked() {+ let thread_id = "plan-exit-parked-thread";+ crate::agent::tinyagents::run_mode::set_mode(+ thread_id,+ tinyagents_harness::middleware::RunMode::Plan,+ );+ let gate = crate::agent::plan_review::gate::global();+ let parked = tokio::spawn(async move {+ gate.request_review(+ Some(thread_id.to_string()),+ None,+ "Plan".into(),+ vec!["step".into()],+ None,+ )+ .await+ });+ // Let the review register as parked before racing plan_exit against it.+ tokio::time::sleep(std::time::Duration::from_millis(20)).await;++ let tool = PlanExitTool::new();+ let ctx = ThreadContext(thread_id);+ let result = tool+ .execute_with_context(+ json!({ "plan": "1. Do the thing" }),+ ToolCallOptions::default(),+ Some(&ctx),+ )+ .await+ .unwrap();+ assert!(!result.is_error);+ assert_eq!(+ crate::agent::tinyagents::run_mode::get_mode(thread_id),+ tinyagents_harness::middleware::RunMode::Plan,+ "plan_exit must not flip to Build while a review is still parked"+ );++ // Resolve the parked review so the spawned task and the gate's+ // bookkeeping don't leak past this test.+ assert!(crate::agent::plan_review::gate::global()+ .decide_by_thread(thread_id, PlanReviewResolution::Approve));+ let resolution = parked.await.unwrap();+ assert_eq!(resolution, PlanReviewResolution::Approve);++ // Now that the review is resolved (no longer parked), plan_exit flips.+ let result = tool+ .execute_with_context(+ json!({ "plan": "1. Do the thing" }),+ ToolCallOptions::default(),+ Some(&ctx),+ )+ .await+ .unwrap();+ assert!(!result.is_error);+ assert_eq!(+ crate::agent::tinyagents::run_mode::get_mode(thread_id),+ tinyagents_harness::middleware::RunMode::Build+ );+}+#[tokio::test]async fn plan_exit_emits_marker() {let tool = PlanExitTool::new();