Skip to content

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

feat(embed): add turn control for embedded conversations

Steven Enamakel6898148fec69
diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rs
index 43b14a6ee7..0387c7eb53 100644
--- a/crates/openhuman-embed/src/turn.rs
+++ b/crates/openhuman-embed/src/turn.rs
@@ -79,6 +79,7 @@ pub struct Turn {
request: TurnRequest,
session_id: Option<String>,
origin: Option<AgentTurnOrigin>,
+ flow_run: Option<(String, String)>,
progress: Option<tokio::sync::mpsc::Sender<AgentProgress>>,
seed: Option<Vec<(String, String)>>,
attachments: Vec<openhuman_core::agent::HostAttachment>,
@@ -111,6 +112,7 @@ impl Turn {
request: TurnRequest::new(message),
session_id: None,
origin: None,
+ flow_run: None,
progress: None,
seed: None,
attachments: Vec::new(),
@@ -448,6 +450,17 @@ impl Turn {
self
}
+ /// Binds the turn to one run of a saved flow, so an approval a tool call
+ /// parks on this turn is correlated back to that exact flow and run. Pair
+ /// it with a [`TrustedAutomationSource::Workflow`] [`origin`](Self::origin):
+ /// the origin only names the flow, not the run.
+ ///
+ /// [`TrustedAutomationSource::Workflow`]: crate::TrustedAutomationSource::Workflow
+ pub fn flow_run(mut self, flow_id: impl Into<String>, run_id: impl Into<String>) -> Self {
+ self.flow_run = Some((flow_id.into(), run_id.into()));
+ self
+ }
+
/// Nucleus sampling for this turn; must be finite and between zero and one.
pub fn top_p(mut self, probability: f64) -> Self {
self.top_p = Some(probability);
diff --git a/crates/openhuman-embed/src/turn_control.rs b/crates/openhuman-embed/src/turn_control.rs
index 0602faaf1a..0e5675a4c5 100644
--- a/crates/openhuman-embed/src/turn_control.rs
+++ b/crates/openhuman-embed/src/turn_control.rs
@@ -344,6 +344,12 @@ impl Turn {
cancellation: self.native_cancellation.clone(),
hooks: std::mem::take(&mut self.hooks),
fresh_tool_snapshot: self.tools.is_some(),
+ approval: openhuman_core::security::approval::ApprovalTurnContext {
+ flow_run: self.flow_run.take().map(|(flow_id, run_id)| {
+ openhuman_core::security::approval::FlowRunContext { flow_id, run_id }
+ }),
+ ..Default::default()
+ },
..Default::default()
},
};