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 and learning sink types

Steven Enamakel156b65875f2d
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rs
index af6d0c34c8..3420b93245 100644
--- a/crates/openhuman-core/src/agent/host_agents.rs
+++ b/crates/openhuman-core/src/agent/host_agents.rs
@@ -49,7 +49,10 @@ pub struct HostAgent {
/// The context every read during the agent's turn must see.
pub context: Arc<CoreContext>,
/// Agent-owned callbacks inherited by core-scheduled turns.
- pub hooks: crate::agent::hooks::HookScope,
+ pub hooks: tinyagents_hooks::scope::HookScope<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ tinyagents_harness::cost::TurnCost,
+ >,
}
impl HostAgent {
diff --git a/crates/openhuman-core/src/agent/host_overrides.rs b/crates/openhuman-core/src/agent/host_overrides.rs
index d7940fdedc..7c69ddab91 100644
--- a/crates/openhuman-core/src/agent/host_overrides.rs
+++ b/crates/openhuman-core/src/agent/host_overrides.rs
@@ -7,7 +7,8 @@
use std::collections::BTreeMap;
use std::sync::{Arc, RwLock};
-use crate::agent::hooks::{PostTurnHook, ToolHook};
+use tinyagents_harness::host::LearningSink;
+use tinyagents_hooks::tool::ToolHook;
use crate::agent::tinyagents::host::OpenHumanRunContext;
use tinyinference_llm::model::ChatModel;
@@ -20,7 +21,7 @@ pub struct HostOverrides {
pub parent: Option<Arc<HostOverrides>>,
/// Approval registration barrier owned by this agent instance.
pub approval_scope: Option<Arc<crate::security::approval::ApprovalScope>>,
- post_turn_hooks: RwLock<BTreeMap<String, Arc<dyn PostTurnHook>>>,
+ post_turn_hooks: RwLock<BTreeMap<String, Arc<dyn LearningSink>>>,
tool_hooks: RwLock<BTreeMap<String, Arc<dyn ToolHook<OpenHumanRunContext>>>>,
/// Native inference used by this agent instead of config-routed inference.
pub model: Option<Arc<dyn ChatModel<()>>>,
@@ -73,7 +74,7 @@ impl HostOverrides {
}
/// Add or replace an agent-local post-turn hook by name; `None` removes it.
- pub fn post_turn_hook(&self, name: &str, hook: Option<Arc<dyn PostTurnHook>>) {
+ pub fn post_turn_hook(&self, name: &str, hook: Option<Arc<dyn LearningSink>>) {
let mut hooks = self
.post_turn_hooks
.write()
@@ -97,7 +98,7 @@ impl HostOverrides {
}
/// Snapshot the agent-local post-turn hooks for a new session.
- pub fn post_turn_hooks(&self) -> Vec<Arc<dyn PostTurnHook>> {
+ pub fn post_turn_hooks(&self) -> Vec<Arc<dyn LearningSink>> {
let mut hooks = self
.parent
.as_ref()
diff --git a/crates/openhuman-core/src/agent/turn_env.rs b/crates/openhuman-core/src/agent/turn_env.rs
index f01d542d01..a440b6df67 100644
--- a/crates/openhuman-core/src/agent/turn_env.rs
+++ b/crates/openhuman-core/src/agent/turn_env.rs
@@ -16,7 +16,7 @@
use tinyagents_harness::cancel::CancellationToken;
use tinyagents_harness::turn_deadline::TurnDeadline;
-use crate::agent::hooks::HookScope;
+use crate::agent::tinyagents::host::OpenHumanRunContext;
use crate::agent::tinyagents::budget::ModelBudget;
/// Per-turn values an entry point hands to the session it runs.
@@ -38,7 +38,10 @@ pub struct HostTurnEnv {
/// A cap on real tool invocations, never wider than the product default.
pub tool_call_limit: Option<usize>,
/// Agent/turn hook callbacks added after the runtime's global ones.
- pub hooks: HookScope,
+ pub hooks: tinyagents_hooks::scope::HookScope<
+ OpenHumanRunContext,
+ tinyagents_harness::cost::TurnCost,
+ >,
/// The host's tool belt for this turn is authoritative: tool declarations
/// recorded in a restored transcript must not bring a revoked tool back.
pub fresh_tool_snapshot: bool,