Skip to content

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

fix(hooks): forward the resolved working directory to configured hooks

Steven Enamakel6bf29639e91e
diff --git a/crates/openhuman-core/src/hooks/bridge.rs b/crates/openhuman-core/src/hooks/bridge.rs
index 254037a4f7..30565b5861 100644
--- a/crates/openhuman-core/src/hooks/bridge.rs
+++ b/crates/openhuman-core/src/hooks/bridge.rs
@@ -82,7 +82,10 @@ fn identity_from_tool(context: &ToolHookContext) -> TurnIdentity {
TurnIdentity {
session_id: context.session_id.clone(),
agent_id: context.agent_id.clone(),
- cwd: string_field(&context.arguments, "cwd"),
+ cwd: context
+ .cwd
+ .as_ref()
+ .map(|cwd| cwd.to_string_lossy().into_owned()),
..TurnIdentity::default()
}
}
diff --git a/crates/openhuman-core/src/hooks/bridge_tests.rs b/crates/openhuman-core/src/hooks/bridge_tests.rs
index e5f0d3a1e4..caf2a0ab86 100644
--- a/crates/openhuman-core/src/hooks/bridge_tests.rs
+++ b/crates/openhuman-core/src/hooks/bridge_tests.rs
@@ -113,3 +113,18 @@ fn timeout_text_classifies_as_a_timeout_failure() {
);
assert_eq!(classify_failure("something else"), "error");
}
+
+#[test]
+fn configured_hook_identity_uses_the_resolved_working_directory() {
+ let mut ctx = context("shell", serde_json::json!({"command": "pwd"}));
+ ctx.cwd = Some(std::path::PathBuf::from("/resolved/workspace"));
+ assert_eq!(
+ identity_from_tool(&ctx).cwd.as_deref(),
+ Some("/resolved/workspace")
+ );
+ ctx.arguments["cwd"] = serde_json::json!("relative/argument");
+ assert_eq!(
+ identity_from_tool(&ctx).cwd.as_deref(),
+ Some("/resolved/workspace")
+ );
+}