Skip to content

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

fix(flows): unwrap capability errors before surfacing them

Steven Enamakel8e120e340f63
diff --git a/crates/openhuman-core/src/flows/registration.rs b/crates/openhuman-core/src/flows/registration.rs
index dece227a3c..c22206c44f 100644
--- a/crates/openhuman-core/src/flows/registration.rs
+++ b/crates/openhuman-core/src/flows/registration.rs
@@ -98,7 +98,10 @@ pub(crate) fn tools(config: Arc<Config>, security: &Arc<SecurityPolicy>) -> Vec<
Box::new(ListAgentDefinitionsTool::new(host.clone())),
// Steer toolkit choice toward what's already connected + surface which
// toolkits a flow still needs (Phase 5, item 19). Read-only.
- Box::new(ListConnectableToolkitsTool::new(config.clone())),
+ Box::new(ListConnectableToolkitsTool::new(
+ config.clone(),
+ Arc::new(FlowsConnectionProvider),
+ )),
// Queryable DSL schema (F2): enumerate the 13 node kinds and fetch one
// kind's full config-field/port/example/gotcha contract — the DSL
// analogue of search_tool_catalog + get_tool_contract, so an agent need
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs b/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs
index 97fa173943..8d142307bd 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs
@@ -18,9 +18,9 @@ struct FlowPolicy;
impl FlowCallPolicy for FlowPolicy {
async fn tier_decision(&self, dispatch: &DispatchCtx, captured: &Config, live: &Config, security: &SecurityPolicy, class: tinybox_bus::CommandClass) -> std::result::Result<GateDecision, String> {
let policy = super::super::tier_policy_from_config(dispatch, captured, Some(live), security)
- .map_err(|error| error.to_string())?;
+ .map_err(capability_payload)?;
super::super::enforce_node_tier_gate(&policy, class, "tool_call")
- .map_err(|error| error.to_string())
+ .map_err(capability_payload)
}
async fn approve(&self, dispatch: &DispatchCtx, approval: &ApprovalTurnContext, decision: GateDecision, slug: &str, args: &Value) -> std::result::Result<Option<String>, String> {
let summary = crate::security::approval::summarize_action(slug, args);
@@ -34,11 +34,22 @@ impl FlowCallPolicy for FlowPolicy {
fn record(&self, audit_id: &str, result: &std::result::Result<Value, String>) {
if let Some(gate) = crate::security::approval::ApprovalGate::try_global() {
let outcome = if result.is_ok() { crate::security::approval::ExecutionOutcome::Success } else { crate::security::approval::ExecutionOutcome::Failure };
- gate.record_execution(audit_id, outcome, result.as_ref().err().map(String::as_str));
+ let display_error = result
+ .as_ref()
+ .err()
+ .map(|message| EngineError::Capability(message.clone()).to_string());
+ gate.record_execution(audit_id, outcome, display_error.as_deref());
}
}
}
+fn capability_payload(error: EngineError) -> String {
+ match error {
+ EngineError::Capability(message) => message,
+ other => other.to_string(),
+ }
+}
+
#[async_trait]
impl ToolBackend for ComposioToolBackend {
fn name(&self) -> &'static str { "composio" }