Skip to content

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

refactor(agent): move stop hook types to tinyagents-hooks

Steven Enamakel2ac87442497e
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.toml
index deff9750d2..4af0a4c819 100644
--- a/crates/openhuman-core/Cargo.toml
+++ b/crates/openhuman-core/Cargo.toml
@@ -134,6 +134,7 @@ tinyflows-import = { path = "../../vendor/tinyflows/crates/tinyflows-import", de
# of vendor/tinyagents at vendor/tinyagents/vendor/tinyinference) — declared
# below as its own path dependency for the same "one checkout, one type
# identity" reason `tinytools` is.
+tinyagents-hooks = { path = "../../vendor/tinyagents/crates/tinyagents-hooks" }
tinyagents-harness = { path = "../../vendor/tinyagents/crates/tinyagents-harness", features = [
"sqlite",
"multimodal",
diff --git a/crates/openhuman-core/src/agent/cost_tests.rs b/crates/openhuman-core/src/agent/cost_tests.rs
index 4ebf70afca..3cf7e4a903 100644
--- a/crates/openhuman-core/src/agent/cost_tests.rs
+++ b/crates/openhuman-core/src/agent/cost_tests.rs
@@ -9,7 +9,7 @@ fn counts(input: u64, output: u64, cached: u64) -> BilledUsage {
/// harness `ModelResponse` (the host's wire form, charge in `raw`) recorded by
/// the harness `StopHookMetrics` impl, priced through the catalog lookup.
fn record(turn: &mut tinyagents_harness::cost::TurnCost, model: &str, usage: &BilledUsage) {
- use tinyagents_harness::middleware::StopHookMetrics as _;
+ use tinyagents_hooks::stop::StopHookMetrics as _;
let response = crate::agent::tinyagents::model::native_model_response_for_request(
&crate::inference::provider::ChatResponse {
text: Some("ok".into()),
diff --git a/crates/openhuman-core/src/agent/goals/runtime.rs b/crates/openhuman-core/src/agent/goals/runtime.rs
index 7c43f1c910..c26d578db0 100644
--- a/crates/openhuman-core/src/agent/goals/runtime.rs
+++ b/crates/openhuman-core/src/agent/goals/runtime.rs
@@ -27,7 +27,7 @@ use tinyagents_graph::goals::{BudgetVerdict, GoalBudgetGuard, ThreadGoal, Thread
use super::store::{self, goals_store};
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
-use tinyagents_harness::middleware::{StopDecision, StopHook, TurnState};
+use tinyagents_hooks::stop::{StopDecision, StopHook, TurnState};
/// Load the goal for an explicitly supplied chat thread.
pub async fn load_for_thread(workspace_dir: &Path, thread_id: Option<&str>) -> Option<ThreadGoal> {
diff --git a/crates/openhuman-core/src/agent/hooks_scope.rs b/crates/openhuman-core/src/agent/hooks_scope.rs
index 153f398516..336b803a17 100644
--- a/crates/openhuman-core/src/agent/hooks_scope.rs
+++ b/crates/openhuman-core/src/agent/hooks_scope.rs
@@ -20,7 +20,7 @@ pub struct HookScope {
tools: Vec<Arc<dyn ToolHook>>,
post_turn: Vec<Arc<dyn PostTurnHook>>,
stop:
- Vec<Arc<dyn tinyagents_harness::middleware::StopHook<tinyagents_harness::cost::TurnCost>>>,
+ Vec<Arc<dyn tinyagents_hooks::stop::StopHook<tinyagents_harness::cost::TurnCost>>>,
}
impl HookScope {
@@ -37,7 +37,7 @@ impl HookScope {
/// Append a usage observer/budget policy checked after each model call.
pub fn push_stop(
&mut self,
- hook: Arc<dyn tinyagents_harness::middleware::StopHook<tinyagents_harness::cost::TurnCost>>,
+ hook: Arc<dyn tinyagents_hooks::stop::StopHook<tinyagents_harness::cost::TurnCost>>,
) {
self.stop.push(hook);
}
@@ -55,7 +55,7 @@ impl HookScope {
/// The scope's own stop policies, in registration order.
pub fn stop_hooks(
&self,
- ) -> &[Arc<dyn tinyagents_harness::middleware::StopHook<tinyagents_harness::cost::TurnCost>>]
+ ) -> &[Arc<dyn tinyagents_hooks::stop::StopHook<tinyagents_harness::cost::TurnCost>>]
{
&self.stop
}
diff --git a/crates/openhuman-core/src/agent/stop_hooks.rs b/crates/openhuman-core/src/agent/stop_hooks.rs
index 02116dab85..4853550991 100644
--- a/crates/openhuman-core/src/agent/stop_hooks.rs
+++ b/crates/openhuman-core/src/agent/stop_hooks.rs
@@ -22,7 +22,7 @@
use async_trait::async_trait;
use tinyagents_harness::cost::TurnCost;
-use tinyagents_harness::middleware::{StopDecision, StopHook, TurnState};
+use tinyagents_hooks::stop::{StopDecision, StopHook, TurnState};
/// Stop a turn when its cumulative cost reaches the configured USD cap.
#[derive(Debug, Clone, Copy)]
diff --git a/crates/openhuman-core/src/agent/tinyagents/budget_stop_turn_tests.rs b/crates/openhuman-core/src/agent/tinyagents/budget_stop_turn_tests.rs
index cf125727aa..09e54d093d 100644
--- a/crates/openhuman-core/src/agent/tinyagents/budget_stop_turn_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/budget_stop_turn_tests.rs
@@ -6,7 +6,7 @@ use crate::agent::stop_hooks::BudgetStopHook;
use crate::agent::tinyagents::TurnModelSource;
use async_trait::async_trait;
use std::sync::Arc;
-use tinyagents_harness::middleware::{StopDecision, StopHook, TurnState};
+use tinyagents_hooks::stop::{StopDecision, StopHook, TurnState};
use tinyinference_llm::model::{ChatModel, ModelProfile, ModelRequest, ModelResponse};
use tinyinference_llm::tool::ToolCall;
use tinyinference_llm::usage::Usage;
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
index 6d45f0535b..54cf971ea1 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -24,7 +24,7 @@ use crate::agent::tinyagents::{
};
use crate::agent::turn_origin::AgentTurnOrigin;
use tinyagents_definition::SandboxMode;
-use tinyagents_harness::middleware::StopHook;
+use tinyagents_hooks::stop::StopHook;
use tinyagents_harness::store::InMemoryStore as ToolResultArtifactIndexStore;
use tinyagents_harness::turn_outcome::{ToolCallOutcome, ToolOutcomeSink};
use tinyinference_llm::model::ResolvedModelRoute;
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
index c344262d55..b0ff5b9dbb 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -10,13 +10,14 @@ use tinyagents_harness::context::RunContext;
use tinyagents_harness::error::Result as TaResult;
use tinyagents_harness::middleware::{
call_effect, dispatch_target, is_repeat_call_exempt, repeat_guard_marker, CallEffect,
- Middleware, StopLatch, ToolFactsLookup, ToolInvocationIdentity,
+ Middleware, ToolFactsLookup, ToolInvocationIdentity,
};
use tinyagents_harness::no_progress::{
classified_step, clear_recovered, ClassifiedFailureTracker, ClassifiedStep, FailurePolicy,
NoProgress, NoProgressTracker, RecoverableFailureLadder, ToolAttempt,
};
use tinyagents_harness::steering::SteeringHandle;
+use tinyagents_hooks::stop::StopLatch;
use tinyinference_llm::tool::ToolCall as TaToolCall;
use tinytools::ToolResult as TaToolResult;
diff --git a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs
index 3bf907c03f..177651846f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs
@@ -2,8 +2,8 @@
use std::sync::Arc;
use tinyagents_harness::cost::TurnCost;
-use tinyagents_harness::middleware::library::StopHookMiddleware;
-use tinyagents_harness::middleware::StopHook;
+use tinyagents_hooks::stop::StopHookMiddleware;
+use tinyagents_hooks::stop::StopHook;
use tinyagents_harness::steering::SteeringHandle;
/// Install product policies and preserve the host-facing halt summary.
@@ -34,7 +34,7 @@ pub(super) fn install(
fn record_halt_summary(
halt_summary: &tinyagents_harness::turn_outcome::HaltSummarySlot,
- report: &tinyagents_harness::middleware::library::StopReport,
+ report: &tinyagents_hooks::stop::StopReport,
) {
*halt_summary
.lock()
diff --git a/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs b/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs
index 2396e0a76b..f11d96cc02 100644
--- a/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs
@@ -13,7 +13,7 @@ fn a_poisoned_halt_summary_does_not_abort_stop_reporting() {
.is_err());
record_halt_summary(
&slot,
- &tinyagents_harness::middleware::library::StopReport {
+ &tinyagents_hooks::stop::StopReport {
hook: "budget".into(),
reason: "limit reached".into(),
iteration: 2,
diff --git a/crates/openhuman-embed/Cargo.toml b/crates/openhuman-embed/Cargo.toml
index 8c7ba0d645..7c2e426a59 100644
--- a/crates/openhuman-embed/Cargo.toml
+++ b/crates/openhuman-embed/Cargo.toml
@@ -77,6 +77,7 @@ tinymcp-bus = { path = "../../vendor/tinymcp/crates/tinymcp-bus" }
# The session store port (`SessionStoreProvider`) a host implements to keep
# conversations in its own database, and the in-memory provider; same path as
# the core's so one copy resolves.
+tinyagents-hooks = { path = "../../vendor/tinyagents/crates/tinyagents-hooks" }
tinyagents-harness = { path = "../../vendor/tinyagents/crates/tinyagents-harness", default-features = false }
tinyagents-definition = { path = "../../vendor/tinyagents/crates/tinyagents-definition" }
tinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session" }
diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rs
index c8b15b13d6..84ff1e180a 100644
--- a/crates/openhuman-embed/src/lib.rs
+++ b/crates/openhuman-embed/src/lib.rs
@@ -220,9 +220,9 @@ pub mod seams {
pub use openhuman_core::agent::stop_hooks::BudgetStopHook;
pub use tinyagents_harness::cost::TurnCost;
pub use tinyagents_harness::middleware::{PolicyDecision, ToolCallPolicy};
- pub use tinyagents_harness::middleware::{StopDecision, StopHook};
+ pub use tinyagents_hooks::stop::{StopDecision, StopHook};
/// Product cost snapshot passed to harness-owned stop policies.
- pub type TurnState<'a> = tinyagents_harness::middleware::TurnState<'a, TurnCost>;
+ pub type TurnState<'a> = tinyagents_hooks::stop::TurnState<'a, TurnCost>;
pub use openhuman_core::core::all::{ControllerExtension, DomainGroup};
pub use openhuman_core::core::server_launcher::{HostBoot, ServeRequest, ServerLauncher};
pub use openhuman_core::security::SecurityPolicy;
diff --git a/vendor/tinyagents b/vendor/tinyagents
index b438bad26a..4c2ccf1313 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit b438bad26a8677dd9041d040e9528936436d4265
+Subproject commit 4c2ccf13132c57446fc7c25eeb8ac2abe6e45085