Skip to content

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

chore(agent): remove unused hooks module

Steven Enamakel2280216155b2
diff --git a/crates/openhuman-core/src/agent/hooks.rs b/crates/openhuman-core/src/agent/hooks.rs
index 8eb5325df9..9346a2e807 100644
--- a/crates/openhuman-core/src/agent/hooks.rs
+++ b/crates/openhuman-core/src/agent/hooks.rs
@@ -38,13 +38,23 @@ pub fn replace_embedder_post_turn_hook(name: &str, hook: Option<Arc<dyn PostTurn
}
}
-/// Snapshot hooks supplied by the embedding host.
+/// Snapshot hooks supplied by the embedding host, for the calling task's
+/// ambient context. Library callers outside a turn use this; the core passes
+/// its own context to [`embedder_post_turn_hooks_in`].
pub fn embedder_post_turn_hooks() -> Vec<Arc<dyn PostTurnHook>> {
+ embedder_post_turn_hooks_in(&crate::core::runtime::DispatchCtx::ambient())
+}
+
+/// Snapshot hooks supplied by the embedding host, plus the agent-local ones of
+/// the agent `ctx` runs for.
+pub fn embedder_post_turn_hooks_in(
+ ctx: &crate::core::runtime::DispatchCtx,
+) -> Vec<Arc<dyn PostTurnHook>> {
let mut hooks = EMBEDDER_POST_TURN_HOOKS
.lock()
.expect("embedder post-turn hooks poisoned")
.clone();
- if let Some(local) = crate::core::runtime::CoreContext::current_host_overrides() {
+ if let Some(local) = ctx.host_overrides() {
hooks.extend(local.post_turn_hooks());
}
hooks
@@ -275,13 +285,22 @@ pub fn replace_embedder_tool_hook(name: &str, hook: Option<Arc<dyn ToolHook>>) {
}
}
-/// Snapshot tool hooks supplied by the embedding host.
+/// Snapshot tool hooks supplied by the embedding host, for the calling task's
+/// ambient context. See [`embedder_post_turn_hooks`].
pub fn embedder_tool_hooks() -> Vec<Arc<dyn ToolHook>> {
+ embedder_tool_hooks_in(&crate::core::runtime::DispatchCtx::ambient())
+}
+
+/// Snapshot tool hooks supplied by the embedding host, plus the agent-local
+/// ones of the agent `ctx` runs for.
+pub fn embedder_tool_hooks_in(
+ ctx: &crate::core::runtime::DispatchCtx,
+) -> Vec<Arc<dyn ToolHook>> {
let mut hooks = EMBEDDER_TOOL_HOOKS
.lock()
.expect("embedder tool hooks poisoned")
.clone();
- if let Some(local) = crate::core::runtime::CoreContext::current_host_overrides() {
+ if let Some(local) = ctx.host_overrides() {
hooks.extend(local.tool_hooks());
}
hooks