Skip to content

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

feat(agent): add live tool listing to session host

Steven Enamakel1db91379dcdf
diff --git a/crates/openhuman-core/src/agent/session_host/live_tools.rs b/crates/openhuman-core/src/agent/session_host/live_tools.rs
new file mode 100644
index 0000000000..7a6588e23d
--- /dev/null
+++ b/crates/openhuman-core/src/agent/session_host/live_tools.rs
@@ -0,0 +1,48 @@
+//! The tool surface a live voice session runs with.
+//!
+//! A live session borrows its tools from an ordinary session host so a spoken
+//! request reaches exactly what a typed one on the same agent would: the same
+//! registry, the same visible (policy-allowed) names and the same fail-closed
+//! tool policy. See `agent::tinyagents::live_harness`.
+
+use std::sync::Arc;
+
+use crate::agent::session_host::types::OpenHumanSessionHost;
+use crate::agent::tinyagents::live_harness::LiveToolSurface;
+use crate::agent::tinyagents::ToolPolicyEnforcement;
+
+impl OpenHumanSessionHost {
+ /// The durable tools, the visible names and the tool policy of this
+ /// session, for a live voice session. Synthesised delegation tools are
+ /// left out: a delegate needs the parent turn's execution context, which a
+ /// live session (no model loop on this side) does not have.
+ pub(crate) fn live_tool_surface(&self) -> LiveToolSurface {
+ let allowed = self
+ .visible_tool_names
+ .iter()
+ .filter(|name| self.tools.iter().any(|tool| tool.name() == name.as_str()))
+ .cloned()
+ .collect();
+ LiveToolSurface {
+ tool_sets: vec![Arc::clone(&self.tools)],
+ allowed,
+ tool_policy: Some(ToolPolicyEnforcement {
+ policy: self.tool_policy.clone(),
+ session: self.tool_policy_session.clone(),
+ session_id: self.event_session_id.clone(),
+ channel: self.event_channel.clone(),
+ agent_definition_id: self.agent_definition_id.clone(),
+ }),
+ has_thread: self.thread_id.is_some(),
+ }
+ }
+
+ /// The workspace descriptor tools run against.
+ pub(crate) fn live_workspace_descriptor(&self) -> Option<tinytools::WorkspaceDescriptor> {
+ self.workspace_descriptor.clone()
+ }
+}
+
+#[cfg(test)]
+#[path = "live_tools_tests.rs"]
+mod tests;