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(tinyagents): redact secrets from tool payloads before journaling
Steven Enamakelcf8826fb6dcf
diff --git a/crates/openhuman-core/src/agent/session_import/live.rs b/crates/openhuman-core/src/agent/session_import/live.rsindex 60e88d6669..d3f136ac8c 100644--- a/crates/openhuman-core/src/agent/session_import/live.rs+++ b/crates/openhuman-core/src/agent/session_import/live.rs@@ -22,12 +22,12 @@ pub const TINYAGENTS_SESSION_KV_STORE: &str = "openhuman_sessions";////// Best-effort: `None` when the config (hence workspace) cannot be resolved and/// no store is installed.-pub async fn session_kv_store() -> Option<Arc<dyn Store>> {+pub async fn session_kv_store(ctx: &DispatchCtx) -> Option<Arc<dyn Store>> {if let Some(stores) = crate::agent::session_store::current() {log::debug!("[session-store] registering the host session store's kv on RunContext.stores");return Some(stores.kv);}- let cfg = match crate::config::ops::load_current_or_init(&DispatchCtx::ambient()).await {+ let cfg = match crate::config::ops::load_current_or_init(ctx).await {Ok(cfg) => cfg,Err(err) => {log::warn!("[session-store] cannot resolve config for store registration: {err:#}");diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rsindex f42887f0b9..5d1806eb05 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs@@ -167,7 +167,8 @@ impl OpenHumanHostBundleFactory {// a screen may run on another task, so no ambient scope is consulted.let mut security = OpenHumanSecurityGate::new(inputs.security_policy, inputs.tool_sets).with_input_screening(!turn.untrusted_input_turn)- .with_approval(turn.approval.clone());+ .with_approval(turn.approval.clone())+ .with_dispatch(turn.dispatch_ctx());if let Some(policy) = inputs.tool_policy {security = security.with_tool_policy(policy);}diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rsindex 8f8495a5c3..3e7bec4e5a 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs@@ -152,6 +152,9 @@ pub struct OpenHumanSecurityGate {/// The owning turn's approval context (chat routing, copilot flag, flow/// run), read from the turn's explicit run context when the gate is built.approval: ApprovalTurnContext,+ /// The owning turn's dispatch context, read from the turn's run context+ /// when the gate is built; `None` falls back to the calling task's.+ dispatch: Option<DispatchCtx>,}impl OpenHumanSecurityGate {@@ -170,9 +173,16 @@ impl OpenHumanSecurityGate {pending_audit: Mutex::new(HashMap::new()),screens_input: true,approval: ApprovalTurnContext::default(),+ dispatch: None,}}+ /// Binds the owning turn's dispatch context.+ pub fn with_dispatch(mut self, dispatch: DispatchCtx) -> Self {+ self.dispatch = Some(dispatch);+ self+ }+/// Binds the owning turn's approval context, so a parked approval is routed/// to the turn's chat surface and stamped with its flow run.pub fn with_approval(mut self, approval: ApprovalTurnContext) -> Self {@@ -415,7 +425,11 @@ impl OpenHumanSecurityGate {#[cfg(feature = "modules")]let desktop_approval_disabled = match self.resolve_tool(&call.tool_name) {Some(tool) => {- crate::desktop::control::approvals_disabled_for(&DispatchCtx::ambient(), tool).await+ crate::desktop::control::approvals_disabled_for(+ &self.dispatch.clone().unwrap_or_else(DispatchCtx::ambient),+ tool,+ )+ .await}None => false,};diff --git a/crates/openhuman-core/src/agent/tinyagents/journal.rs b/crates/openhuman-core/src/agent/tinyagents/journal.rsindex 0a957aa862..cfd7090488 100644--- a/crates/openhuman-core/src/agent/tinyagents/journal.rs+++ b/crates/openhuman-core/src/agent/tinyagents/journal.rs@@ -95,8 +95,8 @@ pub(crate) fn take_request_journal_run(request_id: &str) -> Option<String> {/// Resolve the workspace directory the tenant's journal and run-status stores/// belong to (the storage backend is resolved from it). Async because the/// config load is async; errors are surfaced so callers can log-and-skip.-async fn resolve_workspace() -> anyhow::Result<PathBuf> {- let config = crate::config::ops::load_current_or_init(&DispatchCtx::ambient())+async fn resolve_workspace(ctx: &DispatchCtx) -> anyhow::Result<PathBuf> {+ let config = crate::config::ops::load_current_or_init(ctx).await.map_err(|e| anyhow::anyhow!("[journal] load config for workspace: {e}"))?;Ok(config.workspace_dir)@@ -104,8 +104,8 @@ async fn resolve_workspace() -> anyhow::Result<PathBuf> {/// The journal and run-status stores a turn's events and status go to: the/// calling tenant's, in the storage backend.-async fn journal_stores() -> anyhow::Result<(Arc<dyn AppendStore>, DriverStatusStore)> {- let workspace = resolve_workspace().await?;+async fn journal_stores(ctx: &DispatchCtx) -> anyhow::Result<(Arc<dyn AppendStore>, DriverStatusStore)> {+ let workspace = resolve_workspace(ctx).await?;let stores = crate::agent::session_store::stores_or_ephemeral(&workspace);let status = crate::agent::session_store::status_store_for(&workspace);Ok((stores.journal, status))@@ -184,12 +184,13 @@ impl TurnJournal {/// [`OpenhumanEventBridge`]: crate::agent::tinyagents::observability::OpenhumanEventBridge/// [`EventSink::with_stream_id`]: tinyagents_harness::events::EventSink::with_stream_idpub(crate) async fn attach_turn_journal(+ ctx: &DispatchCtx,events: &EventSink,model: &str,run_id: RunId,thread_id: Option<ThreadId>,) -> Option<TurnJournal> {- let (journal_store, status_store) = match journal_stores().await {+ let (journal_store, status_store) = match journal_stores(ctx).await {Ok(stores) => stores,Err(err) => {log::debug!("[journal] skipping journal attach; {err}");@@ -249,10 +250,11 @@ pub(crate) async fn attach_turn_journal(/// relying on transient `AgentProgress` buffering. Best-effort: a missing store/// or unknown run yields an empty `Vec`, not an error.pub(crate) async fn read_run_events(+ ctx: &DispatchCtx,run_id: &str,from_offset: u64,) -> anyhow::Result<Vec<AgentObservation>> {- let (journal_store, _) = journal_stores().await?;+ let (journal_store, _) = journal_stores(ctx).await?;let journal = StoreEventJournal::new(journal_store);journal.read_from(run_id, from_offset)diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rsindex 126fee2219..1ffaadf3e6 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs@@ -76,7 +76,12 @@ impl ApprovalSecurityMiddleware {.unwrap_or(false)}- pub(crate) async fn requires_approval(&self, name: &str, args: &serde_json::Value) -> bool {+ pub(crate) async fn requires_approval(+ &self,+ dispatch: &DispatchCtx,+ name: &str,+ args: &serde_json::Value,+ ) -> bool {#[cfg(feature = "modules")]let desktop_approval_disabled = match self.tool_sets@@ -85,11 +90,7 @@ impl ApprovalSecurityMiddleware {.find(|tool| tool.name() == name){Some(tool) => {- crate::desktop::control::approvals_disabled_for(- &DispatchCtx::ambient(),- tool.as_ref(),- )- .await+ crate::desktop::control::approvals_disabled_for(dispatch, tool.as_ref()).await}None => false,};@@ -108,12 +109,14 @@ impl ApprovalResolver<crate::agent::tinyagents::host::OpenHumanRunContext>{async fn requires_approval(&self,- _ctx: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,+ ctx: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,call: &TaToolCall,) -> bool {// Resolve external-effect up front so no tool borrow is held across the// approval await.- let has_ext = self.requires_approval(&call.name, &call.arguments).await;+ let has_ext = self+ .requires_approval(&ctx.data.dispatch_ctx(), &call.name, &call.arguments)+ .await;tracing::debug!(tool = %call.name,has_external_effect = has_ext,diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rsindex b5dcae0d50..feb411c9fa 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs@@ -335,7 +335,7 @@ impl ToolMiddleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>let desktop_approval_disabled = match self.resolve_tool(&call.name) {Some(tool) => {crate::desktop::control::approvals_disabled_for(- &crate::core::runtime::DispatchCtx::ambient(),+ &ctx.data.dispatch_ctx(),tool.as_ref(),).awaitdiff --git a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rsindex 2b044cd4c8..1d93b58599 100644--- a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs+++ b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs@@ -114,10 +114,12 @@ impl HarnessPayloadSummarizer<OpenHumanRunContext> for SubagentPayloadSummarizer"[payload_summarizer] prepared a summary call under the parent turn");+ let dispatch = parent_ctx.data.dispatch_ctx();Ok(Box::new(move |request: GenerateRequest| {+ let dispatch = dispatch.clone();Box::pin(async move {let config_loaded =- crate::config::ops::load_current_or_init(&DispatchCtx::ambient()).await;+ crate::config::ops::load_current_or_init(&dispatch).await;let (source, model) = subagent_host::resolve_subagent_source(&definition.model,&definition.id,diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rsindex bf8bd4cf91..18288a9a08 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs@@ -313,7 +313,7 @@ async fn drive_turn(}// `session_kv_store` self-gates on the dual-write flag (config default ON +// env kill switch), returning `None` when disabled or unresolvable.- if let Some(session_kv) = crate::agent::session_import::live::session_kv_store().await {+ if let Some(session_kv) = crate::agent::session_import::live::session_kv_store(&run_context.dispatch_ctx()).await {stores.get_or_insert_with(StoreRegistry::new).register(crate::agent::session_import::live::TINYAGENTS_SESSION_KV_STORE,session_kv,@@ -401,7 +401,7 @@ async fn drive_turn(.as_ref().map(|scope| tinyagents_harness::ids::ThreadId::new(scope.task_id.clone()));let turn_journal =- journal::attach_turn_journal(&sink, model, journal_run_id.clone(), journal_thread_id).await;+ journal::attach_turn_journal(&run_context.dispatch_ctx(), &sink, model, journal_run_id.clone(), journal_thread_id).await;if !is_subagent {if let Some(crate::agent::turn_origin::AgentTurnOrigin::WebChat {request_id: Some(request_id),