Skip to content

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

refactor(agent): use tinyagents hook traits instead of local ones

Steven Enamakele0d689178a6a
diff --git a/crates/openhuman-core/src/agent/host_overrides_tests.rs b/crates/openhuman-core/src/agent/host_overrides_tests.rs
index 83746a3311..2c270420db 100644
--- a/crates/openhuman-core/src/agent/host_overrides_tests.rs
+++ b/crates/openhuman-core/src/agent/host_overrides_tests.rs
@@ -7,7 +7,7 @@ impl PostTurnHook for Hook {
fn name(&self) -> &str {
"local"
}
- async fn on_turn_complete(&self, _: &crate::agent::hooks::TurnContext) -> anyhow::Result<()> {
+ async fn on_turn_complete(&self, _: &tinyagents_harness::host::TurnSummary) -> anyhow::Result<()> {
Ok(())
}
}
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 15efa1e926..0ccb4bf7a6 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -379,7 +379,7 @@ impl OpenHumanSessionHost {
},
None => SystemPromptBuilder::with_defaults(),
};
- let post_turn_hooks: Vec<Arc<dyn crate::agent::hooks::PostTurnHook>> =
+ let post_turn_hooks: Vec<Arc<dyn tinyagents_harness::host::LearningSink>> =
crate::agent::hooks::embedder_post_turn_hooks_in(ctx);
// Best-effort prewarm from the shared Composio cache. This avoids
diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
index 6a8089972e..88781ae22a 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -231,7 +231,7 @@ impl SessionHostBuilder {
/// Sets the post-turn hooks to be executed after each turn.
pub fn post_turn_hooks(
mut self,
- hooks: Vec<Arc<dyn crate::agent::hooks::PostTurnHook>>,
+ hooks: Vec<Arc<dyn tinyagents_harness::host::LearningSink>>,
) -> Self {
self.post_turn_hooks = hooks;
self
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
index 8470a2dde6..ba3ffe75a9 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
@@ -128,7 +128,7 @@ pub(super) struct TurnIdentity {
/// finalize steps, with goal accounting deferred to a fenced background task.
pub(super) async fn finalize_committed_turn(
state: &std::sync::Mutex<super::OpenHumanSessionState>,
- post_turn_hooks: &[std::sync::Arc<dyn crate::agent::hooks::PostTurnHook>],
+ post_turn_hooks: &[std::sync::Arc<dyn tinyagents_harness::host::LearningSink>],
identity: TurnIdentity,
receipt: tinyagents_runtime::CommitReceipt<crate::agent::tinyagents::host::OpenHumanRunContext>,
) {
diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rs
index dbc5209022..55a2cdf0cb 100644
--- a/crates/openhuman-core/src/agent/session_host/types.rs
+++ b/crates/openhuman-core/src/agent/session_host/types.rs
@@ -6,7 +6,7 @@
//! `impl OpenHumanSessionHost`/`impl SessionHostBuilder` can see them without the whole
//! crate gaining field access.
-use crate::agent::hooks::PostTurnHook;
+use tinyagents_harness::host::LearningSink;
use crate::agent::prompts::SystemPromptBuilder;
use crate::agent::tinyagents::TurnModelSource;
use crate::progress::AgentProgress;
diff --git a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
index 41de2d2627..838f6c0d05 100644
--- a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
@@ -52,7 +52,7 @@ pub(crate) struct LiveToolSurface {
pub(crate) has_thread: bool,
/// The session's agent/turn tool callbacks, registered after the
/// runtime's global ones.
- pub(crate) tool_hooks: Vec<Arc<dyn crate::agent::hooks::ToolHook>>,
+ pub(crate) tool_hooks: Vec<Arc<dyn tinyagents_hooks::tool::ToolHook>>,
/// The context the session acts under (its embedder hooks come from it).
pub(crate) dispatch: crate::core::runtime::DispatchCtx,
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_memory_and_hooks_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_memory_and_hooks_tests.rs
index 85236009ec..39bfa5e303 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_memory_and_hooks_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_memory_and_hooks_tests.rs
@@ -107,29 +107,29 @@ fn nested_call(name: &str) -> TaToolCall {
}
/// A hook whose pre-tool decision is fixed, to exercise every arm.
-struct FixedDecisionHook(crate::agent::hooks::ToolHookDecision);
+struct FixedDecisionHook(tinyagents_hooks::tool::ToolHookDecision);
#[async_trait]
-impl crate::agent::hooks::ToolHook for FixedDecisionHook {
+impl tinyagents_hooks::tool::ToolHook for FixedDecisionHook {
fn name(&self) -> &str {
"fixed"
}
async fn before_tool(
&self,
- _context: &crate::agent::hooks::ToolHookContext,
+ _context: &tinyagents_hooks::tool::ToolHookContext,
) -> anyhow::Result<()> {
Ok(())
}
async fn after_tool(
&self,
- _context: &crate::agent::hooks::ToolHookContext,
+ _context: &tinyagents_hooks::tool::ToolHookContext,
) -> anyhow::Result<()> {
Ok(())
}
async fn before_tool_decision(
&self,
- _context: &crate::agent::hooks::ToolHookContext,
- ) -> crate::agent::hooks::ToolHookDecision {
+ _context: &tinyagents_hooks::tool::ToolHookContext,
+ ) -> tinyagents_hooks::tool::ToolHookDecision {
self.0.clone()
}
}
@@ -167,7 +167,7 @@ async fn embedder_tool_hooks_nested_call_honours_a_veto() {
#[tokio::test]
async fn embedder_tool_hooks_nested_call_refuses_ask_and_rewrite() {
- use crate::agent::hooks::ToolHookDecision;
+ use tinyagents_hooks::tool::ToolHookDecision;
for decision in [
ToolHookDecision::Ask("confirm".into()),
ToolHookDecision::ProceedWith(json!({"path": "."})),
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs
index f339ba9231..b020cdd406 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs
@@ -353,13 +353,13 @@ struct RecordingToolHook {
}
#[async_trait]
-impl crate::agent::hooks::ToolHook for RecordingToolHook {
+impl tinyagents_hooks::tool::ToolHook for RecordingToolHook {
fn name(&self) -> &str {
self.name
}
async fn before_tool(
&self,
- context: &crate::agent::hooks::ToolHookContext,
+ context: &tinyagents_hooks::tool::ToolHookContext,
) -> anyhow::Result<()> {
self.pre
.lock()
@@ -372,7 +372,7 @@ impl crate::agent::hooks::ToolHook for RecordingToolHook {
}
async fn after_tool(
&self,
- context: &crate::agent::hooks::ToolHookContext,
+ context: &tinyagents_hooks::tool::ToolHookContext,
) -> anyhow::Result<()> {
self.post.lock().unwrap().push((
context.tool_name.clone(),