Skip to content

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

fix(hooks): stop reporting subagentStop as wired when nothing fires it

Nguyen Thanh Dat368bdaefaad9
diff --git a/src/openhuman/hooks/hooks_tests.rs b/src/openhuman/hooks/hooks_tests.rs
index 9f2a651641..3359c39540 100644
--- a/src/openhuman/hooks/hooks_tests.rs
+++ b/src/openhuman/hooks/hooks_tests.rs
@@ -490,3 +490,31 @@ fn a_bare_command_name_is_not_second_guessed() {
let loaded = config::load(None, Some(dir.path()));
assert!(loaded.warnings.is_empty(), "{:?}", loaded.warnings);
}
+
+/// `subagentStart` has a call site in `subagent_runner`; `subagentStop` does
+/// not — `ops::subagent_stopped` is never called. Reporting it as wired is the
+/// one outcome `is_wired`'s own documentation calls the worst this system can
+/// produce: the author believes a policy is enforced and nothing says otherwise.
+#[test]
+fn subagent_stop_is_reported_as_not_yet_fired() {
+ assert!(
+ HookEvent::SubagentStart.is_wired(),
+ "subagentStart is fired from subagent_runner"
+ );
+ assert!(
+ !HookEvent::SubagentStop.is_wired(),
+ "nothing calls ops::subagent_stopped yet"
+ );
+
+ let parsed = config::parse_one(
+ &PathBuf::from("/tmp/hooks.json"),
+ HookLayer::Project,
+ r#"{"version": 1, "hooks": {"subagentStop": [{"command": "x"}]}}"#,
+ );
+ assert_eq!(parsed.for_event(HookEvent::SubagentStop).len(), 1);
+ assert!(
+ parsed.warnings.iter().any(|w| w.contains("never run")),
+ "{:?}",
+ parsed.warnings
+ );
+}
diff --git a/src/openhuman/hooks/types.rs b/src/openhuman/hooks/types.rs
index 47a55268fc..77ca79f591 100644
--- a/src/openhuman/hooks/types.rs
+++ b/src/openhuman/hooks/types.rs
@@ -182,6 +182,11 @@ impl HookEvent {
// Reasoning blocks are not projected onto the post-turn seam
// the bridge rides.
| HookEvent::AfterAgentThought
+ // `ops::subagent_stopped` exists and is complete, but nothing
+ // calls it: `subagent_runner` fires the start side and returns
+ // from a dozen places without a stop. Until one lands, a
+ // configured `subagentStop` hook never runs.
+ | HookEvent::SubagentStop
)
}