Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(composio): box the resolved config in execute_unredacted returns

oxoxDev8c7ef3f2eed9
diff --git a/crates/openhuman-core/src/integrations/composio/action_tool.rs b/crates/openhuman-core/src/integrations/composio/action_tool.rs
index cfbc160046..13f894288e 100644
--- a/crates/openhuman-core/src/integrations/composio/action_tool.rs
+++ b/crates/openhuman-core/src/integrations/composio/action_tool.rs
@@ -254,8 +254,13 @@ impl ComposioActionTool {
/// 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();
+ async fn execute_unredacted(&self, args: Value) -> (Box<Config>, anyhow::Result<ToolResult>) {
+ // Boxed from the moment it exists, not just at the return: this
+ // local is held across every await point below, and `Config` is a
+ // large top-level struct — inlining it by value in the generated
+ // async state machine was enough to blow a 2 MiB worker-thread
+ // stack (the default for both `cargo test` and tokio).
+ let fallback_config = || Box::new(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
@@ -299,7 +304,7 @@ impl ComposioActionTool {
// re-resolving process-global `OPENHUMAN_WORKSPACE` (the tool is scoped to
// the user/workspace it was created for).
let live_config = match self.live_config().await {
- Ok(c) => c,
+ Ok(c) => Box::new(c),
Err(e) => {
tracing::warn!(
tool = %self.action_name,
diff --git a/crates/openhuman-core/src/integrations/composio/tools/execute.rs b/crates/openhuman-core/src/integrations/composio/tools/execute.rs
index ee90648ea3..ddfa68d6b3 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/execute.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/execute.rs
@@ -111,7 +111,7 @@ impl ComposioExecuteTool {
/// so [`Tool::execute`] redacts against the same credential that ran —
/// not the possibly-stale snapshot captured when this tool was
/// registered.
- async fn execute_unredacted(&self, args: Value) -> (Config, anyhow::Result<ToolResult>) {
+ async fn execute_unredacted(&self, args: Value) -> (Box<Config>, anyhow::Result<ToolResult>) {
let tool = args
.get("tool")
.and_then(|v| v.as_str())
@@ -120,7 +120,7 @@ impl ComposioExecuteTool {
.to_string();
if tool.is_empty() {
return (
- self.config.as_ref().clone(),
+ Box::new(self.config.as_ref().clone()),
Ok(ToolResult::error(
"composio_execute: 'tool' is required (e.g. GMAIL_SEND_EMAIL)",
)),
@@ -175,7 +175,7 @@ impl ComposioExecuteTool {
scope.as_str()
);
return (
- self.config.as_ref().clone(),
+ Box::new(self.config.as_ref().clone()),
Ok(ToolResult::error(format!(
"composio_execute: action `{tool}` is classified `{}` and is refused \
because the calling agent is in strict read-only mode. Only `read`-scoped \
@@ -204,7 +204,10 @@ impl ComposioExecuteTool {
scope = scope.as_str(),
"[composio][scopes] execute blocked by user scope pref"
);
- return (self.config.as_ref().clone(), Ok(ToolResult::error(msg)));
+ return (
+ Box::new(self.config.as_ref().clone()),
+ Ok(ToolResult::error(msg)),
+ );
}
ToolDecision::NotCurated => {
let toolkit = toolkit_from_slug(&tool).unwrap_or_default();
@@ -214,7 +217,7 @@ impl ComposioExecuteTool {
"[composio][scopes] execute blocked: action not in curated whitelist"
);
return (
- self.config.as_ref().clone(),
+ Box::new(self.config.as_ref().clone()),
Ok(ToolResult::error(format!(
"composio_execute: action `{tool}` is not in the curated whitelist for \
toolkit `{toolkit}`. Use composio_list_tools to see available actions."
@@ -258,11 +261,11 @@ impl ComposioExecuteTool {
// executions through the backend tinyhumans tenant regardless
// of mode — silently breaking direct mode for tool execution.
let live_config = match live_composio_config(self.config.as_ref()).await {
- Ok(c) => c,
+ Ok(c) => Box::new(c),
Err(e) => {
tracing::warn!(error = %e, "[composio] tool execute.execute: load_config failed");
return (
- self.config.as_ref().clone(),
+ Box::new(self.config.as_ref().clone()),
Ok(ToolResult::error(format!(
"composio_execute: failed to load live config: {e}"
))),
diff --git a/crates/openhuman-core/src/integrations/composio/tools/list_connections.rs b/crates/openhuman-core/src/integrations/composio/tools/list_connections.rs
index d80cc1b887..53b6dfa63e 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/list_connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/list_connections.rs
@@ -57,7 +57,7 @@ impl ComposioListConnectionsTool {
/// so [`Tool::execute`] redacts against the same credential that ran —
/// not the possibly-stale snapshot captured when this tool was
/// registered.
- async fn execute_unredacted(&self, _args: Value) -> (Config, anyhow::Result<ToolResult>) {
+ async fn execute_unredacted(&self, _args: Value) -> (Box<Config>, anyhow::Result<ToolResult>) {
tracing::debug!("[composio] tool list_connections.execute");
// Mirror `ops::composio_list_connections`: route through the mode-aware
// factory so the agent sees the correct tenant's connections in both
@@ -65,12 +65,17 @@ impl ComposioListConnectionsTool {
// empty list regardless of the user's actual Composio connections,
// which caused the agent to incorrectly conclude that no integrations
// were linked and prompt unnecessary re-authorization (#1710).
+ //
+ // Boxed from the moment it exists (not just at the return): held
+ // across every await point below, and `Config` is large enough that
+ // inlining it by value in the generated async state machine blows a
+ // 2 MiB worker-thread stack (the default for `cargo test` and tokio).
let live_config = match live_composio_config(self.config.as_ref()).await {
- Ok(c) => c,
+ Ok(c) => Box::new(c),
Err(e) => {
tracing::warn!(error = %e, "[composio] list_connections.execute: load_config failed");
return (
- self.config.as_ref().clone(),
+ Box::new(self.config.as_ref().clone()),
Ok(ToolResult::error(format!(
"composio_list_connections: failed to load live config: {e}"
))),
diff --git a/crates/openhuman-core/src/integrations/composio/tools/list_toolkits.rs b/crates/openhuman-core/src/integrations/composio/tools/list_toolkits.rs
index 0f6c8e97a2..41025914df 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/list_toolkits.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/list_toolkits.rs
@@ -59,7 +59,7 @@ impl ComposioListToolkitsTool {
/// so [`Tool::execute`] redacts against the same credential that ran —
/// not the possibly-stale snapshot captured when this tool was
/// registered.
- async fn execute_unredacted(&self, _args: Value) -> (Config, anyhow::Result<ToolResult>) {
+ async fn execute_unredacted(&self, _args: Value) -> (Box<Config>, anyhow::Result<ToolResult>) {
tracing::debug!("[composio] tool list_toolkits.execute");
// Mirror the mode-aware pattern in
// `ops::composio_list_toolkits`. In direct mode there is no
@@ -67,12 +67,17 @@ impl ComposioListToolkitsTool {
// governs availability, so we return an empty toolkits list
// with an explanatory log instead of silently routing through
// the backend tinyhumans tenant (#1710).
+ //
+ // Boxed from the moment it exists (not just at the return): held
+ // across every await point below, and `Config` is large enough that
+ // inlining it by value in the generated async state machine blows a
+ // 2 MiB worker-thread stack (the default for `cargo test` and tokio).
let live_config = match live_composio_config(self.config.as_ref()).await {
- Ok(c) => c,
+ Ok(c) => Box::new(c),
Err(e) => {
tracing::warn!(error = %e, "[composio] tool: load_config failed");
return (
- self.config.as_ref().clone(),
+ Box::new(self.config.as_ref().clone()),
Ok(ToolResult::error(format!(
"composio: failed to load live config: {e}"
))),
diff --git a/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs b/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs
index cca59d7f93..f530829f49 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs
@@ -110,7 +110,7 @@ impl ComposioListToolsTool {
&self,
args: Value,
options: ToolCallOptions,
- ) -> (Config, anyhow::Result<ToolResult>) {
+ ) -> (Box<Config>, anyhow::Result<ToolResult>) {
let toolkits = args.get("toolkits").and_then(|v| v.as_array()).map(|arr| {
arr.iter()
.filter_map(|v| v.as_str().map(str::to_string))
@@ -150,12 +150,16 @@ impl ComposioListToolsTool {
// pattern. Surfacing the empty list explicitly is correct
// fail-mode: the alternative — falling through to the backend
// path — is exactly the bug we're closing (#1710).
+ // Boxed from the moment it exists (not just at the return): held
+ // across every await point below, and `Config` is large enough that
+ // inlining it by value in the generated async state machine blows a
+ // 2 MiB worker-thread stack (the default for `cargo test` and tokio).
let live_config = match live_composio_config(self.config.as_ref()).await {
- Ok(c) => c,
+ Ok(c) => Box::new(c),
Err(e) => {
tracing::warn!(error = %e, "[composio] tool: load_config failed");
return (
- self.config.as_ref().clone(),
+ Box::new(self.config.as_ref().clone()),
Ok(ToolResult::error(format!(
"composio: failed to load live config: {e}"
))),