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(session-host): expose tool visibility fields directly in tests
Steven Enamakel44a93ca5987c
diff --git a/crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rs b/crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rsindex 240575f545..57fbda0b09 100644--- a/crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rs+++ b/crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rs@@ -51,7 +51,7 @@ async fn turn_routes_a_bare_packed_tool_call_through_use_skill() {let (mut agent, _tmp) = build_agent_with(provider, tools, Box::new(NativeDialect));assert!(!agent- .visible_tool_names_for_test()+ .visible_tool_names.contains("skill_registry_search"),"precondition: the tool is withheld behind its pack");diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rsindex 037eec33d1..718cf793a8 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs@@ -342,7 +342,7 @@ async fn an_empty_named_scope_advertises_no_tools_at_all() {).expect("summarizer is a shipped agent definition");- let visible = agent.visible_tool_names_for_test();+ let visible = agent.visible_tool_names;let real: Vec<&String> = visible.iter().filter(|n| n.as_str() != crate::agent::harness::host_definition::NO_TOOLS_SENTINEL)@@ -378,7 +378,7 @@ async fn a_zero_tool_agent_does_not_gain_the_compaction_recovery_tool() {assert!(!agent- .visible_tool_names_for_test()+ .visible_tool_names.contains(tinyjuice_bus::tools::RETRIEVE),"a deliberately tool-less agent must not be handed the recovery tool");@@ -435,7 +435,7 @@ async fn a_summarized_agent_sees_the_recovery_tool_with_compaction_off() {"orchestrator",).expect("orchestrator is a shipped agent definition");- let visible = agent.visible_tool_names_for_test();+ let visible = agent.visible_tool_names;assert!(visible.is_empty() || visible.contains(tinyjuice_bus::tools::RETRIEVE),"the orchestrator's summaries point at a tool it must be able to call"@@ -512,7 +512,7 @@ async fn a_curated_orchestrator_sees_and_holds_every_juice_tool_in_handle_mode()"orchestrator",).expect("orchestrator is a shipped agent definition");- let visible = agent.visible_tool_names_for_test();+ let visible = agent.visible_tool_names;assert!(!visible.is_empty(),"the orchestrator's belt is curated; an empty set would make this test vacuous"diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rsindex 1156b461ee..37258d7e11 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs@@ -186,7 +186,7 @@ fn withholding_tool_search_disables_wildcard_discovery() {.expect("build a wildcard session with discovery withheld");assert!(- agent.deferred_tool_names_for_test().is_empty(),+ agent.deferred_tool_names.is_empty(),"withholding tool_search must also make deferred tools unreachable");}diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rsindex 6d15783f48..d08478e02f 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs@@ -146,11 +146,11 @@ fn wildcard_belt_defers_but_keeps_reachable() {let agent = build_with(direct_and_deferred(), std::collections::HashSet::new());assert_eq!(- agent.deferred_tool_names_for_test(),+ agent.deferred_tool_names,&std::collections::HashSet::from(["rare".to_string()]));- assert!(agent.visible_tool_names_for_test().contains("plain"));- assert!(!agent.visible_tool_names_for_test().contains("rare"));+ assert!(agent.visible_tool_names.contains("plain"));+ assert!(!agent.visible_tool_names.contains("rare"));assert!(!agent.visible_tool_specs_arc()@@ -159,7 +159,7 @@ fn wildcard_belt_defers_but_keeps_reachable() {"a deferred tool must not be in the prompt's spec list");assert!(- agent.tool_policy_session_for_test().is_allowed("rare"),+ agent.tool_policy_session.is_allowed("rare"),"a deferred tool must be callable once found");}@@ -177,14 +177,14 @@ fn named_belt_opts_into_discovery_by_naming_tool_search() {let agent = build_with(direct_and_deferred(), visible);assert_eq!(- agent.visible_tool_names_for_test(),+ agent.visible_tool_names,&std::collections::HashSet::from(["plain".to_string()]));assert_eq!(- agent.deferred_tool_names_for_test(),+ agent.deferred_tool_names,&std::collections::HashSet::from(["rare".to_string()]));- assert!(agent.tool_policy_session_for_test().is_allowed("rare"));+ assert!(agent.tool_policy_session.is_allowed("rare"));}/// A named belt that does not opt in reaches nothing beyond what it wrote@@ -194,8 +194,8 @@ fn named_belt_without_tool_search_reaches_no_deferred_tool() {let visible: std::collections::HashSet<String> = std::iter::once("plain".to_string()).collect();let agent = build_with(direct_and_deferred(), visible);- assert!(agent.deferred_tool_names_for_test().is_empty());- assert!(!agent.tool_policy_session_for_test().is_allowed("rare"));+ assert!(agent.deferred_tool_names.is_empty());+ assert!(!agent.tool_policy_session.is_allowed("rare"));}/// A hand-written `[tools] named` belt is left exactly as written: exposure is@@ -238,9 +238,9 @@ fn orchestrator_reaches_the_replaced_specialists_tools_through_discovery() {&definition,).expect("orchestrator session build");- let deferred = agent.deferred_tool_names_for_test();- let visible = agent.visible_tool_names_for_test();- let policy = agent.tool_policy_session_for_test();+ let deferred = agent.deferred_tool_names;+ let visible = agent.visible_tool_names;+ let policy = agent.tool_policy_session;// Unconditionally registered members only: language commands run through shell and need// host Node runtime and the wallet family needs the `web3`// feature, so a test profile without them cannot see them either way.diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rsindex 1be4076629..7912028c03 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs@@ -384,7 +384,7 @@ async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfa).expect("desktop orchestrator");for name in ["browser", "browser_open"] {- assert!(host.deferred_tool_names_for_test().contains(name), "{name}");+ assert!(host.deferred_tool_names.contains(name), "{name}");assert!(!host.visible_tool_specs_arc().iter()@@ -428,7 +428,7 @@ async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfa.expect("browser-disabled orchestrator");for name in ["browser", "browser_open"] {assert!(- !disabled.deferred_tool_names_for_test().contains(name),+ !disabled.deferred_tool_names.contains(name),"{name}");}diff --git a/crates/openhuman-core/src/agent/session_host/tool_progress.rs b/crates/openhuman-core/src/agent/session_host/tool_progress.rsdeleted file mode 100644index 3a8f8feaa9..0000000000--- a/crates/openhuman-core/src/agent/session_host/tool_progress.rs+++ /dev/null@@ -1,269 +0,0 @@-//! Session tool-execution progress reporting + the shared streaming-delta forwarder.-//!-//! The legacy direct tool-execution path never names a concrete [`AgentProgress`]-//! variant. It talks to a [`ProgressReporter`], whose impls pick the event flavor:-//!-//! * [`TurnProgress`] — top-level chat (channel loop, `OpenHumanSessionHost::turn`): emits the-//! `Turn*` / `ToolCall*` / `TurnCostUpdated` events and streams provider-//! deltas as `TextDelta` / `ThinkingDelta` / `ToolCallArgsDelta`.--use async_trait::async_trait;--use crate::agent::progress::AgentProgress;-use crate::inference::provider::ProviderDelta;-use tinyagents_harness::cost::TurnCost;--/// What the engine emits as a turn progresses. All methods default to no-ops so-/// an impl only overrides the events its flavor cares about.-#[async_trait]-pub(crate) trait ProgressReporter: Send + Sync {- async fn turn_started(&self) {}- async fn iteration_started(&self, _iteration: u32, _max_iterations: u32) {}- async fn cost_updated(&self, _model: &str, _iteration: u32, _cost: &TurnCost) {}- async fn turn_completed(&self, _iterations: u32) {}- /// `display_label` / `display_detail` carry the server-computed human- /// label (e.g. "Reading messages") and contextual detail (e.g.- /// "[email protected]"); `None` lets the client formatter decide.- #[allow(clippy::too_many_arguments)]- async fn tool_started(- &self,- _call_id: &str,- _tool_name: &str,- _arguments: &serde_json::Value,- _iteration: u32,- _display_label: Option<&str>,- _display_detail: Option<&str>,- ) {- }- #[allow(clippy::too_many_arguments)]- async fn tool_completed(- &self,- _call_id: &str,- _tool_name: &str,- _success: bool,- _output: &str,- _elapsed_ms: u64,- _iteration: u32,- ) {- }-- /// Build the per-iteration `ProviderDelta` streaming sink + forwarder task,- /// or `(None, None)` when this flavor doesn't stream. Default: no streaming.- fn make_stream_sink(- &self,- _iteration: u32,- ) -> (- Option<tokio::sync::mpsc::Sender<ProviderDelta>>,- Option<tokio::task::JoinHandle<()>>,- ) {- (None, None)- }-}--/// Top-level chat flavor: `Turn*` lifecycle + `ToolCall*` + streaming.-pub(crate) struct TurnProgress {- pub sink: Option<tokio::sync::mpsc::Sender<AgentProgress>>,-}--impl TurnProgress {- pub(crate) fn new(sink: Option<tokio::sync::mpsc::Sender<AgentProgress>>) -> Self {- Self { sink }- }-}--/// Emit a lifecycle progress event **without ever blocking** the agent's-/// control flow. Progress is pure observability, but the sink is a bounded-/// channel shared by the orchestrator, every inline sub-agent run, and their-/// delta forwarders. A blocking `send().await` here can park a sub-agent's main-/// loop when the channel is momentarily full — which hangs the parent turn,-/// because the orchestrator is `await`ing that sub-agent's tool call and never-/// makes its next LLM request (the subagent-stall flake). So drop the event on-/// `Full` (a missed UI tick, not a correctness issue) and `trace` on `Closed`-/// (no listener). Streaming *text deltas* keep their own blocking backpressure-/// in their forwarder tasks, so visible message text is unaffected.-fn emit(sink: &tokio::sync::mpsc::Sender<AgentProgress>, event: AgentProgress) {- use tokio::sync::mpsc::error::TrySendError;- match sink.try_send(event) {- Ok(()) => {}- Err(TrySendError::Full(_)) => {- log::trace!("[agent_loop] progress channel full — dropping lifecycle event");- }- Err(TrySendError::Closed(_)) => {- log::trace!("[agent_loop] progress sink closed — dropping lifecycle event");- }- }-}--#[async_trait]-impl ProgressReporter for TurnProgress {- async fn turn_started(&self) {- if let Some(ref sink) = self.sink {- emit(sink, AgentProgress::TurnStarted);- }- }-- async fn iteration_started(&self, iteration: u32, max_iterations: u32) {- if let Some(ref sink) = self.sink {- emit(- sink,- AgentProgress::IterationStarted {- iteration,- max_iterations,- },- );- }- }-- async fn cost_updated(&self, model: &str, iteration: u32, cost: &TurnCost) {- if let Some(ref sink) = self.sink {- let event = AgentProgress::TurnCostUpdated {- model: model.to_string(),- iteration,- input_tokens: cost.input_tokens,- output_tokens: cost.output_tokens,- cached_input_tokens: cost.cached_input_tokens,- // Known spend so far; an unpriced call adds nothing to it.- total_usd: cost.cost.known_usd,- };- emit(sink, event);- }- }-- async fn turn_completed(&self, iterations: u32) {- if let Some(ref sink) = self.sink {- emit(- sink,- AgentProgress::TurnCompleted {- iterations,- stop: None,- },- );- }- }-- #[allow(clippy::too_many_arguments)]- async fn tool_started(- &self,- call_id: &str,- tool_name: &str,- arguments: &serde_json::Value,- iteration: u32,- display_label: Option<&str>,- display_detail: Option<&str>,- ) {- if let Some(ref sink) = self.sink {- emit(- sink,- AgentProgress::ToolCallStarted {- call_id: call_id.to_string(),- tool_name: tool_name.to_string(),- arguments: arguments.clone(),- iteration,- display_label: display_label.map(str::to_string),- display_detail: display_detail.map(str::to_string),- },- );- }- }-- async fn tool_completed(- &self,- call_id: &str,- tool_name: &str,- success: bool,- output: &str,- elapsed_ms: u64,- iteration: u32,- ) {- if let Some(ref sink) = self.sink {- emit(- sink,- AgentProgress::ToolCallCompleted {- call_id: call_id.to_string(),- tool_name: tool_name.to_string(),- success,- output_chars: output.chars().count(),- output: output.to_string(),- // The legacy reporter path has no captured argument- // payload at completion time.- arguments: None,- elapsed_ms,- iteration,- failure: None,- // The legacy reporter path has no live tool registry or- // captured `ToolResult` to recompute a label or read- // structured metadata from.- display_label: None,- display_detail: None,- structured: None,- },- );- }- }-- fn make_stream_sink(- &self,- iteration: u32,- ) -> (- Option<tokio::sync::mpsc::Sender<ProviderDelta>>,- Option<tokio::task::JoinHandle<()>>,- ) {- spawn_delta_forwarder(self.sink.clone(), iteration)- }-}--/// Spawn a task that forwards `ProviderDelta`s from the provider's streaming-/// channel into `on_progress` as `AgentProgress` delta events, tagged with-/// `iteration` (1-based). Returns the sender to hand to-/// [`crate::inference::provider::ChatRequest::stream`] and the task-/// handle to await after the chat call.-///-/// Returns `(None, None)` when there is no progress sink — the caller then-/// passes `stream: None` and the provider uses its non-streaming HTTP path.-///-/// Backpressure discipline: the forwarder `.await`s each `send`, so streamed-/// deltas arrive in order and are never silently dropped when the downstream-/// bridge is slow. It exits cleanly once the sender is dropped (after the chat-/// call) or the downstream closes.-pub(crate) fn spawn_delta_forwarder(- on_progress: Option<tokio::sync::mpsc::Sender<AgentProgress>>,- iteration: u32,-) -> (- Option<tokio::sync::mpsc::Sender<ProviderDelta>>,- Option<tokio::task::JoinHandle<()>>,-) {- let Some(progress_sink) = on_progress else {- return (None, None);- };- let (tx, mut rx) = tokio::sync::mpsc::channel::<ProviderDelta>(128);- let forwarder = tokio::spawn(async move {- while let Some(event) = rx.recv().await {- let mapped = match event {- ProviderDelta::TextDelta { delta } => AgentProgress::TextDelta { delta, iteration },- ProviderDelta::ThinkingDelta { delta } => {- AgentProgress::ThinkingDelta { delta, iteration }- }- ProviderDelta::ToolCallStart { call_id, tool_name } => {- AgentProgress::ToolCallArgsDelta {- call_id,- tool_name,- delta: String::new(),- iteration,- }- }- ProviderDelta::ToolCallArgsDelta { call_id, delta } => {- AgentProgress::ToolCallArgsDelta {- call_id,- tool_name: String::new(),- delta,- iteration,- }- }- };- if progress_sink.send(mapped).await.is_err() {- break;- }- }- });- (Some(tx), Some(forwarder))-}