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/tinyagents/budget_stop_turn_tests.rs,crates/ope

Steven Enamakel60056408a828
diff --git a/crates/openhuman-core/src/agent/tinyagents/budget_stop_turn_tests.rs b/crates/openhuman-core/src/agent/tinyagents/budget_stop_turn_tests.rs
index 4a71f23db6..44ec9b93ce 100644
--- a/crates/openhuman-core/src/agent/tinyagents/budget_stop_turn_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/budget_stop_turn_tests.rs
@@ -84,7 +84,10 @@ impl StopHook<tinyagents_harness::cost::TurnCost> for RecordingBudgetStopHook {
self.inner.name()
}
- async fn check(&self, state: &TurnState<'_, tinyagents_harness::cost::TurnCost>) -> StopDecision {
+ async fn check(
+ &self,
+ state: &TurnState<'_, tinyagents_harness::cost::TurnCost>,
+ ) -> StopDecision {
let decision = self.inner.check(state).await;
if let StopDecision::Stop { reason } = &decision {
*self.reason.lock().expect("stop reason lock") = Some(reason.clone());
diff --git a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
index 2739397aba..e7886948eb 100644
--- a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
@@ -28,9 +28,9 @@ use tinyagents_harness::middleware::{
};
use tinyagents_harness::runtime::AgentHarness;
-use super::tool_registration::{capability_diagnostics, host_tool_set_builder, turn_admission};
use super::host::OpenHumanRunContext;
use super::middleware;
+use super::tool_registration::{capability_diagnostics, host_tool_set_builder, turn_admission};
use super::turn_policy::run_policy_for;
use super::ToolPolicyEnforcement;
diff --git a/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs b/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs
index e742d9cd3f..5148bb761e 100644
--- a/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs
@@ -97,10 +97,35 @@ impl SteeringRegistrar for SharedSteeringRegistrar {
fn deregister(&self, task_id: &str) {
shared_steering_registry().deregister(&TaskId::new(task_id));
- tracing::debug!(task_id, "[tinyagents] deregistered subagent steering handle");
+ tracing::debug!(
+ task_id,
+ "[tinyagents] deregistered subagent steering handle"
+ );
}
}
+/// Best-effort thread label for the delivery/requeue observability events and
+/// the metadata on any requeued steer: a sub-agent uses its task id; the
+/// interactive/channel parent turn reads the turn origin.
+pub(super) fn thread_label(
+ subagent_scope: Option<&crate::agent::tinyagents::observability::SubagentScope>,
+ origin: Option<&crate::agent::turn_origin::AgentTurnOrigin>,
+) -> String {
+ subagent_scope
+ .map(|s| s.task_id.clone())
+ .or_else(|| match origin {
+ Some(crate::agent::turn_origin::AgentTurnOrigin::WebChat { thread_id, .. }) => {
+ Some(thread_id.clone())
+ }
+ Some(crate::agent::turn_origin::AgentTurnOrigin::ExternalChannel {
+ reply_target,
+ ..
+ }) => Some(reply_target.clone()),
+ _ => None,
+ })
+ .unwrap_or_default()
+}
+
#[cfg(test)]
#[path = "steering_forwarder_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs b/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs
index ba6b52d4f6..ff76ecfeb3 100644
--- a/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs
@@ -108,9 +108,11 @@ impl ToolExecScope for TurnOriginScope {
.and_then(|context| context.state::<HostOperationContext>())
.and_then(|context| context.origin.clone());
match (origin, CoreContext::current()) {
- (Some(origin), Some(core_context)) => Box::pin(
- CoreContext::scope_with_turn_origin(core_context, Some(origin), execution),
- ),
+ (Some(origin), Some(core_context)) => Box::pin(CoreContext::scope_with_turn_origin(
+ core_context,
+ Some(origin),
+ execution,
+ )),
_ => execution,
}
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/tool_registration_tests.rs b/crates/openhuman-core/src/agent/tinyagents/tool_registration_tests.rs
index 11f02ab16a..f86a4490ae 100644
--- a/crates/openhuman-core/src/agent/tinyagents/tool_registration_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/tool_registration_tests.rs
@@ -148,4 +148,3 @@ async fn shared_adapter_scopes_tool_execution_to_the_run_origin() {
})
.await;
}
-
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
index 76a74f8aba..23712da472 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
@@ -338,7 +338,13 @@ async fn run_turn_via_tinyagents_body(
let registry_diagnostics: Arc<std::sync::Mutex<Vec<tinyagents_registry::RegistryDiagnostic>>> =
Arc::default();
let planner = OpenHumanTurnPlanner {
- models: turn_models_for_plan(model, primary, tier_routes, &error_slot, hosted_security_gate),
+ models: turn_models_for_plan(
+ model,
+ primary,
+ tier_routes,
+ &error_slot,
+ hosted_security_gate,
+ ),
policy,
tool_sets: tool_sets.clone(),
allowed: allowed.clone(),
@@ -527,7 +533,8 @@ async fn run_turn_via_tinyagents_body(
// delivery/requeue observability events and the metadata on any requeued
// steer: a sub-agent uses its task id; the interactive/channel parent turn
// reads the turn origin.
- let steer_thread_label = steering_forwarder::thread_label(subagent_scope.as_ref(), run_context.origin.as_ref());
+ let steer_thread_label =
+ steering_forwarder::thread_label(subagent_scope.as_ref(), run_context.origin.as_ref());
let controls = TurnControls {
max_iterations: Some(max_iterations),
pause_at_cap,
@@ -580,11 +587,10 @@ async fn run_turn_via_tinyagents_body(
tracing::error!(error = %failure.error, "[tinyagents] turn driver could not prepare the turn");
anyhow::anyhow!("{}", failure.error)
})?;
- let steering = prepared
- .run_context
- .steering
- .clone()
- .ok_or_else(|| anyhow::anyhow!("turn driver prepared a run without a steering handle"))?;
+ let steering =
+ prepared.run_context.steering.clone().ok_or_else(|| {
+ anyhow::anyhow!("turn driver prepared a run without a steering handle")
+ })?;
let tool_count = prepared.tools().registered.len();
let candidate_names = prepared.tools().plan.candidates.clone();
@@ -645,7 +651,11 @@ async fn run_turn_via_tinyagents_body(
let _ = prepared.split().1.finish(None);
return Err(error);
}
- tracing::debug!(model, tools = tool_count, "[tinyagents] turn harness assembled");
+ tracing::debug!(
+ model,
+ tools = tool_count,
+ "[tinyagents] turn harness assembled"
+ );
// Heap-allocate the harness drive future. It is large (it owns the whole run
// context, middleware stack, and loop state), and a sub-agent turn runs
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs
index 03dbe338c3..3d48c6bcec 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs
@@ -14,16 +14,16 @@ use std::collections::HashSet;
use std::sync::Arc;
use tinyagents_harness::cache::InMemoryResponseCache;
+use tinyagents_harness::middleware::{
+ install_unmet_deliverable, is_repeat_call_exempt, tool_sets_lookup, ResearchBudgetMiddleware,
+ ShellTurnBudget, TurnClockMiddleware, DIRECT_WEB_READ_LIMIT,
+};
use tinyagents_harness::middleware::{
plan_mode_middleware, ApprovalGateMiddleware, ArgRecoveryMiddleware, BudgetLimits,
BudgetMiddleware, BudgetParityObserver, ContextCompressionMiddleware,
PromptCacheGuardMiddleware, RepeatProgressMiddleware, RunModeHandle,
ToolPolicyMiddleware as TaToolPolicyMiddleware,
};
-use tinyagents_harness::middleware::{
- install_unmet_deliverable, is_repeat_call_exempt, tool_sets_lookup, ResearchBudgetMiddleware,
- ShellTurnBudget, TurnClockMiddleware, DIRECT_WEB_READ_LIMIT,
-};
use tinyagents_harness::runtime::AgentHarness;
use tinyagents_harness::steering::SteeringHandle;
use tinyagents_harness::turn_outcome::{HaltSummarySlot, ToolOutcomeSink};
@@ -55,9 +55,8 @@ pub(super) struct TurnMiddlewareInputs {
pub(super) subagent_scope: Option<SubagentScope>,
pub(super) context_window: Option<u64>,
pub(super) context_mw: TurnContextMiddleware,
- pub(super) stop_hooks: Vec<
- Arc<dyn tinyagents_harness::middleware::StopHook<tinyagents_harness::cost::TurnCost>>,
- >,
+ pub(super) stop_hooks:
+ Vec<Arc<dyn tinyagents_harness::middleware::StopHook<tinyagents_harness::cost::TurnCost>>>,
pub(super) tool_policy: Option<ToolPolicyEnforcement>,
pub(super) required_capabilities: Option<CapabilitySet>,
pub(super) deterministic_cacheable: bool,
@@ -97,7 +96,8 @@ pub(super) struct TurnWiring {
/// Set by `FinalCallWrapUpMiddleware` when it turned the last permitted
/// model call into the turn's conclusion (issue #6014). `None` when the
/// middleware is not installed (a run that does not pause at its cap).
- pub(super) wrap_up_fired: Option<Arc<tinyagents_harness::middleware::FinalCallWrapUpMiddleware>>,
+ pub(super) wrap_up_fired:
+ Option<Arc<tinyagents_harness::middleware::FinalCallWrapUpMiddleware>>,
/// The installed compression middleware, drained after the run to surface
/// each compaction's provenance.
pub(super) compression_mw: Option<Arc<ContextCompressionMiddleware>>,
@@ -547,7 +547,6 @@ pub(super) fn install_turn_middleware(
// compacted, trimmed or persisted (`memory::lifecycle::hooks::pre_turn`).
harness.push_middleware(Arc::new(middleware::memory_pack_middleware()));
-
TurnWiring {
halt_summary,
wrap_up_fired,
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs b/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs
index 19ae57d711..d836dda998 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs
@@ -14,7 +14,7 @@ use std::sync::{Arc, Mutex, PoisonError};
use async_trait::async_trait;
use tinyagents_harness::runtime::RunPolicy;
-use tinyagents_registry::RegistryDiagnostic;
+use tinyagents_registry::{DiagnosticSeverity, RegistryDiagnostic};
use tinyagents_runtime::turn_driver::{SharedToolSet, TurnPlan, TurnPlanner};
use tinyagents_runtime::{DriverRequest, RuntimeError};
use tinyinference_llm::model::ErrorSlotModel;
@@ -142,6 +142,57 @@ impl TurnPlanner<(), OpenHumanRunContext> for OpenHumanTurnPlanner {
}
}
+/// Enforces the capability registry's diagnostics fail-closed (issue #4249,
+/// Workstream 10 — registry), *before* the first model dispatch: an ambiguous or
+/// broken tool surface (a name shared across native/MCP/Composio/generated
+/// tools, a dangling alias) aborts the turn instead of silently resolving to an
+/// unintended component while a provider call is in flight. Warnings are logged.
+pub(super) fn enforce_registry_diagnostics(
+ slot: &Mutex<Vec<RegistryDiagnostic>>,
+) -> anyhow::Result<()> {
+ let registry_diagnostics =
+ std::mem::take(&mut *slot.lock().unwrap_or_else(PoisonError::into_inner));
+ if !registry_diagnostics.is_empty() {
+ let (errors, warnings): (
+ Vec<&tinyagents_registry::RegistryDiagnostic>,
+ Vec<&tinyagents_registry::RegistryDiagnostic>,
+ ) = registry_diagnostics
+ .iter()
+ .partition(|d| matches!(d.severity, DiagnosticSeverity::Error));
+ for diag in &warnings {
+ tracing::warn!(
+ kind = diag.kind.as_str(),
+ name = %diag.name,
+ "[registry] non-fatal diagnostic: {}",
+ diag.message
+ );
+ }
+ if !errors.is_empty() {
+ let messages: Vec<String> = errors
+ .iter()
+ .map(|d| format!("[{}] {}: {}", d.kind.as_str(), d.name, d.message))
+ .collect();
+ for msg in &messages {
+ tracing::error!("[registry] error-severity diagnostic aborting turn: {msg}");
+ }
+ tracing::error!(
+ error_count = messages.len(),
+ warning_count = warnings.len(),
+ "[registry] aborting turn before model dispatch: capability registry validation failed"
+ );
+ return Err(anyhow::Error::new(
+ tinyagents_harness::agent_error::AgentError::RegistryValidationFailed {
+ diagnostics: messages,
+ },
+ ));
+ }
+ tracing::debug!(
+ warning_count = warnings.len(),
+ "[registry] registry diagnostics present (warnings only); proceeding with turn"
+ );
+ }
+ Ok(())
+}
#[cfg(test)]
#[path = "turn_plan_tests.rs"]
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs
index 0391286317..62a313e563 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs
@@ -2,14 +2,14 @@
//! run policy a turn gets, and the model-call ceilings.
use super::*;
+use crate::agent::tinyagents::turn_models::TurnModels;
use crate::agent::tinyagents::TurnModelSource;
use async_trait::async_trait;
-use crate::agent::tinyagents::turn_models::TurnModels;
-use tinyagents_runtime::turn_driver::{SharedToolSet, TurnControls, TurnDriver};
-use tinyagents_runtime::{DriverRequest, ToolSnapshot};
use tinyagents_harness::turn_policy::{
DEFAULT_MODEL_CALL_TIMEOUT_SECS, LOCAL_MODEL_CALL_TIMEOUT_SECS,
};
+use tinyagents_runtime::turn_driver::{SharedToolSet, TurnControls, TurnDriver};
+use tinyagents_runtime::{DriverRequest, ToolSnapshot};
use tinyinference_llm::model::{ChatModel, ModelProfile, ModelRequest, ModelResponse};
use tinytools::{Tool, ToolResult};
@@ -128,7 +128,11 @@ async fn prepared_with(
}
async fn registered_tool_names(has_thread: bool) -> Vec<String> {
- prepared_with(has_thread, None).await.harness.tools().names()
+ prepared_with(has_thread, None)
+ .await
+ .harness
+ .tools()
+ .names()
}
#[tokio::test]
@@ -219,7 +223,10 @@ async fn run_slow_first_byte_turn(
delay: std::time::Duration::from_secs(delay_secs),
provider,
});
- let run = prepare_with(model, Vec::new(), false, None).await.run().await;
+ let run = prepare_with(model, Vec::new(), false, None)
+ .await
+ .run()
+ .await;
match run.partial.error {
Some(error) => Err(error.to_string()),
None => Ok(run.partial.run.text().unwrap_or_default()),