Skip to content

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

feat(session_host): restore recorded mcp tool specs on resumed threads

Steven Enamakel1e45f1a44cf3
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 8e911e15dc..c4e786e211 100644
--- a/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs
+++ b/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs
@@ -16,6 +16,7 @@ pub(super) struct McpToolCatalog {
pub(super) connected: Vec<tinymcp_bus::McpToolPresentation>,
pub(super) configured: Vec<tinymcp_bus::McpToolPresentation>,
pub(super) recorded_names: std::collections::HashSet<String>,
+ pub(super) recorded_specs: Vec<tinytools::ToolSpec>,
}
impl OpenHumanTurnPrelude {
@@ -76,12 +77,17 @@ impl OpenHumanTurnPrelude {
// knew under the pre-readable hashed name keeps resolving.
#[cfg(feature = "mcp")]
{
- mutable.mcp_tools.recorded_names = recorded
+ let recorded_mcp_specs = recorded
.specs()
.iter()
.filter(|spec| spec.name.starts_with("mcp_"))
+ .cloned()
+ .collect();
+ mutable.mcp_tools.recorded_names = recorded_mcp_specs
+ .iter()
.map(|spec| spec.name.clone())
.collect();
+ mutable.mcp_tools.recorded_specs = recorded_mcp_specs;
}
}
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs
index d3eab1ff67..8c50abd733 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs
@@ -147,6 +147,28 @@ impl OpenHumanTurnPrelude {
}
}
}
+ #[cfg(feature = "mcp")]
+ {
+ let recorded = self
+ .mutable
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .mcp_tools
+ .recorded_specs
+ .clone();
+ let recorded = recorded
+ .iter()
+ .map(|spec| (spec.name.as_str(), spec))
+ .collect::<std::collections::HashMap<_, _>>();
+ // A resumed thread keeps the exact MCP declaration it was shown,
+ // while the current module presentation still supplies its live
+ // executor. This mirrors the REPL snapshot restoration above.
+ for spec in &mut specs {
+ if let Some(frozen) = recorded.get(spec.name.as_str()) {
+ *spec = Arc::new((*frozen).clone());
+ }
+ }
+ }
let synthesized_tools = Arc::new(synthesized);
crate::tools::toolpacks::bind_synthesized_pack_registry(&surface.tools, &synthesized_tools);
let all_tools = surface