Skip to content

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

fix(browser): tell the agent where to fix Chrome in TinyComputer 0.11's words

Shanu870e85197bea
diff --git a/crates/openhuman-core/src/modules/README.md b/crates/openhuman-core/src/modules/README.md
index 288671f64b..90d752a5e9 100644
--- a/crates/openhuman-core/src/modules/README.md
+++ b/crates/openhuman-core/src/modules/README.md
@@ -217,7 +217,7 @@ download, its `dlopen`, or its resident memory.
| [`computer_config.rs`](computer_config.rs) | `tinycomputer` | The private configuration: `jev` (decision model), `planner` (planner, rescue and output models), `browser` (Chrome path), `trace_path`. Rebuilt from `[computer]` and stored credentials on every call; `OPENHUMAN_COMPUTER_TRACE` turns tracing on. |
| [`computer.rs`](computer.rs) | `tinycomputer` | `status` for the Computer settings page: lifecycle state, configured routes, and optionally what the module reports through `Describe`. |
| [`browser.rs`](browser.rs) | `tinycomputer` | `BrowserClient` for the `Browser*` members, over the desktop proxy, plus the shared website policy: "Allow all" (the list's `*`) lets the browser open any public site, private and local addresses still refused. |
-| [`browser_task.rs`](browser_task.rs) | `tinycomputer` | Browser tasks over `StartTask` / `AwaitTask` / `ContinueTask`: `start`, `wait`, `resume`, `cancel`, `report`. The host keeps the policy (surfaces, origins, action budget, approvals) and sends Browser Control's Chrome path, and in persistent mode its profile folder, with every task, read from the settings each time. |
+| [`browser_task.rs`](browser_task.rs) | `tinycomputer` | Browser tasks over `StartTask` / `AwaitTask` / `ContinueTask`: `start`, `wait`, `resume`, `cancel`, `report`. The host keeps the policy (surfaces, origins, action budget, approvals) and sends Browser Control's Chrome path, and in persistent mode its profile folder, with every task, read from the settings each time. A refusal or failure that says Chrome is missing, or that its path names no Chrome, tells the agent where the user sets that path. |
| [`browser_profile.rs`](browser_profile.rs) | `tinycomputer` | Whether a running Chrome holds the persistent profile folder, by the lock Chrome keeps there (`SingletonLock`, or `lockfile` on Windows). Chrome lets one browser at a time use a profile, so a task waits up to 5 s for one closing on it, then runs in a fresh profile. |
| [`browser_task_report.rs`](browser_task_report.rs) | `tinycomputer` | What is kept when a task stops: a content-free log summary, and with tracing on the full report under `<workspace>/state/computer/tasks/`. |
| [`browser_sites.rs`](browser_sites.rs), [`browser_sites/store.rs`](browser_sites/store.rs) | `tinycomputer` | Per-site memory of plans and elements learned by finished tasks, in `<workspace>/state/computer/sites/<site>.json`, with 30-day expiry. Fed back on `StartTask`; never reaches the agent's memory or prompts. |
diff --git a/crates/openhuman-core/src/modules/browser.rs b/crates/openhuman-core/src/modules/browser.rs
index 125d23eb97..0e8170ced4 100644
--- a/crates/openhuman-core/src/modules/browser.rs
+++ b/crates/openhuman-core/src/modules/browser.rs
@@ -30,9 +30,49 @@ pub(crate) const CHROME_NOT_FOUND_HINT: &str = "Chrome was not found. Ask the us
Chrome path (for example /Applications/Google Chrome.app/Contents/MacOS/Google Chrome), \
then try again. Do not install or download a browser yourself.";
+/// What the agent is told when the Chrome path the user set names no Chrome
+/// the module can start: refused when a task starts, or when the browser
+/// launches. Left without it, the agent reads TinyComputer's own field name
+/// (`browser_executable`), which is nothing the user can find.
+pub(crate) const CHROME_PATH_HINT: &str = "Chrome could not be started from the Chrome \
+ path the user set. Ask the user to set Connections > Computer Control > Browser > Chrome \
+ path to the Chrome program itself (for example /Applications/Google Chrome.app/Contents/\
+ MacOS/Google Chrome), then try again. Do not install or download a browser yourself.";
+
+/// How TinyComputer says no Chrome was found: agent-browser's own words
+/// before TinyComputer 0.11, and the module's since.
+const CHROME_MISSING: &[&str] = &["chrome not found", "no chrome or chromium was found"];
+
+/// How TinyComputer says the browser binary it was given would not start, or
+/// is no executable at all (refused before a task starts).
+const CHROME_UNUSABLE: &[&str] = &[
+ "browser binary given could not be started",
+ "browser_executable must be the absolute path",
+];
+
/// Whether a module error or task failure says Chrome could not be found.
pub(crate) fn chrome_not_found(text: &str) -> bool {
- text.to_ascii_lowercase().contains("chrome not found")
+ let text = text.to_ascii_lowercase();
+ CHROME_MISSING.iter().any(|said| text.contains(said))
+}
+
+/// Whether a module error or task failure says the Chrome path the user set
+/// names no Chrome the module can start.
+pub(crate) fn chrome_path_unusable(text: &str) -> bool {
+ let text = text.to_ascii_lowercase();
+ CHROME_UNUSABLE.iter().any(|said| text.contains(said))
+}
+
+/// What the agent is told to ask of the user when `text`, a module error or a
+/// task failure, says Chrome is missing or its path is unusable.
+pub(crate) fn chrome_hint(text: &str) -> Option<&'static str> {
+ if chrome_not_found(text) {
+ Some(CHROME_NOT_FOUND_HINT)
+ } else if chrome_path_unusable(text) {
+ Some(CHROME_PATH_HINT)
+ } else {
+ None
+ }
}
#[derive(Debug, thiserror::Error)]
@@ -70,10 +110,9 @@ impl BrowserCallError {
.and_then(serde_json::Value::as_str)
.map(|name| name.rsplit('.').next().unwrap_or(name).to_owned())
.unwrap_or_else(|| error.code.clone());
- let message = if chrome_not_found(&error.message) {
- format!("{} {CHROME_NOT_FOUND_HINT}", error.message)
- } else {
- error.message.clone()
+ let message = match chrome_hint(&error.message) {
+ Some(hint) => format!("{} {hint}", error.message),
+ None => error.message.clone(),
};
Self::Bus { name, message }
}
diff --git a/crates/openhuman-core/src/modules/browser_task.rs b/crates/openhuman-core/src/modules/browser_task.rs
index da4da23ce3..80c09d3538 100644
--- a/crates/openhuman-core/src/modules/browser_task.rs
+++ b/crates/openhuman-core/src/modules/browser_task.rs
@@ -303,15 +303,25 @@ async fn free_profile(request: &mut StartTaskRequest, wait: Duration) {
}
}
+/// A module reply as its data, or as the error the tool reports: its code,
+/// message and hint, and where the user fixes a Chrome the module was not
+/// given or could not start ([`super::browser::chrome_hint`]).
fn unwrap_response<Reply>(member: &str, response: AgentResponse<Reply>) -> Result<Reply, String> {
match (response.ok, response.data, response.error) {
(true, Some(data), _) => Ok(data),
- (_, _, Some(error)) => Err(format!(
- "browser task {member} failed [{}]: {} {}",
- error.code, error.message, error.hint
- )
- .trim_end()
- .to_owned()),
+ (_, _, Some(error)) => {
+ let host = super::browser::chrome_hint(&error.message).unwrap_or_default();
+ let said = [error.message.as_str(), error.hint.as_str(), host]
+ .into_iter()
+ .map(str::trim)
+ .filter(|part| !part.is_empty())
+ .collect::<Vec<_>>()
+ .join(" ");
+ Err(format!(
+ "browser task {member} failed [{}]: {said}",
+ error.code
+ ))
+ }
_ => Err(format!("browser task {member} returned no result")),
}
}
diff --git a/crates/openhuman-core/src/modules/browser_task_tests.rs b/crates/openhuman-core/src/modules/browser_task_tests.rs
index 89a3356962..862c3c35e7 100644
--- a/crates/openhuman-core/src/modules/browser_task_tests.rs
+++ b/crates/openhuman-core/src/modules/browser_task_tests.rs
@@ -151,6 +151,33 @@ fn unwrap_response_returns_data_or_the_structured_error() {
.contains("no result"));
}
+#[test]
+fn a_chrome_path_the_module_refuses_says_where_the_user_fixes_it() {
+ // TinyComputer refuses a task whose Chrome path names no program in its
+ // own words; the agent is told where the user sets that path.
+ let refused: AgentResponse<u32> = AgentResponse {
+ ok: false,
+ data: None,
+ error: Some(AgentError::new(
+ "INVALID_REQUEST",
+ "browser_executable must be the absolute path of a browser binary on this machine",
+ "",
+ false,
+ )),
+ };
+ let error = unwrap_response("StartTask", refused).unwrap_err();
+ assert!(
+ error.starts_with(
+ "browser task StartTask failed [INVALID_REQUEST]: browser_executable must be"
+ ),
+ "{error}"
+ );
+ assert!(
+ error.ends_with(crate::modules::browser::CHROME_PATH_HINT),
+ "{error}"
+ );
+}
+
#[tokio::test]
async fn a_task_keeps_the_persistent_profile_only_while_no_other_chrome_holds_it() {
let mut config = Config::default();
diff --git a/crates/openhuman-core/src/modules/browser_tests.rs b/crates/openhuman-core/src/modules/browser_tests.rs
index 47674ee5ef..d152ceca2b 100644
--- a/crates/openhuman-core/src/modules/browser_tests.rs
+++ b/crates/openhuman-core/src/modules/browser_tests.rs
@@ -152,6 +152,42 @@ fn a_missing_chrome_tells_the_agent_where_the_user_sets_its_path() {
assert!(!chrome_not_found("Chrome launch timed out"));
}
+#[test]
+fn tinycomputers_own_words_for_a_missing_or_unusable_chrome_get_the_users_fix() {
+ // TinyComputer 0.11 says why its Chrome would not start in its own words.
+ let failed = |message: &str| -> String {
+ let response: DesktopResponse = serde_json::from_value(serde_json::json!({
+ "version": "2.12",
+ "ok": false,
+ "command": "browser-open-session",
+ "error": {
+ "code": "BROWSER_UNAVAILABLE",
+ "message": message,
+ "details": {"name": "ai.tinyhumans.tinycomputer.Browser.Error.BrowserUnavailable"}
+ }
+ }))
+ .unwrap();
+ BrowserCallError::from_response(&response).to_string()
+ };
+ let missing = failed(
+ "browser unavailable: no Chrome or Chromium was found on this machine; give the path of the browser to use",
+ );
+ assert!(missing.ends_with(CHROME_NOT_FOUND_HINT), "{missing}");
+ let unusable = failed(
+ "browser unavailable: the browser binary given could not be started (Chrome exited before providing DevTools URL); check that its path names Chrome or Chromium",
+ );
+ assert!(unusable.ends_with(CHROME_PATH_HINT), "{unusable}");
+ let other = failed("browser unavailable: CDP connection failed: refused");
+ assert!(other.ends_with("refused"), "{other}");
+ assert_eq!(
+ chrome_hint(
+ "browser_executable must be the absolute path of a browser binary on this machine"
+ ),
+ Some(CHROME_PATH_HINT)
+ );
+ assert_eq!(chrome_hint("Chrome launch timed out"), None);
+}
+
#[test]
fn fresh_profile_is_the_default() {
let config = Config::default();
diff --git a/crates/openhuman-core/src/modules/schemas.rs b/crates/openhuman-core/src/modules/schemas.rs
index 091ff202b4..c862a947cd 100644
--- a/crates/openhuman-core/src/modules/schemas.rs
+++ b/crates/openhuman-core/src/modules/schemas.rs
@@ -182,12 +182,18 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
/// What the settings page's Chrome check shows when Chrome would not start:
-/// where to fix a missing Chrome, or else the module's own reason.
+/// where to fix a missing Chrome or a Chrome path that names no Chrome, or
+/// else the module's own reason.
fn readiness_error(detail: &str) -> String {
if super::browser::chrome_not_found(detail) {
"Chrome was not found. Set Chrome path below to the Chrome program (for example \
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome), save, and test again."
.to_owned()
+ } else if super::browser::chrome_path_unusable(detail) {
+ "Chrome could not be started from Chrome path. Set it to the Chrome program itself \
+ (for example /Applications/Google Chrome.app/Contents/MacOS/Google Chrome), save, and \
+ test again."
+ .to_owned()
} else {
format!("Chrome could not start: {detail}")
}
diff --git a/crates/openhuman-core/src/modules/schemas_tests.rs b/crates/openhuman-core/src/modules/schemas_tests.rs
index 57c79208c0..2046a2646c 100644
--- a/crates/openhuman-core/src/modules/schemas_tests.rs
+++ b/crates/openhuman-core/src/modules/schemas_tests.rs
@@ -107,6 +107,18 @@ fn the_chrome_check_says_where_to_fix_a_missing_chrome() {
super::readiness_error("Bus: launch timed out"),
"Chrome could not start: Bus: launch timed out"
);
+ // TinyComputer 0.11's own words for each.
+ let missing = super::readiness_error(
+ "BrowserUnavailable: browser unavailable: no Chrome or Chromium was found on this machine; give the path of the browser to use",
+ );
+ assert!(missing.starts_with("Chrome was not found."), "{missing}");
+ let unusable = super::readiness_error(
+ "BrowserUnavailable: browser unavailable: the browser binary given could not be started (Chrome exited before providing DevTools URL); check that its path names Chrome or Chromium",
+ );
+ assert!(
+ unusable.starts_with("Chrome could not be started from Chrome path."),
+ "{unusable}"
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/tools/impl/browser/browser_computer_tests.rs b/crates/openhuman-core/src/tools/impl/browser/browser_computer_tests.rs
index fca3451070..21f74813d0 100644
--- a/crates/openhuman-core/src/tools/impl/browser/browser_computer_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/browser/browser_computer_tests.rs
@@ -436,6 +436,20 @@ fn a_task_that_found_no_chrome_tells_the_agent_to_ask_for_its_path() {
host_hint(&failed("the last three actions changed nothing")),
None
);
+ // TinyComputer 0.11's own words: the step's note names a missing Chrome,
+ // or a Chrome path that names no Chrome it can start.
+ assert_eq!(
+ host_hint(&failed(
+ "https://www.amazon.in could not be opened: BROWSER_UNAVAILABLE (browser unavailable: no Chrome or Chromium was found on this machine; give the path of the browser to use)"
+ )),
+ Some(crate::modules::browser::CHROME_NOT_FOUND_HINT)
+ );
+ assert_eq!(
+ host_hint(&failed(
+ "https://www.amazon.in could not be opened: BROWSER_UNAVAILABLE (browser unavailable: the browser binary given could not be started (Chrome exited before providing DevTools URL); check that its path names Chrome or Chromium)"
+ )),
+ Some(crate::modules::browser::CHROME_PATH_HINT)
+ );
}
struct ThreadOnly(&'static str);
diff --git a/crates/openhuman-core/src/tools/impl/browser/browser_task_actions.rs b/crates/openhuman-core/src/tools/impl/browser/browser_task_actions.rs
index d47f9df626..6ce3992b5c 100644
--- a/crates/openhuman-core/src/tools/impl/browser/browser_task_actions.rs
+++ b/crates/openhuman-core/src/tools/impl/browser/browser_task_actions.rs
@@ -9,16 +9,13 @@ use tinycomputer_bus::agent::{TaskStatus, TaskView};
use tinycomputer_bus::browser::{Action, LocateBy, Locator, ScrollDirection, Target, WaitState};
/// What the host adds to a task report the agent cannot act on alone: a
-/// task that failed because Chrome was not found says where the user sets
-/// its path, rather than leaving the agent to install a browser.
+/// task that failed because Chrome was not found, or would not start from
+/// the path the user set, says where the user sets that path, rather than
+/// leaving the agent to install a browser.
pub(super) fn host_hint(view: &TaskView) -> Option<&'static str> {
match &view.status {
- TaskStatus::Failed { reason, hint, .. }
- if crate::modules::browser::chrome_not_found(reason)
- || crate::modules::browser::chrome_not_found(hint) =>
- {
- Some(crate::modules::browser::CHROME_NOT_FOUND_HINT)
- }
+ TaskStatus::Failed { reason, hint, .. } => crate::modules::browser::chrome_hint(reason)
+ .or_else(|| crate::modules::browser::chrome_hint(hint)),
_ => None,
}
}