Skip to content

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

refactor(session): consolidate recorded tool rebuilding into prelude

Steven Enamakel9b2c7242dd3c
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 2a2bdc0a9d..d4735a788f 100644
--- a/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs
+++ b/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs
@@ -35,13 +35,22 @@ impl OpenHumanTurnPrelude {
.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(
+ /// Executors for tool declarations the resumed thread was sent that the
+ /// live surface did not supply this turn.
+ ///
+ /// * Integration actions stay executable even when this process has not
+ /// (re)fetched their integration yet — only for an agent that carries
+ /// integration actions at all.
+ /// * Search role tools stay declared even when no provider is usable now
+ /// (signed out, provider turned off); a call answers with an actionable
+ /// error instead of an unknown-tool failure.
+ pub(super) fn rebuilt_recorded_tools(
&self,
+ definition: &crate::agent::harness::definition::AgentDefinition,
base: &[Box<dyn tinytools::Tool>],
synthesized: &[Box<dyn tinytools::Tool>],
+ integrations: &[crate::agent::prompts::ConnectedIntegration],
+ integrations_are_authoritative: bool,
) -> Vec<Box<dyn tinytools::Tool>> {
let recorded = self
.mutable
@@ -49,11 +58,37 @@ impl OpenHumanTurnPrelude {
.unwrap_or_else(std::sync::PoisonError::into_inner)
.recorded_integration_actions
.clone();
- super::super::recorded_tools::rehydrate_search_tools(
+ let mut rebuilt = Vec::new();
+ if definition.subagents.iter().any(|entry| {
+ matches!(
+ entry,
+ crate::agent::harness::definition::SubagentEntry::Skills(wildcard)
+ if wildcard.matches_all()
+ )
+ }) {
+ rebuilt = super::super::recorded_tools::rehydrate_integration_actions(
+ &recorded,
+ synthesized,
+ integrations,
+ integrations_are_authoritative,
+ );
+ if !rebuilt.is_empty() {
+ log::info!(
+ "[session] rebuilt {} recorded integration action(s) the live integrations did not supply agent={}",
+ rebuilt.len(),
+ self.agent_definition_id
+ );
+ }
+ }
+ #[cfg(feature = "modules")]
+ rebuilt.extend(super::super::recorded_tools::rehydrate_search_tools(
&recorded,
&[base, synthesized],
&self.agent_definition_id,
- )
+ ));
+ #[cfg(not(feature = "modules"))]
+ let _ = base;
+ rebuilt
}
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 d9fe958503..0523fb0304 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -447,39 +447,14 @@ impl OpenHumanTurnPrelude {
let mut collected = collect_orchestrator_tools(&definition, registry, &integrations);
#[cfg(feature = "mcp")]
collected.extend(mcp_tools);
- // Integration actions the thread already declared stay executable
- // even when this process has not (re)fetched their integration yet.
- // Only an agent that carries integration actions at all gets them.
- if definition.subagents.iter().any(|entry| {
- matches!(
- entry,
- crate::agent::harness::definition::SubagentEntry::Skills(wildcard)
- if wildcard.matches_all()
- )
- }) {
- let recorded = self
- .mutable
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner)
- .recorded_integration_actions
- .clone();
- let rebuilt = super::recorded_tools::rehydrate_integration_actions(
- &recorded,
- &collected,
- &integrations,
- integrations_are_authoritative,
- );
- if !rebuilt.is_empty() {
- log::info!(
- "[session] rebuilt {} recorded integration action(s) the live integrations did not supply agent={}",
- rebuilt.len(),
- self.agent_definition_id
- );
- collected.extend(rebuilt);
- }
- }
- #[cfg(feature = "modules")]
- collected.extend(self.rebuilt_search_tools(&surface.tools, &collected));
+ let rebuilt = self.rebuilt_recorded_tools(
+ &definition,
+ &surface.tools,
+ &collected,
+ &integrations,
+ integrations_are_authoritative,
+ );
+ collected.extend(rebuilt);
let synthesized =
super::builder::drop_synthesized_name_collisions(&surface.tools, collected);
let synthesized_names = synthesized