Skip to content

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

fix(agent): discover enabled browser in desktop tool snapshots

Steven Enamakeld69d78101a61
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 7d46590056..bb9a5957cc 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -201,11 +201,10 @@ impl OpenHumanSessionHost {
// module or remote driver can supply. The engine's connection is now
// exclusively the engine's. Lane C (#6040) rides the same binding.
let (archivist_provider, auto_recall) = super::helpers::bind_session_memory(config)?;
-
// Load the user's persisted tool preferences once. They drive two
// things below: granting the App UI Control / App Automation mutation
// opt-in (#3762) and filtering the tool set to the enabled snapshot.
- let enabled_tools: Vec<String> = {
+ let mut enabled_tools: Vec<String> = {
use crate::desktop::app_state::load_stored_app_state;
match load_stored_app_state(config) {
Ok(stored) => stored
@@ -220,7 +219,10 @@ impl OpenHumanSessionHost {
}
}
};
-
+ if config.browser.enabled && !enabled_tools.is_empty() {
+ // Browser's explicit opt-in outranks a positive-only onboarding snapshot.
+ enabled_tools.extend(["browser".to_string(), "browser_open".to_string()]);
+ }
// Share a single `Arc<Config>` across the heavyweight per-build consumers
// (the tool registry, the reflection hook, the turn provider) instead of
// deep-cloning the large `Config` at each site (#5050, Fix 1). `Config` is
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
index 90fe99b4cd..af37bb62a4 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
@@ -53,6 +53,79 @@ fn spec(name: &str) -> ToolSpec {
}
}
+#[cfg(feature = "modules")]
+#[tokio::test]
+async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfaces() {
+ let tmp = tempfile::tempdir().expect("tempdir");
+ let workspace = tmp.path().join("workspace");
+ std::fs::create_dir_all(workspace.join("state")).expect("state dir");
+ // A desktop onboarding snapshot predating TinyBrowser has other enabled
+ // tools but cannot name browser/browser_open. The explicit Browser setting
+ // must still register both deferred tools for the user-facing session.
+ std::fs::write(
+ workspace.join("state/app-state.json"),
+ r#"{"onboardingTasks":{"enabledTools":["shell","file_read"]}}"#,
+ )
+ .expect("app state");
+ let mut config = crate::config::Config {
+ workspace_dir: workspace.clone(),
+ action_dir: workspace.clone(),
+ config_path: tmp.path().join("config.toml"),
+ ..Default::default()
+ };
+ config.browser.enabled = true;
+ config.http_request.allowed_domains = vec!["example.com".into()];
+ let mut host =
+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")
+ .expect("desktop orchestrator");
+ for name in ["browser", "browser_open"] {
+ assert!(host.deferred_tool_names_for_test().contains(name), "{name}");
+ assert!(!host
+ .visible_tool_specs_arc()
+ .iter()
+ .any(|spec| spec.name == name));
+ }
+ host.ensure_runtime_session().expect("runtime session");
+ let prelude = host
+ .runtime_state
+ .lock()
+ .expect("runtime state")
+ .prelude
+ .clone()
+ .expect("prelude");
+ let fresh = prelude.prepare(true).await.expect("fresh tool surface");
+ let fresh = fresh.tools.expect("fresh tools");
+ for name in ["browser", "browser_open"] {
+ assert!(fresh.specs().iter().any(|spec| spec.name == name), "{name}");
+ }
+ prelude.adopt_recorded_tools(Some(&fresh));
+ prelude.refresh_delegation_tool_surface();
+ let resumed = prelude.prepare(false).await.expect("resumed tool surface");
+ for name in ["browser", "browser_open"] {
+ assert!(
+ resumed
+ .tools
+ .as_ref()
+ .unwrap()
+ .specs()
+ .iter()
+ .any(|spec| spec.name == name),
+ "{name}"
+ );
+ }
+
+ config.browser.enabled = false;
+ let disabled =
+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")
+ .expect("browser-disabled orchestrator");
+ for name in ["browser", "browser_open"] {
+ assert!(
+ !disabled.deferred_tool_names_for_test().contains(name),
+ "{name}"
+ );
+ }
+}
+
/// The incident this guards: a thread resumed in a fresh process (empty
/// integrations cache) lost every Composio action, so the orchestrator's
/// `tool_search` had nothing to find although its restored prompt told it to