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(composio): redact per-action outcomes with the config that dispatched
oxoxDev6e02e9aa8187
diff --git a/crates/openhuman-core/src/integrations/composio/action_tool.rs b/crates/openhuman-core/src/integrations/composio/action_tool.rsindex db9ff1ad1a..cfbc160046 100644--- a/crates/openhuman-core/src/integrations/composio/action_tool.rs+++ b/crates/openhuman-core/src/integrations/composio/action_tool.rs@@ -244,16 +244,18 @@ impl Tool for ComposioActionTool {}async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {- let outcome = Box::pin(self.execute_unredacted(args)).await;- match self.config.as_deref() {- Some(config) => super::tools::redact_composio_outcome(config, outcome),- None => outcome,- }+ let (config, outcome) = Box::pin(self.execute_unredacted(args)).await;+ super::tools::redact_composio_outcome(&config, outcome)}}impl ComposioActionTool {- async fn execute_unredacted(&self, args: Value) -> anyhow::Result<ToolResult> {+ /// Returns the config actually used for this call alongside the+ /// outcome, so [`Tool::execute`] always redacts against the same+ /// credential that dispatched — for both a spawn-time config and a+ /// deferred instance with none.+ async fn execute_unredacted(&self, args: Value) -> (Config, anyhow::Result<ToolResult>) {+ let fallback_config = || self.config.as_deref().cloned().unwrap_or_default();// Agent-level sandbox gate (issue #685, CodeRabbit follow-up on// PR #904) — mirrors the check in// [`super::tools::ComposioExecuteTool::execute`] so a read-only@@ -274,13 +276,16 @@ impl ComposioActionTool {"[composio][sandbox] per-action execute blocked: agent is read-only, action is {}",scope.as_str());- return Ok(ToolResult::error(format!(- "{}: action is classified `{}` and is refused because the calling \- agent is in strict read-only mode. Only `read`-scoped actions are \- available to this agent.",- self.action_name,- scope.as_str()- )));+ return (+ fallback_config(),+ Ok(ToolResult::error(format!(+ "{}: action is classified `{}` and is refused because the calling \+ agent is in strict read-only mode. Only `read`-scoped actions are \+ available to this agent.",+ self.action_name,+ scope.as_str()+ ))),+ );}}@@ -301,10 +306,13 @@ impl ComposioActionTool {error = %e,"[composio] per-action execute: load_config failed");- return Ok(ToolResult::error(format!(- "{}: failed to load live config: {e}",- self.action_name- )));+ return (+ fallback_config(),+ Ok(ToolResult::error(format!(+ "{}: failed to load live config: {e}",+ self.action_name+ ))),+ );}};@@ -326,7 +334,7 @@ impl ComposioActionTool {tool = %self.action_name,"[composio][contract-gate] returning full contract before first execute");- return Ok(ToolResult::error(contract));+ return (live_config, Ok(ToolResult::error(contract)));}super::contract_gate::GateDecision::Proceed => {}}@@ -378,7 +386,7 @@ impl ComposioActionTool {.await;let elapsed_ms = started.elapsed().as_millis() as u64;- match res {+ let outcome = match res {Ok(resp) => {crate::core::bus::BUS.publish(crate::core::events::DomainEvent::ComposioActionExecuted {@@ -423,7 +431,8 @@ impl ComposioActionTool {);Ok(ToolResult::error(e))}- }+ };+ (live_config, outcome)}}diff --git a/crates/openhuman-core/src/integrations/composio/action_tool_tests.rs b/crates/openhuman-core/src/integrations/composio/action_tool_tests.rsindex eb4c392861..f922bbc227 100644--- a/crates/openhuman-core/src/integrations/composio/action_tool_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/action_tool_tests.rs@@ -416,3 +416,89 @@ async fn mode_toggle_between_calls_is_observed() {"direct-mode tool must not surface backend-session artifacts: {direct_msg}");}++// ── Redaction uses the config that actually dispatched (PR #6689) ──+//+// `execute_unredacted` now returns the config it resolved alongside the+// outcome, and `execute` redacts against that returned config instead of+// `self.config` — see CodeRabbit findings 447c07b7 (deferred instances+// skipped redaction entirely) and the sibling `redact.rs:90` finding+// (a configured instance redacted against its stale registration-time+// snapshot instead of the live, reloaded config used for dispatch).++#[tokio::test]+async fn deferred_instance_returns_live_config_for_redaction() {+ use crate::config::TEST_ENV_LOCK;+ let _env_guard = TEST_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());+ let _serialised = super::super::module_client::module_guard().await;++ let tmp = tempfile::tempdir().expect("tempdir");+ let _workspace_guard = WorkspaceEnvGuard::set(tmp.path());+ let mut config = Config::default();+ config.config_path = tmp.path().join("config.toml");+ config.workspace_dir = tmp.path().join("workspace");+ config.composio.mode = crate::config::schema::COMPOSIO_MODE_DIRECT.to_string();+ config.composio.api_key = Some("test-direct-key-for-deferred-redaction".to_string());+ config.save().await.expect("save config to disk");++ // Deferred instances (the parent-session catalogue synthesised beside+ // delegation tools) have no spawn-time config to anchor to — `config`+ // is `None` — so before this fix `execute()`'s `None => outcome` arm+ // returned every deferred outcome completely unredacted.+ let t = ComposioActionTool::deferred(+ "gmail",+ "GMAIL_FETCH_EMAILS".to_string(),+ "fetch".to_string(),+ None,+ );+ assert!(t.config.is_none(), "deferred instances carry no spawn-time config");++ let (live_config, _outcome) = t.execute_unredacted(serde_json::json!({})).await;+ assert_eq!(+ live_config.composio.api_key.as_deref(),+ Some("test-direct-key-for-deferred-redaction"),+ "a deferred instance must return the live config actually used for dispatch, \+ not a default placeholder — otherwise execute() has nothing to redact against"+ );+}++#[tokio::test]+async fn configured_instance_returns_live_config_not_the_stale_snapshot() {+ use crate::config::TEST_ENV_LOCK;+ let _env_guard = TEST_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());+ let _serialised = super::super::module_client::module_guard().await;++ let tmp = tempfile::tempdir().expect("tempdir");+ let _workspace_guard = WorkspaceEnvGuard::set(tmp.path());++ // The on-disk config is the source of truth `live_composio_config`+ // reloads from; it holds the CURRENT (rotated) key.+ let mut on_disk = Config::default();+ on_disk.config_path = tmp.path().join("config.toml");+ on_disk.workspace_dir = tmp.path().join("workspace");+ on_disk.composio.mode = crate::config::schema::COMPOSIO_MODE_DIRECT.to_string();+ on_disk.composio.api_key = Some("rotated-key-after-registration".to_string());+ on_disk.save().await.expect("save config to disk");++ // The tool's own spawn-time snapshot is stale — it still carries the+ // key that was active when the sub-agent was created, before a+ // mid-session credential rotation.+ let mut stale_snapshot = on_disk.clone();+ stale_snapshot.composio.api_key = Some("stale-key-from-registration".to_string());++ let t = ComposioActionTool::new(+ Arc::new(stale_snapshot),+ "GMAIL_FETCH_EMAILS".to_string(),+ "fetch".to_string(),+ None,+ );++ let (live_config, _outcome) = t.execute_unredacted(serde_json::json!({})).await;+ assert_eq!(+ live_config.composio.api_key.as_deref(),+ Some("rotated-key-after-registration"),+ "execute_unredacted must return the live (reloaded) config used for dispatch, \+ not the stale spawn-time snapshot — otherwise redaction misses a key rotated \+ mid-session"+ );+}