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
perf(core): box large async state machines behind inline(never) wrappers
Steven Enamakel7712a755c5d5
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rsindex dfa6b3c9e5..db5dd358c9 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs@@ -188,8 +188,61 @@ pub(crate) async fn run_root_turn_via_hosted_agent(.await}+/// Returned boxed and `#[inline(never)]` on purpose: an `async fn` body is+/// otherwise re-instantiated inside every crate / codegen unit that awaits it,+/// and this state machine is large. Boxing here keeps one copy, compiled in+/// this crate.#[allow(clippy::too_many_arguments)]-async fn run_turn_via_tinyagents_inner(+#[inline(never)]+fn run_turn_via_tinyagents_inner<'a>(+ run_context: OpenHumanRunContext,+ turn_models: TurnModels,+ provider_id: String,+ model: &'a str,+ history: Vec<TranscriptMessage>,+ tool_sets: Vec<Arc<Vec<Box<dyn tinytools::Tool>>>>,+ allowed: Option<HashSet<String>>,+ max_iterations: usize,+ subagent_scope: Option<SubagentScope>,+ context_window: Option<u64>,+ run_queue: Option<Arc<RunQueue<crate::agent::queued_turn::QueuedTurn>>>,+ early_exit_tools: &'a [&'a str],+ pause_at_cap: bool,+ max_output_tokens: Option<u32>,+ context_mw: TurnContextMiddleware,+ tool_policy: Option<ToolPolicyEnforcement>,+ deterministic_cacheable: bool,+ defer_turn_completed_to_caller: bool,+ hosted_root: Option<(+ Arc<crate::agent::tinyagents::host::OpenHumanHostBase>,+ String,+ )>,+) -> futures::future::BoxFuture<'a, Result<TinyagentsTurnOutcome>> {+ Box::pin(run_turn_via_tinyagents_body(+ run_context,+ turn_models,+ provider_id,+ model,+ history,+ tool_sets,+ allowed,+ max_iterations,+ subagent_scope,+ context_window,+ run_queue,+ early_exit_tools,+ pause_at_cap,+ max_output_tokens,+ context_mw,+ tool_policy,+ deterministic_cacheable,+ defer_turn_completed_to_caller,+ hosted_root,+ ))+}++#[allow(clippy::too_many_arguments)]+async fn run_turn_via_tinyagents_body(mut run_context: OpenHumanRunContext,turn_models: TurnModels,provider_id: String,diff --git a/crates/openhuman-core/src/flows/ops/execution.rs b/crates/openhuman-core/src/flows/ops/execution.rsindex 2eab17b58b..e413d84c66 100644--- a/crates/openhuman-core/src/flows/ops/execution.rs+++ b/crates/openhuman-core/src/flows/ops/execution.rs@@ -90,7 +90,41 @@ pub(super) async fn export_run_to_langfuse(/// status. Registering before the `run_id` is observable makes the cancel/// always take the signalled branch instead. `_run_guard` is held for the whole/// body and deregisters on any exit, including the early returns below.-pub(super) async fn run_flow_body(+///+/// Returned boxed and `#[inline(never)]` on purpose: an `async fn` body is+/// otherwise re-instantiated inside every crate / codegen unit that awaits it,+/// and this state machine is large. Boxing here keeps one copy, compiled in+/// this crate.+#[allow(clippy::too_many_arguments)]+#[inline(never)]+pub(super) fn run_flow_body(+ config_arc: Arc<Config>,+ flow: Flow,+ flow_id: String,+ thread_id: String,+ input: Value,+ inputs: serde_json::Map<String, Value>,+ trigger: FlowRunTrigger,+ no_actionable_nodes: bool,+ cancel_token: tokio_util::sync::CancellationToken,+ _run_guard: run_registry::RunGuard,+) -> futures::future::BoxFuture<'static, Result<Outcome<Value>, String>> {+ Box::pin(run_flow_body_inner(+ config_arc,+ flow,+ flow_id,+ thread_id,+ input,+ inputs,+ trigger,+ no_actionable_nodes,+ cancel_token,+ _run_guard,+ ))+}++#[allow(clippy::too_many_arguments)]+async fn run_flow_body_inner(config_arc: Arc<Config>,flow: Flow,flow_id: String,diff --git a/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch_uncached.rs b/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch_uncached.rsindex e9250c7f7b..638445d726 100644--- a/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch_uncached.rs+++ b/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch_uncached.rs@@ -20,6 +20,7 @@ use super::fetch::{connectable_toolkit_slugs, resolve_toolkit_description};////// Returns `None` when we couldn't even build a client (no auth),/// signalling the caller should NOT cache this result.+////// Returned boxed and `#[inline(never)]` on purpose: an `async fn` body is/// otherwise re-instantiated inside every crate / codegen unit that awaits it,/// and these state machines are large. Boxing here keeps one copy, compiled indiff --git a/crates/openhuman-core/src/security/approval/gate_intercept.rs b/crates/openhuman-core/src/security/approval/gate_intercept.rsindex 29b0b201f6..9916d2303d 100644--- a/crates/openhuman-core/src/security/approval/gate_intercept.rs+++ b/crates/openhuman-core/src/security/approval/gate_intercept.rs@@ -6,7 +6,36 @@ impl ApprovalGate {/// thread routing cleared, `pending_approvals` row left open) and/// `*park_bound_elapsed` is set so the bounded caller can render its own/// fast-path result instead of a `Deny`.- async fn intercept_audited_inner(+ ///+ /// Returned boxed and `#[inline(never)]` on purpose: an `async fn` body is+ /// otherwise re-instantiated inside every crate / codegen unit that awaits+ /// it, and this state machine is large. Boxing here keeps one copy,+ /// compiled in this crate.+ #[allow(clippy::too_many_arguments)]+ #[inline(never)]+ fn intercept_audited_inner<'a>(+ &'a self,+ tool_name: &'a str,+ action_summary: &'a str,+ args_redacted: serde_json::Value,+ park_bound: Option<Duration>,+ park_bound_elapsed: &'a mut bool,+ tool_call_id: Option<&'a str>,+ forced: bool,+ ) -> futures::future::BoxFuture<'a, (GateOutcome, Option<String>)> {+ Box::pin(self.intercept_audited_inner_body(+ tool_name,+ action_summary,+ args_redacted,+ park_bound,+ park_bound_elapsed,+ tool_call_id,+ forced,+ ))+ }++ #[allow(clippy::too_many_arguments)]+ async fn intercept_audited_inner_body(&self,tool_name: &str,action_summary: &str,