Skip to content

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

refactor(hooks): migrate command hooks to tinyagents_hooks

Steven Enamakeld6239772b2da
diff --git a/crates/openhuman-core/src/hooks/host.rs b/crates/openhuman-core/src/hooks/host.rs
index 834df591af..8f9888595c 100644
--- a/crates/openhuman-core/src/hooks/host.rs
+++ b/crates/openhuman-core/src/hooks/host.rs
@@ -10,7 +10,7 @@ use crate::core::runtime::DispatchCtx;
use std::sync::{Arc, LazyLock};
use async_trait::async_trait;
-use tinyagents_runtime::command_hooks::{
+use tinyagents_hooks::command::{
config, HookConfig, HookEngine, HookEnvironment, PromptEvaluator,
};
diff --git a/crates/openhuman-core/src/hooks/mod.rs b/crates/openhuman-core/src/hooks/mod.rs
index 9b27b7e6da..8365d6c906 100644
--- a/crates/openhuman-core/src/hooks/mod.rs
+++ b/crates/openhuman-core/src/hooks/mod.rs
@@ -25,7 +25,6 @@
//! turn's latency, observing does not) are documented with it in
//! `tinyagents_runtime::command_hooks`.
-pub mod bridge;
pub mod host;
pub mod ops;
pub mod prompt_eval;
diff --git a/crates/openhuman-core/src/hooks/ops.rs b/crates/openhuman-core/src/hooks/ops.rs
index 0c9bec1b16..eb57246565 100644
--- a/crates/openhuman-core/src/hooks/ops.rs
+++ b/crates/openhuman-core/src/hooks/ops.rs
@@ -11,10 +11,10 @@ use crate::core::runtime::DispatchCtx;
use std::path::PathBuf;
use std::time::Duration;
-use tinyagents_runtime::command_hooks::context::{
+use tinyagents_hooks::command::context::{
build_input, set_host_context, HostContext, TurnIdentity,
};
-use tinyagents_runtime::command_hooks::types::{
+use tinyagents_hooks::command::types::{
CompactPayload, HookEvent, HookPayload, PromptPayload, SessionPayload, SubagentPayload,
TextPayload,
};
@@ -32,7 +32,7 @@ pub async fn init(ctx: &DispatchCtx, config: &crate::config::schema::Config) {
});
if !settings.enabled {
- super::bridge::ConfiguredHookBridge::uninstall();
+ crate::agent::hooks::replace_embedder_tool_hook("configured_hooks", None);
super::host::engine()
.install(tinyagents_runtime::command_hooks::HookConfig::default())
.await;
@@ -52,10 +52,13 @@ pub async fn init(ctx: &DispatchCtx, config: &crate::config::schema::Config) {
if loaded.is_empty() {
// Nothing configured: keep the bridge out of the harness entirely so an
// unconfigured host pays not even a task-local lookup per tool call.
- super::bridge::ConfiguredHookBridge::uninstall();
+ crate::agent::hooks::replace_embedder_tool_hook("configured_hooks", None);
return;
}
- super::bridge::ConfiguredHookBridge::install();
+ crate::agent::hooks::replace_embedder_tool_hook(
+ "configured_hooks",
+ Some(std::sync::Arc::new(super::host::engine().clone())),
+ );
}
fn workspace_roots(config: &crate::config::schema::Config) -> Vec<PathBuf> {