Skip to content

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

refactor(session-host): inline search tool rehydration into prelude

Steven Enamakel8fac9c2c5a5a
diff --git a/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs b/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs
index 80234375f4..2a2bdc0a9d 100644
--- a/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs
+++ b/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs
@@ -23,13 +23,37 @@ impl OpenHumanTurnPrelude {
actions.len(),
self.agent_definition_id
);
- let search_tools = super::super::recorded_tools::recorded_search_tools(recorded.specs());
- let mut mutable = self
+ // Search role tools ride in the same list; each rehydration pass
+ // keeps only the names it owns.
+ let mut actions = actions;
+ actions.extend(super::super::recorded_tools::recorded_search_tools(
+ recorded.specs(),
+ ));
+ self.mutable
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .recorded_integration_actions = actions;
+ }
+
+ /// Executors for the recorded search role tools that neither the base
+ /// surface nor this turn's synthesized tools supply.
+ #[cfg(feature = "modules")]
+ pub(super) fn rebuilt_search_tools(
+ &self,
+ base: &[Box<dyn tinytools::Tool>],
+ synthesized: &[Box<dyn tinytools::Tool>],
+ ) -> Vec<Box<dyn tinytools::Tool>> {
+ let recorded = self
.mutable
.lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner);
- mutable.recorded_integration_actions = actions;
- mutable.recorded_search_tools = search_tools;
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .recorded_integration_actions
+ .clone();
+ super::super::recorded_tools::rehydrate_search_tools(
+ &recorded,
+ &[base, synthesized],
+ &self.agent_definition_id,
+ )
}
pub(super) async fn refresh_turn_boundary(&self, cold: bool) {
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index d502379126..d9fe958503 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -159,9 +159,6 @@ struct OpenHumanTurnPreludeMutable {
/// executors whenever the live integrations list does not supply them
/// (see `recorded_tools`).
recorded_integration_actions: Vec<tinytools::ToolSpec>,
- /// Search role tools the resumed thread was sent (see
- /// `recorded_tools::rehydrate_search_tools`).
- recorded_search_tools: Vec<tinytools::ToolSpec>,
workflows: Vec<crate::skills::Workflow>,
composio_events: Option<tinybus::events::EventReceiver<crate::core::events::DomainEvent>>,
skill_events: Option<tinybus::events::EventReceiver<crate::core::events::DomainEvent>>,
@@ -482,20 +479,7 @@ impl OpenHumanTurnPrelude {
}
}
#[cfg(feature = "modules")]
- {
- let recorded = self
- .mutable
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner)
- .recorded_search_tools
- .clone();
- let rebuilt = super::recorded_tools::rehydrate_search_tools(
- &recorded,
- &[surface.tools.as_slice(), collected.as_slice()],
- &self.agent_definition_id,
- );
- collected.extend(rebuilt);
- }
+ collected.extend(self.rebuilt_search_tools(&surface.tools, &collected));
let synthesized =
super::builder::drop_synthesized_name_collisions(&surface.tools, collected);
let synthesized_names = synthesized
@@ -1588,7 +1572,6 @@ impl OpenHumanSessionHost {
// this session's current authorization refresh.
connected_integrations_authoritative: false,
recorded_integration_actions: Vec::new(),
- recorded_search_tools: Vec::new(),
workflows: self.workflows.clone(),
composio_events: None,
skill_events: None,