Skip to content

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

fix(security): correct approval gate intercept to use event projection

Steven Enamakel54e3ca4cb511
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
index 6cd169b855..4a90317887 100644
--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
@@ -506,22 +506,23 @@ impl EventListener for OpenhumanEventBridge {
.lock()
.unwrap_or_else(|p| p.into_inner())
.insert(call_id.as_str().to_string(), std::time::Instant::now());
- // The harness start event carries no call input (`ToolStarted`
- // has only `call_id`/`tool_name`), so the label/detail are
- // computed against empty args here — a tool whose label
- // doesn't depend on its arguments (the common case: a policy
- // label, or a name-derived default) already reads correctly;
- // one whose detail DOES depend on args (e.g. a search query)
- // is recomputed with the real arguments on `ToolCallCompleted`
- // below and forwarded on the wire as
+ // The harness start event now carries the captured call
+ // input when payload capture is on (tinyagents#211); fall
+ // back to `Value::Null` when it's off, same as before. A
+ // tool whose label doesn't depend on its arguments (the
+ // common case: a policy label, or a name-derived default)
+ // already reads correctly with real input; one whose detail
+ // DOES depend on args (e.g. a search query) is recomputed
+ // with the real arguments on `ToolCallCompleted` below and
+ // forwarded on the wire as
// `tool_display_label`/`tool_display_detail` there too.
- let (display_label, display_detail) =
- self.resolve_display(tool_name, &serde_json::Value::Null);
+ let arguments = input.clone().unwrap_or(serde_json::Value::Null);
+ let (display_label, display_detail) = self.resolve_display(tool_name, &arguments);
match &self.scope {
None => self.send(AgentProgress::ToolCallStarted {
call_id: call_id.as_str().to_string(),
tool_name: tool_name.clone(),
- arguments: serde_json::Value::Null,
+ arguments,
iteration,
display_label,
display_detail,
@@ -531,7 +532,7 @@ impl EventListener for OpenhumanEventBridge {
task_id: s.task_id.clone(),
call_id: call_id.as_str().to_string(),
tool_name: tool_name.clone(),
- arguments: serde_json::Value::Null,
+ arguments,
iteration,
display_label,
display_detail,
diff --git a/crates/openhuman-core/src/security/approval/gate_intercept.rs b/crates/openhuman-core/src/security/approval/gate_intercept.rs
index 1726274499..ca7636e254 100644
--- a/crates/openhuman-core/src/security/approval/gate_intercept.rs
+++ b/crates/openhuman-core/src/security/approval/gate_intercept.rs
@@ -426,6 +426,7 @@ impl ApprovalGate {
created_at: now,
expires_at,
source_context: source_context.clone(),
+ tool_call_id: tool_call_id.map(str::to_string),
};
// Register the waiter BEFORE persisting the row so a fast
@@ -445,9 +446,23 @@ impl ApprovalGate {
.lock()
.insert(thread_id.clone(), request_id.clone());
}
+ // Record the full routing correlation (thread/client/tool_call_id) so
+ // whichever path resolves this request's decision — `decide()`, the
+ // TTL timeout, or a dropped decision channel, all below — can mirror
+ // it onto `ApprovalDecided` without re-deriving it from ambient
+ // task-locals that may no longer be in scope by then.
+ self.insert_request_route(
+ &request_id,
+ RequestRoute {
+ thread_id: chat_thread_id.clone(),
+ client_id: chat_client_id.clone(),
+ tool_call_id: tool_call_id.map(str::to_string),
+ },
+ );
if let Err(err) = store::insert_pending(&self.config, &pending, &self.session_id) {
self.evict_waiter(&request_id);
self.clear_thread(&chat_thread_id, &request_id);
+ self.take_request_route(&request_id);
tracing::error!(
error = %err,
tool = tool_name,
diff --git a/crates/openhuman-core/src/web_chat/event_bus.rs b/crates/openhuman-core/src/web_chat/event_bus.rs
index 44ef0c736f..0da6f801a9 100644
--- a/crates/openhuman-core/src/web_chat/event_bus.rs
+++ b/crates/openhuman-core/src/web_chat/event_bus.rs
@@ -193,8 +193,27 @@ impl EventHandler<DomainEvent> for AgentSurfaceSubscriber {
item_id,
text_preview,
..
+ } => {
+ let Some(item_id) = item_id.clone() else {
+ return;
+ };
+ let lane = Some(mode.clone());
+ log::debug!(
+ "[web-channel] agent-surface emitting queue_item_delivered thread_id={thread_id} item_id={item_id}"
+ );
+ publish_web_channel_event(WebChannelEvent {
+ event: "queue_item_delivered".to_string(),
+ client_id: String::new(),
+ thread_id: thread_id.clone(),
+ queue_item: Some(crate::core::socketio::QueueItemPayload {
+ id: item_id,
+ lane,
+ text_preview: text_preview.clone(),
+ }),
+ ..Default::default()
+ });
}
- | DomainEvent::RunQueueFollowupDispatched {
+ DomainEvent::RunQueueFollowupDispatched {
thread_id,
item_id,
text_preview,
@@ -209,10 +228,7 @@ impl EventHandler<DomainEvent> for AgentSurfaceSubscriber {
let Some(item_id) = item_id.clone() else {
return;
};
- let lane = match event {
- DomainEvent::RunQueueMessageDelivered { .. } => Some(mode.clone()),
- _ => None,
- };
+ let lane = None;
log::debug!(
"[web-channel] agent-surface emitting queue_item_delivered thread_id={thread_id} item_id={item_id}"
);