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
fix(network): allow host tool calls to bypass per-call approval
Steven Enamakel3f61502b1597
diff --git a/crates/openhuman-core/src/tools/impl/network/host.rs b/crates/openhuman-core/src/tools/impl/network/host.rsindex c7ed7ce6e2..b22ec2a51e 100644--- a/crates/openhuman-core/src/tools/impl/network/host.rs+++ b/crates/openhuman-core/src/tools/impl/network/host.rs@@ -33,7 +33,9 @@ fn http_limits() -> HttpLimits {/// HTML detection and extraction execute in the lazily loaded TinyJuice module.#[derive(Debug)]-struct TinyJuiceHtml;+struct TinyJuiceHtml {+ ctx: DispatchCtx,+}#[async_trait::async_trait]impl AsyncHtmlExtractor for TinyJuiceHtml {@@ -48,7 +50,7 @@ impl AsyncHtmlExtractor for TinyJuiceHtml {}async fn to_markdown(&self, html: &str) -> anyhow::Result<String> {- crate::inference::tokenjuice::extract_html(&DispatchCtx::ambient(), html.to_string())+ crate::inference::tokenjuice::extract_html(&self.ctx, html.to_string()).await.map_err(anyhow::Error::msg)}@@ -60,16 +62,25 @@ impl AsyncHtmlExtractor for TinyJuiceHtml {/// disclosures and x402 quotes carry no chat routing. A chat turn registers/// [`routed_http_request_tool`] instead.pub fn http_request_tool(+ ctx: &DispatchCtx,gate: Arc<dyn NetGate>,allowed_domains: Vec<String>,max_response_size: usize,timeout_secs: u64,) -> HttpRequestTool {- http_request_tool_for(gate, None, allowed_domains, max_response_size, timeout_secs)+ http_request_tool_for(+ ctx,+ gate,+ None,+ allowed_domains,+ max_response_size,+ timeout_secs,+ )}/// [`http_request_tool`] whose x402 quotes are owned by `chat`.fn http_request_tool_for(+ ctx: &DispatchCtx,gate: Arc<dyn NetGate>,chat: Option<&ApprovalChatContext>,allowed_domains: Vec<String>,@@ -84,9 +95,9 @@ fn http_request_tool_for(http_limits(),);#[cfg(feature = "web3")]- let tool = tool.with_payment_hook(Arc::new(x402::X402PaymentHook::new(chat)));+ let tool = tool.with_payment_hook(Arc::new(x402::X402PaymentHook::new(ctx, chat)));#[cfg(not(feature = "web3"))]- let _ = chat;+ let _ = (ctx, chat);tool}@@ -98,8 +109,9 @@ pub fn routed_http_request_tool(max_response_size: usize,timeout_secs: u64,) -> PerCallTool<HttpRequestTool> {- PerCallTool::new(move |chat| {+ PerCallTool::new(move |chat, ctx| {http_request_tool_for(+ ctx,Arc::new(RoutedGate::new(Arc::clone(&policy), chat)),chat,allowed_domains.clone(),@@ -119,11 +131,12 @@ pub(crate) fn x402_request_tool(max_response_size: usize,timeout_secs: u64,) -> PerCallTool<impl Tool> {- PerCallTool::new(move |chat| {+ PerCallTool::new(move |chat, ctx| {let gate: Arc<dyn NetGate> = Arc::new(RoutedGate::new(Arc::clone(&policy), chat));X402RequestTool {gate: Arc::clone(&gate),inner: http_request_tool_for(+ ctx,gate,chat,allowed_domains.clone(),@@ -181,7 +194,7 @@ pub fn routed_curl_tool(max_download_bytes: u64,timeout_secs: u64,) -> PerCallTool<CurlTool> {- PerCallTool::new(move |chat| {+ PerCallTool::new(move |chat, _ctx| {CurlTool::new(Arc::new(RoutedGate::new(Arc::clone(&policy), chat)),allowed_domains.clone(),@@ -201,8 +214,9 @@ pub fn routed_web_fetch_tool(max_bytes: Option<usize>,timeout_secs: Option<u64>,) -> PerCallTool<WebFetchTool> {- PerCallTool::new(move |chat| {+ PerCallTool::new(move |chat, ctx| {web_fetch_tool(+ ctx,Arc::new(RoutedGate::new(Arc::clone(&policy), chat)),allowed_domains.clone(),max_bytes,@@ -214,6 +228,7 @@ pub fn routed_web_fetch_tool(/// `web_fetch`, converting HTML through TinyJuice and opting into TinyJuice's/// optional `summary_focus` argument.pub fn web_fetch_tool(+ ctx: &DispatchCtx,gate: Arc<dyn NetGate>,allowed_domains: Vec<String>,max_bytes: Option<usize>,@@ -225,7 +240,7 @@ pub fn web_fetch_tool(max_bytes,timeout_secs,http_limits(),- Arc::new(TinyJuiceHtml),+ Arc::new(TinyJuiceHtml { ctx: ctx.clone() }),)// Opts into a caller-steered summary; see `tokenjuice::focus`..with_schema_property(SUMMARY_FOCUS_ARG, summary_focus_property())@@ -260,12 +275,14 @@ mod x402 {/// held here and the hook is built per call.#[derive(Debug)]pub(super) struct X402PaymentHook {+ ctx: DispatchCtx,chat: Option<ApprovalChatContext>,}impl X402PaymentHook {- pub(super) fn new(chat: Option<&ApprovalChatContext>) -> Self {+ pub(super) fn new(ctx: &DispatchCtx, chat: Option<&ApprovalChatContext>) -> Self {Self {+ ctx: ctx.clone(),chat: chat.cloned(),}}@@ -285,7 +302,7 @@ mod x402 {.ok_or_else(|| {"402 response is missing a valid PAYMENT-REQUIRED header".to_string()})?;- let config = crate::core::runtime::DispatchCtx::ambient()+ let config = self.ctx.load_config().await.map_err(|error| format!("x402 payment failed: {error}"))?;diff --git a/crates/openhuman-core/src/tools/per_call.rs b/crates/openhuman-core/src/tools/per_call.rsindex c07d6e37cd..44df1264b5 100644--- a/crates/openhuman-core/src/tools/per_call.rs+++ b/crates/openhuman-core/src/tools/per_call.rs@@ -21,7 +21,8 @@ use tinytools::{ToolPolicy, ToolResult, ToolRunContext, ToolScope, ToolSpec, ToolTimeout,};-use crate::agent::tinyagents::host::run_context::approval_for_tool;+use crate::agent::tinyagents::host::run_context::{approval_for_tool, dispatch_ctx_for_tool};+use crate::core::runtime::DispatchCtx;use crate::security::approval::ApprovalChatContext;/// Builds the tool one call runs, from that call's chat routing and the