Skip to content

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

feat(agent): add live tool support to tinyagents harness

Steven Enamakel3d80980d4db2
diff --git a/crates/openhuman-core/src/agent/session_host/live_tools.rs b/crates/openhuman-core/src/agent/session_host/live_tools.rs
index 7a6588e23d..58b026ea54 100644
--- a/crates/openhuman-core/src/agent/session_host/live_tools.rs
+++ b/crates/openhuman-core/src/agent/session_host/live_tools.rs
@@ -24,6 +24,7 @@ impl OpenHumanSessionHost {
.cloned()
.collect();
LiveToolSurface {
+ tool_hooks: self.host_env.hooks.tool_hooks().to_vec(),
tool_sets: vec![Arc::clone(&self.tools)],
allowed,
tool_policy: Some(ToolPolicyEnforcement {
diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
index 741759c8a9..e20c218ca0 100644
--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
@@ -67,6 +67,9 @@ pub(super) fn assemble_turn_harness(
stop_hooks: Vec<
Arc<dyn tinyagents_harness::middleware::StopHook<crate::agent::cost::TurnCost>>,
>,
+ // The turn's agent/turn tool callbacks (`OpenHumanRunContext::tool_hooks`),
+ // registered after the runtime's global ones.
+ scoped_tool_hooks: Vec<Arc<dyn crate::agent::hooks::ToolHook>>,
tool_policy: Option<ToolPolicyEnforcement>,
required_capabilities: Option<CapabilitySet>,
deterministic_cacheable: bool,
@@ -627,7 +630,8 @@ pub(super) fn assemble_turn_harness(
// observation-only (never mutates the result), so running first in the
// reverse-order `after_tool` chain is safe — it cannot perturb the
// summarization/cap or tool-outcome capture layers.
- let embedder_tool_hooks = crate::agent::hooks::turn_tool_hooks();
+ let mut embedder_tool_hooks = crate::agent::hooks::embedder_tool_hooks();
+ embedder_tool_hooks.extend(scoped_tool_hooks);
if !embedder_tool_hooks.is_empty() {
harness.push_middleware(Arc::new(middleware::EmbedderToolHooksMiddleware::new(
embedder_tool_hooks,
diff --git a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
index efa119d78e..d6610176a0 100644
--- a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
@@ -51,6 +51,9 @@ pub(crate) struct LiveToolSurface {
/// Whether the session is bound to a chat thread (thread-scoped tools are
/// only offered then).
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>>,
}
/// Builds the live session's tool harness.
@@ -62,6 +65,7 @@ pub(crate) fn assemble_live_tool_harness(
allowed,
tool_policy,
has_thread,
+ tool_hooks,
} = surface;
let mut harness: AgentHarness<(), OpenHumanRunContext> = AgentHarness::new();
harness.with_policy(run_policy_for(LIVE_MAX_TOOL_CALLS, false));
@@ -121,7 +125,8 @@ pub(crate) fn assemble_live_tool_harness(
registered_tools,
route_session,
)));
- let embedder_tool_hooks = crate::agent::hooks::turn_tool_hooks();
+ let mut embedder_tool_hooks = crate::agent::hooks::embedder_tool_hooks();
+ embedder_tool_hooks.extend(tool_hooks);
if !embedder_tool_hooks.is_empty() {
harness.push_middleware(Arc::new(middleware::EmbedderToolHooksMiddleware::new(
embedder_tool_hooks,
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
index 2b69ce725a..726e46e194 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
@@ -277,6 +277,7 @@ pub(super) async fn run_turn_via_tinyagents_body(
early_exit_tools,
context_mw,
run_context.stop_hooks.clone(),
+ run_context.tool_hooks.clone(),
tool_policy.clone(),
routes::turn_required_capabilities(model),
deterministic_cacheable,