Skip to content

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

fix(approval): handle missing approval store in steering forwarder

Steven Enamakel919e904f685a
diff --git a/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs b/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs
index 577fc25c1e..2e2826e480 100644
--- a/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs
@@ -281,6 +281,16 @@ impl Drop for SteeringForwarderGuard {
}
let requeued = requeue_texts.len();
let thread_label = self.thread_label.clone();
+ let (first_item_id, first_text_preview) = requeue_texts
+ .first()
+ .map(|(text, _lane)| {
+ (
+ uuid::Uuid::new_v4().to_string(),
+ crate::agent::queued_turn::text_preview(text),
+ )
+ })
+ .map(|(id, preview)| (Some(id), Some(preview)))
+ .unwrap_or((None, None));
// `RunQueue::push` is async (tokio `Mutex`); `Drop` is synchronous. Push
// the recovered steers back on a detached task so they land in the
diff --git a/crates/openhuman-core/src/security/approval/store.rs b/crates/openhuman-core/src/security/approval/store.rs
index fd81697802..9e386ab0d8 100644
--- a/crates/openhuman-core/src/security/approval/store.rs
+++ b/crates/openhuman-core/src/security/approval/store.rs
@@ -28,6 +28,8 @@ use chrono::{DateTime, Utc};
use rusqlite::{params, types::Type, Connection};
use crate::config::Config;
+use crate::core::bus::BUS;
+use crate::core::events::DomainEvent;
use crate::memory::safety::sanitize_text;
use super::types::{
diff --git a/crates/openhuman-core/src/security/approval/types.rs b/crates/openhuman-core/src/security/approval/types.rs
index ef1f17d89a..4e5facb29d 100644
--- a/crates/openhuman-core/src/security/approval/types.rs
+++ b/crates/openhuman-core/src/security/approval/types.rs
@@ -35,6 +35,13 @@ pub struct PendingApproval {
/// optional and additive so the chat path's wire shape never changes.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source_context: Option<ApprovalSourceContext>,
+ /// The gated tool call's provider-assigned call id, when the parked call
+ /// originated from a tracked tool-call turn. Lets a frontend correlate
+ /// the approval card back to the exact `tool_call` timeline row instead
+ /// of matching on tool name. `None` for non-tracked callers (CLI, cron,
+ /// workflows) and for rows persisted before this field existed.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tool_call_id: Option<String>,
}
impl PendingApproval {
@@ -55,9 +62,16 @@ impl PendingApproval {
created_at: Utc::now(),
expires_at,
source_context: None,
+ tool_call_id: None,
}
}
+ /// Attach the gated tool call's provider-assigned call id.
+ pub fn with_tool_call_id(mut self, tool_call_id: impl Into<String>) -> Self {
+ self.tool_call_id = Some(tool_call_id.into());
+ self
+ }
+
/// Attach an [`ApprovalSourceContext`] — used by
/// [`super::gate::ApprovalGate`] when parking a `Workflow`-origin tool
/// call so the row (and the `approval_list_pending` JSON the frontend