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\n\nis_wired() carries its own rule:\n\n Move an event here as its call site lands; do not flip one\n optimistically.\n\nSubagentStop is not in the list, so the loader treats a configured\nsubagentStop hook as live and says nothing. It is not live. The only\ndispatch of HookEvent::SubagentStop is inside ops::subagent_stopped, and\nthat function has no caller anywhere in the tree:\n\n grep -rn 'subagent_stopped(' src/ | grep -v src/openhuman/hooks/\n -> (no matches)\n\nsubagent_starting, by contrast, is called from subagent_runner's spawn\ngate. The start side landed; the stop side did not.\n\nThe result is the exact outcome the doc comment above is_wired calls the\nworst this system can produce: hooks.test fires the event so it looks\nwired, the loader stays quiet, and in a real run the hook never runs -\nthe author believes a policy is enforced and nothing says otherwise.\n\nMove SubagentStop into the not-yet-fired set so the loader warns. Wiring\nthe call site is the real fix; it belongs in subagent_runner next to the\nstart hook, and picking the right place among that function's many return\npaths is a change I would rather not guess at. Until then the honest\nanswer is a warning.\n

Nguyen Thanh Dat5047bd0ae9e3
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
)
}