Skip to content

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

test(core): align plan, skill, and thread fixtures

Steven Enamakelcdb4de6fae36
diff --git a/crates/openhuman-core/src/agent/plan_review/tool_tests.rs b/crates/openhuman-core/src/agent/plan_review/tool_tests.rs
index 376e6e0513..eee3ff49f7 100644
--- a/crates/openhuman-core/src/agent/plan_review/tool_tests.rs
+++ b/crates/openhuman-core/src/agent/plan_review/tool_tests.rs
@@ -1,5 +1,6 @@
use super::*;
use crate::agent::turn_origin::with_origin;
+use crate::security::approval::{ApprovalChatContext, APPROVAL_CHAT_CONTEXT};
#[tokio::test]
async fn non_interactive_origin_auto_approves() {
@@ -30,14 +31,20 @@ async fn interactive_turn_parks_until_resolved() {
client_id: "c-int".into(),
request_id: Some("req-int".into()),
},
- tool.execute(json!({ "summary": "plan", "steps": ["one"] })),
+ APPROVAL_CHAT_CONTEXT.scope(
+ ApprovalChatContext {
+ thread_id: "t-int".into(),
+ client_id: "c-int".into(),
+ request_id: Some("req-int".into()),
+ },
+ tool.execute(json!({ "summary": "plan", "steps": ["one"] })),
+ ),
);
- // An interactive turn must BLOCK on the gate rather than return
- // immediately — a short timeout elapses with no result (the parked
- // future is then dropped, and the gate cleans up).
- let res = tokio::time::timeout(std::time::Duration::from_millis(60), fut).await;
+ // The web channel supplies both task locals. One poll reaches the gate
+ // and must remain pending; no wall-clock timeout is needed to prove park.
+ tokio::pin!(fut);
assert!(
- res.is_err(),
+ matches!(futures::poll!(fut.as_mut()), std::task::Poll::Pending),
"interactive turn should park, not resolve immediately"
);
}
diff --git a/crates/openhuman-core/src/skills/bundled/mod_tests.rs b/crates/openhuman-core/src/skills/bundled/mod_tests.rs
index 40eac444fc..71e06ce2a1 100644
--- a/crates/openhuman-core/src/skills/bundled/mod_tests.rs
+++ b/crates/openhuman-core/src/skills/bundled/mod_tests.rs
@@ -18,21 +18,19 @@ const SAMPLE: BundledSkill = BundledSkill {
fn validate_relative_path(dir_name: &str, path: &str) -> Result<(), String> {
let path: &'static str = Box::leak(path.to_owned().into_boxed_str());
+ let mut files = vec![BundledFile {
+ path: "WORKFLOW.md",
+ contents: "---\nname: test\ndescription: test\n---\n",
+ }];
+ if path != "WORKFLOW.md" {
+ files.push(BundledFile {
+ path,
+ contents: "body",
+ });
+ }
let skill = BundledSkill {
dir_name: Box::leak(dir_name.to_owned().into_boxed_str()),
- files: Box::leak(
- vec![
- BundledFile {
- path: "WORKFLOW.md",
- contents: "---\nname: test\ndescription: test\n---\n",
- },
- BundledFile {
- path,
- contents: "body",
- },
- ]
- .into_boxed_slice(),
- ),
+ files: Box::leak(files.into_boxed_slice()),
};
skill.validate()
}
diff --git a/crates/openhuman-core/src/threads/ops/live_state_tests.rs b/crates/openhuman-core/src/threads/ops/live_state_tests.rs
index 9f70e8c86c..471270462c 100644
--- a/crates/openhuman-core/src/threads/ops/live_state_tests.rs
+++ b/crates/openhuman-core/src/threads/ops/live_state_tests.rs
@@ -57,7 +57,7 @@ async fn goal_get_reads_back_a_stored_goal() {
.await
.unwrap();
let empty_json = empty.into_cli_compatible_json().unwrap();
- assert!(empty_json["result"]["goal"].is_null(), "{empty_json}");
+ assert!(empty_json["data"]["goal"].is_null(), "{empty_json}");
let dir = crate::config::Config::load_or_init()
.await
@@ -73,8 +73,8 @@ async fn goal_get_reads_back_a_stored_goal() {
.await
.unwrap();
let filled_json = filled.into_cli_compatible_json().unwrap();
- let goal = &filled_json["result"]["goal"];
- assert_eq!(goal["objective"], "ship it");
+ let goal = &filled_json["data"]["goal"];
+ assert_eq!(goal["objective"], "ship it", "{filled_json}");
assert_eq!(goal["status"], "active");
}
@@ -94,7 +94,7 @@ async fn todos_get_reads_back_what_the_todo_tool_wrote() {
.await
.unwrap();
let empty_json = empty.into_cli_compatible_json().unwrap();
- assert!(empty_json["result"]["todos"].as_array().unwrap().is_empty());
+ assert!(empty_json["data"]["todos"].as_array().unwrap().is_empty());
let scope = crate::agent::todos::ops::TodoScope::Session {
id: "thread-todos-live".to_string(),
@@ -113,7 +113,9 @@ async fn todos_get_reads_back_what_the_todo_tool_wrote() {
.await
.unwrap();
let filled_json = filled.into_cli_compatible_json().unwrap();
- let todos = filled_json["result"]["todos"].as_array().unwrap();
+ let todos = filled_json["data"]["todos"]
+ .as_array()
+ .unwrap_or_else(|| panic!("missing todos in {filled_json}"));
assert_eq!(todos.len(), 1);
assert_eq!(todos[0]["content"], "write tests");
}