Skip to content

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

feat(agent): gate tool calls through security checks before execution

Steven Enamakel33b174aee973
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
index dab110cf3c..dc154a5172 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
@@ -93,15 +93,21 @@ pub(super) async fn await_pending(handle: Option<tokio::task::JoinHandle<()>>) {
return;
};
let started = Instant::now();
- match tokio::time::timeout(PENDING_POST_COMMIT_WAIT, handle).await {
+ let mut handle = handle;
+ match tokio::time::timeout(PENDING_POST_COMMIT_WAIT, &mut handle).await {
Ok(_) => tracing::debug!(
waited_ms = elapsed_ms(started),
"[session-runtime] post-commit: previous turn's deferred work settled before this turn"
),
- Err(_) => tracing::warn!(
- waited_ms = elapsed_ms(started),
- "[session-runtime] post-commit: previous turn's deferred work still running; proceeding"
- ),
+ Err(_) => {
+ // Abort so the wedged accounting cannot overlap this turn's own
+ // goal load/accounting and reorder goal budgets.
+ handle.abort();
+ tracing::warn!(
+ waited_ms = elapsed_ms(started),
+ "[session-runtime] post-commit: previous turn's deferred work still running; aborted and proceeding"
+ );
+ }
}
}
diff --git a/crates/openhuman-core/src/agent/session_host/stop_summary.rs b/crates/openhuman-core/src/agent/session_host/stop_summary.rs
index 106091ce1f..428b1aaa11 100644
--- a/crates/openhuman-core/src/agent/session_host/stop_summary.rs
+++ b/crates/openhuman-core/src/agent/session_host/stop_summary.rs
@@ -263,7 +263,10 @@ pub(crate) fn render_stop_summary(results: &[CheckpointToolResult], stop_note: &
let mut out = format!("I stopped this turn early because {}.\n", kind.copy());
if !groups.is_empty() {
out.push_str("\n**What happened**\n");
- for group in groups.iter().take(MAX_LISTED) {
+ // Show the most recent groups (the immediate blocker is last), in
+ // chronological order.
+ let shown_from = groups.len().saturating_sub(MAX_LISTED);
+ for group in groups.iter().skip(shown_from) {
let name = crate::util::truncate_with_ellipsis(&group.name, 60);
let count = times(group.count);
let _ = if group.success {
@@ -274,7 +277,7 @@ pub(crate) fn render_stop_summary(results: &[CheckpointToolResult], stop_note: &
writeln!(out, "- `{name}` failed{count}: {}", group.error)
};
}
- let hidden: usize = groups.iter().skip(MAX_LISTED).map(|g| g.count).sum();
+ let hidden: usize = groups.iter().take(shown_from).map(|g| g.count).sum();
if hidden > 0 {
let _ = writeln!(out, "- …and {hidden} more tool call(s)");
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
index 29596112ba..4cf4e3e3ba 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
@@ -396,7 +396,7 @@ impl OpenHumanSecurityGate {
pub(crate) fn unanswered_approval_text(tool_name: &str) -> String {
format!(
"The approval request for '{tool_name}' was not answered in time, so it was not run. \
- Tell the user it is waiting on their approval and that they can ask again to retry. \
+ Tell the user the approval window expired and that they must ask again to retry. \
Do not retry this call yourself this turn and do not achieve the same result another \
way (shell, CLI, another tool)."
)
diff --git a/crates/openhuman-core/src/integrations/composio/tools/connect.rs b/crates/openhuman-core/src/integrations/composio/tools/connect.rs
index d85f747438..3d05b926c4 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/connect.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/connect.rs
@@ -73,7 +73,10 @@ pub(super) fn composio_connect_tool_timeout(
) -> tinytools::ToolTimeout {
match park_bound {
Some(bound) => tinytools::ToolTimeout::Millis(
- u64::try_from((bound + COMPOSIO_CONNECT_TIMEOUT_SLACK).as_millis()).unwrap_or(u64::MAX),
+ bound
+ .checked_add(COMPOSIO_CONNECT_TIMEOUT_SLACK)
+ .and_then(|total| u64::try_from(total.as_millis()).ok())
+ .unwrap_or(u64::MAX),
),
None => tinytools::ToolTimeout::Unbounded,
}