The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(agent): use harness StopHook trait in core and embed
Steven Enamakel3286da0e1cd6
diff --git a/crates/openhuman-core/src/agent/hooks_scope.rs b/crates/openhuman-core/src/agent/hooks_scope.rsindex d11afe110e..8e5b752cdc 100644--- a/crates/openhuman-core/src/agent/hooks_scope.rs+++ b/crates/openhuman-core/src/agent/hooks_scope.rs@@ -18,7 +18,7 @@ tokio::task_local! {pub struct HookScope {tools: Vec<Arc<dyn ToolHook>>,post_turn: Vec<Arc<dyn PostTurnHook>>,- stop: Vec<Arc<dyn crate::agent::stop_hooks::StopHook<crate::agent::cost::TurnCost>>>,+ stop: Vec<Arc<dyn tinyagents_harness::middleware::StopHook<crate::agent::cost::TurnCost>>>,}impl HookScope {@@ -35,7 +35,7 @@ impl HookScope {/// Append a usage observer/budget policy checked after each model call.pub fn push_stop(&mut self,- hook: Arc<dyn crate::agent::stop_hooks::StopHook<crate::agent::cost::TurnCost>>,+ hook: Arc<dyn tinyagents_harness::middleware::StopHook<crate::agent::cost::TurnCost>>,) {self.stop.push(hook);}diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rsindex 65e5ac5f6b..60b0bab5be 100644--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs@@ -59,7 +59,9 @@ pub(super) fn assemble_turn_harness(context_window: Option<u64>,early_exit_tools: &[&str],context_mw: TurnContextMiddleware,- stop_hooks: Vec<Arc<dyn crate::agent::stop_hooks::StopHook<crate::agent::cost::TurnCost>>>,+ stop_hooks: Vec<+ Arc<dyn tinyagents_harness::middleware::StopHook<crate::agent::cost::TurnCost>>,+ >,tool_policy: Option<ToolPolicyEnforcement>,required_capabilities: Option<CapabilitySet>,deterministic_cacheable: bool,diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rsindex 7f9974823d..2dd833cb6a 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs@@ -19,13 +19,13 @@ use tokio::sync::mpsc::Sender;use crate::agent::harness::definition::SandboxMode;use crate::agent::harness::fork_context::{AgentContextPreparedSource, ParentExecutionContext};use crate::agent::progress::AgentProgress;-use crate::agent::stop_hooks::StopHook;use crate::agent::subagent_host::SubagentUsage;use crate::agent::tinyagents::turn_outcome::ToolOutcomeSink;use crate::agent::tinyagents::{turn_outcome::ToolCallOutcome, turn_policy::ToolPolicyEnforcement, TurnContextMiddleware,};use crate::agent::turn_origin::AgentTurnOrigin;+use tinyagents_harness::middleware::StopHook;use tinyagents_harness::store::InMemoryStore as ToolResultArtifactIndexStore;use tinyinference_llm::model::ResolvedModelRoute;diff --git a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rsindex fe29167870..d3a635826f 100644--- a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs+++ b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs@@ -1,9 +1,9 @@//! Host accounting and result projection for the harness-owned stop chain.use crate::agent::cost::TurnCost;-use crate::agent::stop_hooks::StopHook;use std::sync::Arc;use tinyagents_harness::middleware::library::{StopHookMetrics, StopHookMiddleware};+use tinyagents_harness::middleware::StopHook;use tinyagents_harness::steering::SteeringHandle;use tinyinference_llm::model::ModelResponse;diff --git a/crates/openhuman-embed/src/agent/spec.rs b/crates/openhuman-embed/src/agent/spec.rsindex f7426ef1b9..286cdf0783 100644--- a/crates/openhuman-embed/src/agent/spec.rs+++ b/crates/openhuman-embed/src/agent/spec.rs@@ -346,7 +346,10 @@ impl AgentSpec {/// Observe cumulative usage after each model call or vote to stop before/// the next call. Return `StopDecision::Continue` for observation alone;/// a budget policy can return `StopDecision::Stop`. Scoped to this agent; no runtime-global policy is replaced.- pub fn stop_hook(mut self, hook: std::sync::Arc<dyn crate::seams::StopHook<crate::seams::TurnCost>>) -> Self {+ pub fn stop_hook(+ mut self,+ hook: std::sync::Arc<dyn crate::seams::StopHook<crate::seams::TurnCost>>,+ ) -> Self {self.hooks.push_stop(hook);self}diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rsindex 43e0d09f43..45a7388d77 100644--- a/crates/openhuman-embed/src/lib.rs+++ b/crates/openhuman-embed/src/lib.rs@@ -197,9 +197,9 @@ pub use runtime::{/// so the trait unifies — re-exporting it here would break the/// agent-runtime ownership boundary.pub mod seams {+ pub use openhuman_core::agent::cost::TurnCost;pub use openhuman_core::agent::hooks::{PostTurnHook, ToolHook};pub use openhuman_core::agent::hooks::{ToolHookContext, ToolHookDecision, TurnContext};- pub use openhuman_core::agent::cost::TurnCost;pub use openhuman_core::agent::stop_hooks::{BudgetStopHook, StopDecision, StopHook, TurnState,};diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rsindex 9e82a4aa67..e3fedd4f9d 100644--- a/crates/openhuman-embed/src/turn.rs+++ b/crates/openhuman-embed/src/turn.rs@@ -185,7 +185,10 @@ impl Turn {/// Observe cumulative usage after each model call or vote to stop before/// the next call. Return `StopDecision::Continue` for observation alone;/// a budget policy can return `StopDecision::Stop`. Scoped to this turn; no runtime-global policy is replaced.- pub fn stop_hook(mut self, hook: std::sync::Arc<dyn crate::seams::StopHook<crate::seams::TurnCost>>) -> Self {+ pub fn stop_hook(+ mut self,+ hook: std::sync::Arc<dyn crate::seams::StopHook<crate::seams::TurnCost>>,+ ) -> Self {self.hooks.push_stop(hook);self}diff --git a/crates/openhuman-embed/tests/runtime_agents.rs b/crates/openhuman-embed/tests/runtime_agents.rsindex dbafd90ddc..ff80ae99ba 100644--- a/crates/openhuman-embed/tests/runtime_agents.rs+++ b/crates/openhuman-embed/tests/runtime_agents.rs@@ -27,7 +27,9 @@ struct RecordingBudgetStopHook {}#[async_trait::async_trait]-impl openhuman_core::agent::stop_hooks::StopHook<openhuman_core::agent::cost::TurnCost> for RecordingBudgetStopHook {+impl openhuman_core::agent::stop_hooks::StopHook<openhuman_core::agent::cost::TurnCost>+ for RecordingBudgetStopHook+{fn name(&self) -> &str {"budget"}diff --git a/crates/openhuman-embed/tests/usage_hooks.rs b/crates/openhuman-embed/tests/usage_hooks.rsindex 08735c00b0..8d3b293c5f 100644--- a/crates/openhuman-embed/tests/usage_hooks.rs+++ b/crates/openhuman-embed/tests/usage_hooks.rs@@ -6,7 +6,7 @@ use common::{chat_completion, chat_requests, offline_config, route, runtime, scripted_provider,stub_backend, tool_call_completion,};-use openhuman_embed::seams::{StopDecision, StopHook, TurnState, TurnCost};+use openhuman_embed::seams::{StopDecision, StopHook, TurnCost, TurnState};use openhuman_embed::{AgentDefinitionSpec, AgentSpec, HostTurnTools, Runtime, Tool, ToolScopeSpec, Workspace,};