Skip to content

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

chore: files changed crates/openhuman-core/src/agent/session_host/runtime_session.rs,crates/openhuma

Steven Enamakel67759a22a937
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index 86c6e6a309..6865ca4182 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -195,6 +195,16 @@ impl OpenHumanTurnPrelude {
)
}
+ /// The session's deferred set for this turn; see
+ /// `OpenHumanRunContext::deferred_tool_names`.
+ fn current_deferred_tool_names(&self) -> std::collections::HashSet<String> {
+ self.tool_surface
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .deferred_tool_names
+ .clone()
+ }
+
fn replace_tool_surface(&self, surface: OpenHumanTurnToolSurface) {
*self
.tool_surface
@@ -1675,6 +1685,10 @@ impl OpenHumanSessionHost {
middleware.transcript_snapshot = Some(transcript_snapshot);
options.run_context.data.context_middleware = Some(middleware);
options.run_context.data.current_tools = Some(current_tools);
+ if !overrides.suppress_tools {
+ options.run_context.data.deferred_tool_names =
+ Arc::new(prelude.current_deferred_tool_names());
+ }
options.run_context.data.current_synthesized_tools =
Some(current_synthesized_tools);
options.run_context.data.tool_policy =
diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
index b2b39a987c..43b691ca7f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
@@ -136,6 +136,9 @@ pub(super) fn assemble_turn_harness(
// The dialect the session composed its prompt for; see
// `OpenHumanRunContext::tool_dialect`.
tool_dialect: tinyagents_harness::config::ToolDispatcher,
+ // Session-deferred tools (`OpenHumanRunContext::deferred_tool_names`):
+ // registered as `Deferred` whatever their own exposure says.
+ session_deferred: Arc<HashSet<String>>,
// Live per-thread Plan/Build mode handle (`agent::tinyagents::run_mode`).
// `Some` installs `PlanModeMiddleware`, which hides/denies side-effecting
// tools while the thread is in `RunMode::Plan` — flipped without
@@ -402,6 +405,7 @@ pub(super) fn assemble_turn_harness(
&early_exit_set,
early_exit_hook.as_ref(),
is_subagent_run,
+ &session_deferred,
);
// SHADOW tool-exposure layer (issue #4249, 01.3 — dynamic exposure). Compose
diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs b/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs
index 3fe222b86e..4fbd96b81d 100644
--- a/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs
@@ -88,6 +88,7 @@ pub(super) fn register_turn_tools_and_agents(
early_exit_set: &HashSet<&str>,
early_exit_hook: Option<&EarlyExitHook>,
is_subagent_run: bool,
+ session_deferred: &HashSet<String>,
) -> (
usize,
Vec<String>,
@@ -139,6 +140,9 @@ pub(super) fn register_turn_tools_and_agents(
adapter = adapter.with_early_exit(hook.clone());
}
}
+ if session_deferred.contains(name) {
+ adapter = adapter.deferred();
+ }
registered.insert(name.to_string());
let adapter = Arc::new(adapter);
capability_registry.replace_tool(adapter.clone());
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 7c7f7148c8..8f54341174 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -288,6 +288,12 @@ pub struct OpenHumanRunContext {
/// Exact executable dynamic/delegation tools selected with
/// [`Self::current_tools`] for this turn.
pub(crate) current_synthesized_tools: Option<Arc<Vec<Box<dyn tinytools::Tool>>>>,
+ /// Tools the session serves through `tool_search` for this turn although
+ /// their own exposure is `Direct` (the agent definition's
+ /// `deferred_tools`). Turn assembly registers them as `Deferred`, so the
+ /// harness keeps them off the wire, indexes them for search and still
+ /// admits a call by name. Empty for every turn without such a list.
+ pub(crate) deferred_tool_names: Arc<HashSet<String>>,
/// Context middleware snapshot prepared for this exact turn.
pub(crate) context_middleware: Option<TurnContextMiddleware>,
/// Model/harness sidecars consumed only after a durable commit.
@@ -340,6 +346,7 @@ impl OpenHumanRunContext {
tool_policy: None,
current_tools: None,
current_synthesized_tools: None,
+ deferred_tool_names: Arc::new(HashSet::new()),
context_middleware: None,
session_sidecar: Arc::new(Mutex::new(SessionTurnSidecar::default())),
required_output: None,
diff --git a/crates/openhuman-core/src/agent/tinyagents/tools.rs b/crates/openhuman-core/src/agent/tinyagents/tools.rs
index ace45b55bb..08a9a024f4 100644
--- a/crates/openhuman-core/src/agent/tinyagents/tools.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/tools.rs
@@ -79,6 +79,9 @@ pub(crate) struct CanonicalSharedToolAdapter {
description: String,
parameters_schema: serde_json::Value,
early_exit: Option<EarlyExitHook>,
+ /// Report `Deferred` whatever the resolved tool says: the session serves
+ /// this tool through `tool_search` for its own agent only.
+ force_deferred: bool,
}
impl CanonicalSharedToolAdapter {
@@ -94,9 +97,18 @@ impl CanonicalSharedToolAdapter {
description: spec.description,
parameters_schema: spec.parameters,
early_exit: None,
+ force_deferred: false,
})
}
+ /// Register this tool as `Deferred` for the turn (see
+ /// `OpenHumanRunContext::deferred_tool_names`). A `Hidden` tool stays
+ /// hidden: deferral only ever subtracts.
+ pub(crate) fn deferred(mut self) -> Self {
+ self.force_deferred = true;
+ self
+ }
+
pub(crate) fn with_early_exit(mut self, hook: EarlyExitHook) -> Self {
self.early_exit = Some(hook);
self
@@ -145,6 +157,7 @@ impl Tool for CanonicalSharedToolAdapter {
fn exposure(&self) -> tinytools::ToolExposure {
match self.resolved_tool().map(Tool::exposure) {
Some(tinytools::ToolExposure::Deferred) => tinytools::ToolExposure::Deferred,
+ _ if self.force_deferred => tinytools::ToolExposure::Deferred,
_ => tinytools::ToolExposure::Direct,
}
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
index 783d773b69..07c49d3fd6 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
@@ -281,6 +281,7 @@ async fn run_turn_via_tinyagents_inner(
hosted_root.is_some(),
pause_at_cap,
run_context.tool_dialect,
+ Arc::clone(&run_context.deferred_tool_names),
run_context
.thread_id
.as_deref()