browser_use_cli._FHS_BIN_DIRS + _floor_subprocess_path restated
browser_lightpanda._SANE_PATH_DIRS + merge_sane_path: the same eight dirs in
the same order, the same rule (drop empty entries, keep the existing order,
append each dir that exists and is not already present). A probe over four
input PATHs (empty, /usr/bin:/bin, an nvm-only PATH, one with an empty entry
and an already-present floor dir) gave identical output from both.
The one difference was the Windows guard in the copy, so merge_sane_path now
returns its input unchanged on nt. Lightpanda's only caller already returns
before it on nt, so nothing there changes. The PATH-order test now goes
through _base_subprocess_env, the behaviour the floor exists for.
A call the Bot Desktop fence refuses never bound the supervisor to its endpoint, so asking its daemon for a tab could record another browser's target. Record in dispatch()'s finally instead. Also cover a driven tab whose form has not rendered: it stays the only candidate, for a named origin and for an originless fill.
Refs #140196
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
On a shared CDP browser focus_page attached to the first same-origin tab whose
form probe passed, so a stored secret could be typed into a stale tab or another
session's tab. After each call browser_exec now asks its harness daemon for its
current_tab and records the targetId on the task's vault supervisor; focus_page
uses only that tab when it is on the origin (even before its form renders, so the
probe cannot fall through to a foreign tab) and walks the origin as before
otherwise.
Fixes#140196
Outside a served (multiplexed) turn _base_subprocess_env left BH_RUNTIME_DIR
unset, so every hermes -p CLI, cron and one-shot process of one OS user shared
<harness home>/runtime/bu-default.* and the harness reused whichever live
daemon it found there: one profile's browser_exec drove the browser (real
profile, logins) another profile's daemon was attached to.
The harness runtime/tmp dirs are now namespaced by hermes_home_key() always
(served profiles already got exactly this key). That always sets
BH_RUNTIME_DIR, so the deep-HOME default-socket fallback
(fit_default_socket_dir) is gone: socket_fit_runtime_dir already moves an
over-budget profile runtime dir to a private short dir.
Fixes#149829
The SSH ControlMaster dir lived in the temp root under a predictable name
and was created with exist_ok, so a directory (or symlink) another local
user pre-created was adopted as-is (#80284).
ensure_owned_private_dir() (tools/spill_safety.py) creates the dir 0700,
refuses a symlink/non-directory or another user's dir, and tightens our
own dir's mode. The SSH control dir is now per-user and moves to
socket_safe_tmpdir() so a deep scratch TMPDIR cannot overflow sun_path.
The browser-use own-tab marker is created O_NOFOLLOW instead of being
truncated through a planted link.
(Salvage note: the agent-browser socket-dir half of the original commit
is dropped; agent-browser no longer exists on main.)
Co-authored-by: ryang3d <ryang3d@users.noreply.github.com>
Two review rounds each found ~8 new host routes because the policy listed what to refuse.
tools/hosted_tool_policy.py now lists what is allowed, and the denylist is gone.
- hosted_tool_refusal: a tool runs in a hosted scope only if it is on HOSTED_TOOL_ALLOWLIST
(terminal, process_manage, execute_code, read_file, write_file, patch, search_files), the
tools that act only through the agent's sandbox. The agent loop asks once per call in
_dispatch_authorized_once, which every sequential, concurrent and batched call goes
through whatever its executor (inline, memory provider, context engine, registry). The
primitives ask too, for callers outside the loop: ToolRegistry.dispatch, the inline
executor table, handle_function_call (connectors, bridges) and the browser_exec direct
entry. Memory, session_search, todo, vision, web, browser, MCP, connectors, catalog,
delegation, skills and cron are refused before any handler (round-2 findings 9, 10, 11,
13, 14).
- host_feature_enabled: agent features outside tool calls that read or write this host's
profile state are off in a hosted scope. Context files and SOUL.md, subdirectory hints,
@-references, workspace snapshot, backend probe, built-in memory init/load/writes and
providers, recall DB, background review, trajectory export, failed-write bookkeeping,
checkpoints, image/video processing, inline skill shell, cron scripts, MCP stdio, media
delivery, transcription and /review delegation each ask the one function (findings 4,
12, 13, 15).
- Per-site refusals that the allowlist covers are removed (connector file inputs).
- Local mode is unchanged. A test shows the allowlist is never consulted unscoped or
locally and every registered tool reaches its handler. The local byte-parity test is
kept.
browser_exec ran the model's Python in a host subprocess (a cloud browser
moves Chromium, not the interpreter), and it was not the only tool the
sandbox routing never reached. Tools with no route through the agent's
environment yet now fail closed in a hosted scope, before any setup, file or
process, with an error naming why (tools/hosted_tool_policy.py):
- by toolset, at ToolRegistry.dispatch: the browser tools, computer use and
desktop UI, desktop projects, image and video generation, text to speech,
skills, cron jobs, delegation, kanban, catalog and connection management,
onboarding, and every MCP server's tools (they come from the profile's
config and run for it);
- directly, on the paths the registry never sees: the browser_exec entry,
checkpoint take and restore, inline skill shell, @-references, the
workspace git probe in the system prompt, cron scripts, MCP stdio spawns,
media delivery by host path, connector file inputs, document extraction in
read_file, voice transcription and delegate_task's inline dispatch.
Routing each of these through the sandbox is follow-up work; refusing them
keeps the hosted guarantee that nothing tenant-supplied runs or is read here.
Local installs are unchanged (every check is a no-op with no hosted scope),
which a permanent test now pins: env maps and built-in backend constructor
arguments are byte-identical, unscoped and under the local scope, to the
same calls with the hosted machinery switched off.
The developer guide describes the hosted operation interface, what runs in
the sandbox, and what is refused.
A call such as search_files without `pattern` ran anyway and returned matches, and a
typo'd or invented argument was dropped with no signal, so the model assumed an option
had taken effect. One check now sits in front of every tool Hermes ships
(registry dispatch and the agent's inline executors; model_tools.py is untouched):
- a missing `required` argument is refused before the handler runs, naming the field
(with its allowed values when the schema enumerates them) and the valid parameters;
- an argument the schema does not declare still reaches the handler exactly as sent;
the result gains a `_warning` naming it. Nothing is stripped.
Slim redo of #142503. What differs from it, and why:
- scope is built-in tools only. MCP and plugin tools, and schemas that are open or
union-shaped at the root, pass through untouched: a third-party `properties` list is
not a promise about what the handler accepts.
- nothing is stripped, so handlers that read an undeclared key and execution middleware
that rewrites arguments keep main's contract.
- legacy call shapes and tool-owned guidance are declared by each tool at registration
(`compat_args`, `self_checked_args`) instead of a central table: skill_manage and memory
flat shapes, delegate_task's single-task shape, patch's V4A mode, terminal(code=...),
video_generate(video_url=...), and the handlers whose own missing-argument message says
more than a generic refusal can.
- the dynamic schema is only built when the registered one reports a finding.
Co-authored-by: Elisa Martinez Abad <elisam@nvidia.com>
Co-authored-by: James Nolan <jnolan@nvidia.com>
search_files, memory, manage_connections, execute_code, browser_exec,
skill_manage and terminal repeated the same rule in the tool description
and again in a parameter description (or only restated the JSON schema:
"default: 50" beside "default": 50). Every model call pays for both
copies. Each rule now appears once, on the parameter it governs where
there is one. Parameter names, types, enums, defaults and required lists
are unchanged; with descriptions stripped the seven schemas are identical
to main.
Measured on anthropic/claude-fable-5.2 (provider prompt tokens, one tool
per request): search_files 732 -> 557, memory 885 -> 767,
manage_connections 1,563 -> 1,333, execute_code 1,165 -> 1,085,
browser_exec 1,187 -> 1,145, skill_manage 1,340 -> 1,313, terminal
919 -> 895. All seven together: 8,077 -> 7,381 (-696 per call).
memory: the user/memory store meanings moved from the description to the
`target` parameter, so the single-store narrowing now rewrites only that
parameter. A disabled store is still never named in the schema (new test).
browser_exec keeps page_info() and fill_input() in the helper list: the
"work text-first" sentence that also names them is absent from the
native-vision and Lightpanda variants.
manage_connections keeps its two short opening sentences: the tool_search
catalog line is the first sentence and must not be clipped.
memory also keeps "Reusable procedures belong in a skill, not memory" at the
end of its SKIP list although the WHEN paragraph says the same: with the
sentence gone a weak model stored a procedure in memory in 1 of 9 runs (0 of
9 on main).
Prompt-surface snapshot re-rendered.
Gate (2c, efficiency): the 0.5 s check while browser_exec runs stopped only once this process
owned the daemon. On Windows, in a managed worker, or for a daemon another Hermes started it can
never be owned, so it ran every tick for the whole call (up to ~600 short threads in a 300 s call;
for another Hermes's daemon each tick also read its cmdline, uids, sid and environ).
_own_harness_daemon now answers True (owned), False (never ours) or None (nothing to own yet), and
the check stops on anything but None. The managed-worker comment now gives the real reason: a
killed worker must not take the next turn's browser along; its clean exit still runs main's atexit
browser cleanup.
Tests: for another Hermes's daemon and in a managed worker the check answers stop; both fail with
the old owned-only stop rule.
main deleted agent-browser and the browser_tool_* modules and replaced them with a Python Chromium
launcher (tools/browser_launcher.py) and a browser_session layer. On this base:
- The agent-browser family (daemon + Chromium ownership) and the old lightpanda / real-profile
ownership have nothing left to apply to; their tests are dropped.
- main's atexit handler (browser_session_lifecycle.emergency_cleanup_all_sessions) now always runs
cleanup_all_browsers, which stops every harness daemon this process drove. The owned-only exit
step (stop_owned_harness_daemons) had no caller left and is removed; a harness daemon this
process started is still owned and dies with it on an ungraceful exit.
- The launcher's Chromium and lightpanda serve start detached by design: a shared-profile Chromium
outlives its launcher for its other holders, and a crashed owner's throwaway Chromium or
lightpanda server is reaped from its launch record by the next Hermes. Both spawns are marked
with that reason; owning the throwaway ones is a follow-up.
- The long-first-call test drives main's browser_exec routing (_route_exec_current).
Review (W4): on main, the atexit handler reached harness daemons only through
cleanup_all_browsers when _active_sessions was non-empty, so a browser_exec-only process never
stopped them on Windows. This branch's exit step fell back to stop_harness_daemons() off POSIX,
so every Windows exit --reloaded every daemon it had driven: a shared "default" daemon another
live Hermes was using (the cross-owner stop this branch fixes on POSIX) plus up to 15 s of exit
latency per daemon. Windows records no ownership, so the owned-only exit step now does nothing
there, as main did.
Test: with os.name "nt" and a driven daemon, the exit step reloads nothing; fails with the fallback.
Review (W3): agent/managed_worker.py documents that a worker keeps its background processes,
sandbox and browser between turns, and _owns_job exempts managed-worker jobs for that reason.
The browser daemons had no such exemption: a Browser Use harness daemon or an agent-browser
daemon (and its Chromium) started by one turn's worker was owned by it, so the supervisor killed
it when that worker exited and the next turn got a fresh browser (a Browser Use cloud browser lost
its state). _own_harness_daemon and _own_local_daemon now return early in a worker process
(agent.runtime_session_store.is_worker_process), mirroring _owns_job.
Tests: in a worker process neither family registers its daemon; both fail without the check.
Review (2c efficiency, nit 8): the 0.5 s check that owns a long first command's daemon kept
running for the whole command, and for an already-owned agent-browser daemon each tick rescans the
process table for children (psutil children(): 7-15 ms on a busy host). Both periodic checks now
return False once their daemon is owned, which stops them (agent.periodic_scheduler); the call
after the command still rescans for a relaunched Chromium. A pid file naming a process that fails
the identity check logged WARNING "Refusing to reap browser daemon" on every tick; that path now
logs at DEBUG (the reap paths keep WARNING).
The agent-browser half lives in browser_tool_lifecycle (_owning_local_daemon_meanwhile, next to
_own_local_daemon), which also keeps browser_tool_session.py under the 1k-line shape gate.
Test: once owned, the in-command check runs once and stops; fails when the check never returns False.
Review of 7b22760a16: registering_meanwhile started a fresh "while not done.wait()" thread per
browser command, the exact loop agent.periodic_scheduler exists to replace (one process-wide timer
thread; a body runs on a short-lived worker only when due, raises are logged and rescheduled, a
handle never overlaps itself, cancel(wait=) lets an in-flight run finish, and the body keeps the
caller's context). browser_exec and the local agent-browser command now schedule their existing
ownership check on it and cancel it (wait=5) before their own post-command check; the helper and
its unit test are gone, and hermes_cli no longer gains a thread it had to mark exempt.
Tests: the two long-first-command tests still fail when the scheduled check is a no-op.
Greptile on d1d8bc2e19: browser_exec handed the harness daemon to the owner-death supervisor only
after the CLI call returned, and agent-browser did the same for its daemon and Chromium. The first
call starts them and can run for minutes (navigation, user code); a Hermes killed during it left
them running, as on main. Both waits now run inside registering_meanwhile(), which calls the same
ownership check (_own_harness_daemon / _own_local_daemon) every 0.5 s on a helper thread while the
command runs and stops (joined) before the caller's own post-call check. A command shorter than
0.5 s never triggers it; the check is the existing one, so a daemon another Hermes started is still
never registered. _owns_local_daemon names the local-session predicate both agent-browser call sites
now share.
Tests: a browser_exec and an agent-browser command that block until their daemon was owned (both
fail when the wrapper is removed); registering_meanwhile stops with its block and swallows a failing
registration.
Greptile on d1d8bc2e19: stop_owned_harness_daemons trusted the cached ownership entry and stopped the
daemon by name (--reload). If our daemon had exited and another live Hermes had since started its
replacement under the same name, _own_harness_daemon never saw it (no command ran here after), so
exiting this Hermes stopped the other Hermes's browser. The exit path now reads the name's published
pid (one resolver, _published_daemon_pid, shared with _own_harness_daemon) and reloads only names
that still publish the pid we own; for the rest it forgets the entry and releases our old group once
empty. The exit test now uses a real per-test runtime dir instead of resolving under $HOME.
Test: with the name republished by another pid, exit reloads nothing and releases ours; the control
half (still our pid) reloads it. Fails when the published-pid check is removed.
Round-2 review of the exit-path fold:
- Windows records no ownership (_own_harness_daemon is POSIX-only), so the owned-only exit stop
would have stopped nothing there. stop_owned_harness_daemons stops every driven daemon on
Windows, as the exit path did before.
- _own_local_daemon keeps its one-syscall group-leader check for an already-owned pid, so a stale
pid file whose pid was recycled is never treated as the owned daemon.
- The ddgs marker now says the worker runs until its search returns, which is unbounded if primp hangs.
- test_mcp_stdio_init_timeout still patched tools.mcp_tool._get_mcp_stderr_log (dropped in the
previous commit); the replaced-daemon test uses a reaped child's pid instead of a fixed 4242; the
two browser kill -9 tests treat macOS's EPERM for a zombie-only group as gone.
cleanup_all_browsers keeps stopping every driven daemon: /browser connect|disconnect call it so the
next call runs on the new endpoint, and a daemon latches its endpoint when it starts
(TestBackendSwapRetargetsDaemons). Its reload of a daemon another Hermes started on the same name
is main's behaviour, unchanged here.
_own_local_daemon (after every local agent-browser command) and _own_harness_daemon (after every
browser_exec) ran the full identity chain (getpgid, psutil cmdline/uids, the spawn-tag environ read)
before looking at what they already owned, so the docstring's "already-registered groups cost one
set lookup" was false. Both now check the owned pid first: a known daemon skips the identity and tag
checks; agent-browser still rescans the daemon's children so a relaunched Chromium is picked up.
Also:
- A session whose daemon exited (pid file gone, idle timeout) drops its entry, so a long-lived
gateway with per-task session names no longer keeps one entry per session forever.
- A harness daemon that replaced an owned one releases the old group (once empty) instead of
leaving the stale number registered until a later prune.
- The harness pid-file path moves to browser_harness_dirs.harness_pid_file, sharing _harness_home
with namespace_harness_dirs; the copy in browser_use_cli had drifted (Path.home() of this
process where the harness resolves the child env's HOME).
Tests: an owned daemon is not re-verified (both families), an exited agent-browser daemon is
forgotten, a replacement harness daemon releases the old group; both new tests fail on the prior head.
The atexit handler called stop_harness_daemons(), which sends --reload to every daemon this process
drove. browser_exec records a daemon it merely reused too, so a clean exit restarted the shared
daemon another live Hermes started on the same name, the case _own_harness_daemon already refuses
to own. The exit path now stops only the daemons in _owned_daemon_groups (stop_owned_harness_daemons).
cleanup_all_browsers keeps main's stop-everything-driven behaviour for a backend swap.
Test: the atexit handler with one owned and one foreign driven daemon reloads only the owned one; it
fails when the handler calls stop_harness_daemons() again.
Two same-user Hermes processes can reach one daemon. Both read bu-default.pid on the default
Browser Use name, and every Hermes shares the real-profile attach session. The identity checks (uid,
module, session leader, socket-dir binding) prove what the daemon is, not who started it, so both
Hermes registered its group. Killing either one then killed the browser the other was still using.
The real-profile attach's before/after pid-file diff had the same hole: two concurrent attaches
both see the file change.
Each agent-browser and browser-harness command now carries this process's spawn tag (spawn_env:
pid plus create time). The daemon it forks inherits the tag, and _own_local_daemon /
_own_harness_daemon register a daemon only when its tag names this process
(process_identity.spawned_by_this_process; an unreadable environment fails closed). The pid-file
diff is gone. Probed on macOS against agent-browser 0.26.0: the forked daemon carries the tag.
New tests start a verified daemon tagged with another live process. Each fails with its check
removed (the daemon gets registered) and passes with it.
Reported by Greptile on #137057 (two threads).
Same class as the router fix: nine stop paths released their group from the owner-death supervisor
as soon as the leader exited, but members that ignore TERM or outlive the leader keep the group
alive. Releasing it let those members survive a later kill -9 of this process.
Lightpanda, real-profile Chrome, embedded cua-driver, the TTS command provider, dashboard WhatsApp
pairing, the raft and WhatsApp bridges, verify's app server, agent-browser session groups, and
Browser Use harness daemons stopped by --reload now go through release_process_group_once_empty.
New test stops a raft bridge whose TERM-ignoring helper survives. It fails when raft releases
unconditionally, and the group stays covered with the fix. Test seams moved from the per-module
release_process_groups name to the shared helper.
Reported by Greptile on #137057 (thread on the router).
A child started in its own session or group (start_new_session, os.setsid /
setpgid / setpgrp, windows_detach_popen_kwargs) does not die with a SIGKILLed
Hermes: it reparents to init and runs forever. That is how every family this PR
migrates leaked. With the families on spawn_owned, this keeps the class closed.
scripts/check_detached_spawns.py (AST) flags those shapes in the production trees
unless the line, or the line above it, says `detached-spawn: ok — <why>`. It runs
in scripts/check ("detached-spawns") and as a blocking lint.yml step. The baseline
is empty: every remaining site is on spawn_owned / own_process_groups, or carries
its reason. The reasons this commit adds are the census verdicts:
- must outlive the starter on purpose: restart watchers, /update and the updater
hand-offs, dashboard/desktop/service launches, cron and kanban workers
(restart-safe), the update-custody watchdog itself;
- awaited with a group kill on timeout: cron scripts, rg search, the Browser Use
CLI, update completion (holds the checkout lock fd);
- covered by its own parent guard: the compute host (compute_host._parent_guard_loop
flushes sessions; a supervisor KILL could cut that short);
- not a spawn: the wake-word `start_new_session` config key and event field.
tests/scripts/test_check_detached_spawns.py: each shape flagged, non-detached and
commented/string shapes not, the marker opts out on its line or the line above
and nowhere else, tests and the helper are out of scope, main() fails on a new
unmarked spawn, and the repository scan is empty. Teeth: appending an unmarked
start_new_session Popen to tools/file_operations_search.py turns
`scripts/check --only detached-spawns` red (rc 1); restoring it turns it green.
Names the owned-child API in process_identity layer 4:
- spawn_owned(argv, purpose=..., **popen_kwargs): starts the child as a session/group leader,
hands the group to the owner-death supervisor and records it in the spawn ledger.
- own_process_groups(pgids) / release_process_groups(pgids): for groups something else spawned
(MCP SDK servers, agent-browser's Chromium, harness daemons) and for children the owner stopped
itself.
The stringly update_supervised_pgids("register"/"unregister", ...) becomes the private protocol
writer. llama-server's spawn_server(owned=True) now goes through spawn_owned instead of
re-spelling it. Adds a contract test for spawn_owned (group leader, supervisor registration,
ledger entry, release); it goes red when the registration is removed.
browser_harness detaches its daemon on purpose (start_new_session) so a session persists across
browser_exec calls, and the daemon has no idle exit. A SIGKILLed or OOM-killed Hermes therefore
left every daemon it drove running forever, each holding a CDP connection (#121095). A clean exit
leaked them too: stop_harness_daemons() only ran from cleanup_all_browsers(), which the atexit
handler calls only when an agent-browser session was tracked, and a browser_exec-only process
never tracks one (measured: 4 of 4 daemons leaked after the owners exited normally).
After each browser_exec, the daemon behind its BU_NAME is handed to the per-process owner-death
supervisor. The harness publishes the daemon pid in its runtime dir; it is accepted only while it
is this user's live `python -m browser_harness.daemon` leading its own session, so a stale or
planted pid file can never put a stranger's group in front of the supervisor. stop_harness_daemons()
releases the groups it stopped, and the atexit handler now calls it unconditionally.
Replaces the per-family reaper of #120739 (trevornk, owner-pid claim files + a janitor sweep of
dead-owner daemons, +1150 lines): the owner dying is detected by the shared supervisor at the
moment it happens, not by the next Hermes that happens to start the browser janitor, and the live
control daemon of another Hermes is never in this process's registry at all. The claim-file idea
(trevornk) and the per-owner-dir idea (#129655, mheals / Diaspar4u) are what this keys on: the
daemon's own pid file under the runtime dir the CLI ran with.
Outside a served profile, browser-harness binds
<home>/.config/browser-harness/runtime/bu-<BU_NAME>.sock. A deep HOME (a
container's profile home $HERMES_HOME/home, a long account home) or a long
session name pushed that past sun_path and every browser_exec died with
"browser-harness: fatal: AF_UNIX path too long". Only served profiles had a
short-dir fallback.
browser_exec now judges the default socket on the call's final BU_NAME and,
when it would overflow, points BH_RUNTIME_DIR at a private 0700 hbh-<hash>
dir (keyed by uid and harness home): the user's runtime dir
($XDG_RUNTIME_DIR, else /run/user/<uid>) first, the short socket temp root
only where none exists (containers, macOS). A socket that already binds keeps
its path and its live daemon; an exported BH_RUNTIME_DIR/BH_TMP_DIR is kept.
The direct-API Browser Use route stamped "cloud" from configuration before the harness chose its
browser. With BU_AUTOSPAWN the harness attaches to a local Chrome that is already listening, and
capture_screenshot()/new_tab() then switched the user's visible tab. That route now asks the live
harness daemon (daemon_browser_kind() == "cloud", set only by a BU_BROWSER_ID cloud browser) at each
call; a provider session whose CDP endpoint Hermes resolved keeps activating, every local, connected
or autospawn-fell-back-to-local browser never does.
capture_screenshot() activated a hidden agent tab on every backend, so on
/browser connect, the real-profile browser or a local headed Chrome each
screenshot switched the user's visible tab. Activation now follows the same
cloud flag new_tab uses; the 10 s png deadline and jpeg fallback stay on every
backend. new_tab's activation on cloud no longer raises after the tab exists
when a provider rejects Target.activateTarget.
Chrome draws no compositor frame for a hidden tab, and Browser Use cloud
never answers a png Page.captureScreenshot for one, while the harness
creates its tabs in the background. browser_exec now launches the harness
through a thin launcher that rebinds capture_screenshot() (bring a hidden
tab to the front, png with a 10s deadline, then one jpeg fallback saved
as png) and, on cloud-provider browsers, new_tab() (activate the tab).
The model code still arrives untouched on stdin.
Found on Hermes Cloud staging.
Greptile finding "Browser recommends a missing tool": the non-native
browser_exec header picked its vision_analyze pointer from
check_vision_requirements(), which reports whether a vision route exists,
not whether this session exposes the tool, so a session with `vision`
disabled was told to call a tool it does not have (tools/AGENTS.md:
cross-toolset references are added in get_tool_definitions()).
The header now states only the transport fact ("Screenshots are not
attached to this tool's results. Work text-first: ..."), still never
calling the model blind, and model_tools' browser_exec rewriter appends the
vision_analyze pointer when "vision_analyze" is in the session's available
set. The native header (screenshots ride back in the result) never gets it.
Prompt-surface fixtures re-rendered: the stock render has vision_analyze,
so browser_exec gains the pointer (+8 tokens per surface).
The non-native header told every model whose screenshots don't ride back in tool results
"Your model cannot view images ... skip the screenshot-driven workflow described below".
The gate (_should_use_native_vision_fast_path) is a routing fact: decide_image_input_mode is
"text" when auxiliary.vision is pinned explicitly (by design, #16506) or the catalog cannot
attest the model. A vision-capable main model read the line against itself, and no
screenshot section follows the header.
Three honest variants now: attached natively (unchanged), "not attached to this tool's
results; pass the capture_screenshot() path to vision_analyze" when the vision_analyze gate
(check_vision_requirements) has a route, and "no vision route is configured" otherwise.
Lightpanda keeps its own text-first line without the misleading prefix.
The browser_exec description picks its text-first header from
_should_use_native_vision_fast_path(), which measures whether screenshots can
ride back inside TOOL RESULTS for the active provider/model. The header then
asserted a model-level fact ("Your model cannot view images") that was never
tested, and a vision-capable model on such a provider (deepseek-flash in the
report; nous/claude on this host) quoted it against itself and skipped an
image the user had attached to the conversation.
Reword the header to state only what was determined: screenshots will not
reach the model through this tool's results, work text-first, and this says
nothing about user-attached images. Same guidance, no capability claim.
Reported and diagnosed by @dcdc4747 in #131568.
The deferred tool_search catalog shows each tool's first sentence clipped to
60 chars, so lines like 'image_generate: Generate high-quality images from
text prompts, or edit /…' hid that it edits with reference images on the
user's configured model. An agent skipped it and called FAL directly with a
hardcoded model.
- catalog line cap 60 -> 80 (CATALOG_SUMMARY_MAX_CHARS); every built-in
tool's first sentence now fits and leads with what it does
- image_generate/video_generate say they use the configured model;
image_generate says to use it rather than direct API calls/scripts
- web_search/web_extract/browser_exec name when to use each other
- drop a duplicated cronjob sentence and filler in skill_view/video_generate
- regenerate tests/fixtures/prompt_surface
A local browser_exec call (hybrid ::local sidecar, cloud fallback, real profile) was labelled by re-reading
browser.engine after the call. A session created before the engine changed (a routed profile re-reads config
every call), or the real-profile Chromium, could therefore be counted as Lightpanda, and a Lightpanda session
as Chromium.
The route now carries the engine of the session it actually ran on ("local" or "lightpanda"; the real profile
is always Chromium) into the metrics label instead of reconstructing it from configuration.
browser.user_data_dir, chromium_args, cloud_provider and every other browser.* knob were read with
read_raw_config, which skips the managed overlay and ${VAR} expansion: a managed profile pin or
flag set was ignored, and ${HOME}/chrome-profile became a literal dir under HERMES_HOME. The session
layer's one reader (browser_session_cloud.browser_section) now uses load_user_config_effective, and
the other raw browser.* reads go through it or the same loader: browser_exec's cloud routing
(browser_use_cli._read_browser_cfg), the real-profile pin (browser_connect._browser_setting) and
/browser status's cdp_url (methods_browser, now browser_session_cdp.get_cdp_override_raw). Tests
that stubbed read_raw_config for browser.* now stub the effective loader.
The handler named the configured cloud provider for every call, so hybrid ::local sidecar, cloud
fallback and real-profile calls counted against browserbase. The test now drives the real
_handle_browser_exec instead of rebuilding the wiring.
- locales: drop the /browser use, Browser Use mode and agent-browser status keys whose callers are gone;
reword status/usage/description lines and tips t180-t182 (contiguous tip keys kept) in every locale.
- browser_launcher: a bare command name in browser.executable_path resolves through hermes_platform's
locate_command (no shutil.which); the LANE fallback for chromium_missing_hint is gone.
- browser_cdp: drop the Camofox sentences from its description and error.
- shared metrics: record_browser_call loses the extension-controller wrapper (no browser_* tool routes
through it any more) and browser_exec's registry handler calls it, so the browser execution-backend
series keeps reporting for the only browser path.
- test_profiles: the clone/live-browser test uses browser_launcher.running_instance.
Live probe: browser-harness tracks native dialogs in its own daemon
(Page.javascriptDialogOpening on its own target session) and the task's CDP
supervisor never captured one on harness-driven pages, so the field had no
working source. browser_dialog's text now describes what it actually does:
answer a supervisor-held dialog, its error listing candidate ids.
browser_exec is the only core browser tool (plus browser_cdp, browser_dialog,
browser_vault, all CDP). Deleted: browser_navigate/snapshot/click/type/
scroll/back/press/get_images/vision/console and every module that served
them (browser_tool_session/_lifecycle/_cloud/_cdp/_real_profile/
_lightpanda_fallback/_eval_policy/_origin/_snapshot/_vision) plus
browser_camofox*.py (Camofox ships as the catalog plugin 'camofox').
tools/browser_tool.py and tools/browser_tool_install.py shrink to the
frozen old-updater stub warm_agent_browser_npx_cache.
toolsets: _HERMES_CORE_TOOLS / browser toolset list only the CDP tools.
model_tools: browser_tools legacy alias and the browser_navigate /
browser_type schema rewriters removed. Cloud providers no longer request an
install post_setup hook (nothing to install).
- browser_vault: supervisor-only (no agent-browser eval fallback); attaches
on demand to the task's session cdp_url; check_fn = browser_exec available
or a CDP override.
- browser_cdp: endpoint + SSRF guards from browser_session_cdp /
browser_url_policy; the private-page probe reads the target's URL over the
same CDP endpoint; gate = browser-harness importable + CDP override.
- browser_dialog: pending dialogs now arrive in browser_exec results
(pending_dialogs) instead of the deleted browser_snapshot.
- browser_extension_router serves browser_cdp only.
browser_exec no longer shells out to agent-browser: local browsers (real
profile, Lightpanda, packaged Chromium) come from
browser_session.get_session_info, whose sessions always carry cdp_url, and
the cloud fallback_from_cloud path reuses the same local session.
check_fn is browser_exec_available() (browser-harness importable).
Removed is_browser_use_cli_mode, default_downgrade_notice,
set_browser_use_mode, get_browser_backend and BACKEND_DISABLED; the
harness env gets only BROWSER_USE_API_KEY from the profile secret scope.
Three review points on the served-profile harness dirs:
- The length check measured BH_RUNTIME_DIR as supplied, but the harness
binds `Path(BH_RUNTIME_DIR).expanduser().resolve()`
(browser_harness/_ipc.py:23). A short relative (`BH_RUNTIME_DIR=rt`
from a deep cwd) or symlinked spelling skipped the short-dir fallback
while the real socket exceeded sun_path. The candidate is now expanded
and resolved before measuring, on Linux and macOS alike; a dir that
fits is still returned exactly as given.
- The dir selection, socket budget and private-dir claim move from
tools/browser_use_cli.py (which had grown past 1,000 lines) to a new
tools/browser_harness_dirs.py, together with the daemon identity
(HARNESS_DIR_KEYS, daemon_identity, daemon_env).
_base_subprocess_env applies namespace_harness_dirs; browser_use_cli.py
is back to 1,000 lines.
- The budget is a pure function of the platform
(`socket_dir_budget(platform)`, `fits_socket_budget(dir, budget)`), so
the macOS length rule is tested with macOS data and no longer patches
sys.platform. The real-platform bind tests stay marked
platforms("macos") / platforms("linux").
Red on the previous head: the relative and symlink cases of the new
Linux test (resolved socket 249/246 bytes > 107).
Refs #134889 (GW-23)
On Linux a served profile's harness runtime dir ~/.config/browser-harness/runtime/p-<12hex> left
room for only 38-character session names at /home/teknium (30 at /home/alexander.smith) under the
108-byte sun_path, while BU_NAME may be 64; the daemon could not bind for longer names.
_socket_fit_runtime_dir now applies the macOS short private dir claim on Linux too, with Linux's
budget (107 - len("/bu-.sock") - 64 = 34 bytes): hbh-<12hex> under socket_safe_tmpdir(), else under
the sticky system temp root, claimed only through _claim_private_dir (mkdir 0700, or an existing
real dir owned by this uid with no group/other bits). A dir that already fits is kept unchanged, and
an unclaimable one keeps the long path. Windows (loopback TCP) is unchanged.
Refs #134889 (GW-23)
browser_exec resolves the live endpoint into BU_CDP_URL in _route_exec, and records its harness
daemon only inside dispatch(). A /browser connect landing between the two reaped nothing, the CLI
spawned the daemon on the old endpoint, and the daemon (which latches BU_CDP_* at spawn) kept
driving the old browser for every later call in that profile.
browser_exec now snapshots the profile's live CDP generation before routing and re-routes (at most
3 attempts) when it moved during routing; after dispatch, a moved generation reloads this call's
daemon through the existing --reload path so the next call respawns on the current endpoint.
Refs #134889 (GW-23)
The harness writes shot.png, debug-click overlays and bu-<NAME>.log under
BH_TMP_DIR (browser_harness/paths.py tmp_dir, else <home>/tmp). A served
profile already had its own BH_RUNTIME_DIR but still shared that tmp dir, so
one profile's screenshots and daemon logs sat beside another's.
_namespace_harness_daemons now also sets BH_TMP_DIR to <tmp root>/p-<hash>
(nested inside an inherited BH_TMP_DIR when one is set) with
BH_TMP_DIR_SHARED=1 so log names keep the bu-<name> stem. The runtime dir
still derives from the inherited value, as before. The driven-daemon identity
now carries the tmp keys too, so an unscoped shutdown --reload reaches the
daemon with its own tmp dir. Single-profile processes are unchanged.
Refs #134889 (GW-23)
Refs #134889 only
A served profile's Browser Use daemons get their own BH_RUNTIME_DIR
(~/.config/browser-harness/runtime/p-<hash>), shared by several BU_NAMEs, so
the installed harness names each socket <dir>/bu-<BU_NAME>.sock
(browser_harness/_ipc.py _runtime_stem/_sock_path). On macOS sun_path is 104
bytes; with a default HOME that path is 63 bytes on a 9-letter account, which
left room for only ~31-character session names although BU_NAME may be 64.
When the per-profile dir is over the 30-byte budget on macOS, the profile now
gets a private dir under the short socket root (/private/tmp/hbh-<12 hex>,
keyed by uid, harness root and profile). An existing dir is accepted only when
it is a real directory owned by this uid with no group/other bits; otherwise
the long path stays. Linux and single-profile processes are unchanged.
Refs #134889 (GW-23)
Refs #134889 only
The harness names a daemon by BU_NAME alone (an unnamed browser_exec is
"default") inside one runtime dir and reuses any live daemon of that name.
On a multiplexed gateway profile B's unnamed exec therefore reused the
daemon A had spawned on A's /browser connect endpoint and drove A's
logged-in browser. The owner map was keyed by BU_NAME and last-writer-wins,
so A's reap stopped nothing after B touched the daemon, or killed the one B
was using.
Under a served-profile scope _base_subprocess_env now points
BH_RUNTIME_DIR at a per-home subdirectory (sha256 of the home key) of the
harness runtime dir, with BH_RUNTIME_DIR_SHARED=1 so names keep their
bu-<name> stems. _driven_daemons is keyed by (runtime dir, shared flag,
BU_NAME), and stop_harness_daemons reloads each daemon in the dir it was
started in. Outside a served-profile scope the env is unchanged.
Test: A and B unnamed execs get different daemons on their own endpoints;
A's reap stops only A's daemon, B keeps its browser and A respawns on its
new endpoint (red on the previous head: B got A's endpoint).
Refs #134889 (CLI-9)
/browser connect wrote the process-wide BROWSER_CDP_URL and reaped every
task's browser, so on a multiplexed gateway one profile's live browser
reached every other profile's sessions.
- tools/browser_tool_cdp: live overrides are a lock-protected map keyed by
hermes_home_key() (set_live_cdp_override / live_cdp_override).
Precedence: this profile's live connect, then the operator's
BROWSER_CDP_URL env, then browser.cdp_url. Camofox yields to it too.
- Browser sessions record the home_key that created them; CDP supervisors
and Browser Use harness daemons remember theirs.
- cleanup_profile_browsers(home_key) closes only that profile's sessions,
supervisors (SUPERVISOR_REGISTRY.stop_home) and harness daemons, and
drops its per-home config cache slots. cleanup_all_browsers is unchanged.
Refs #134889 (CLI-9)
Review findings on the fallback:
- browser_exec(local=true) under a cloud backend fell back to the CLOUD
browser when the profile could not load. It now runs on the local
sidecar browser (which never loads the profile) and the route keeps it.
- Without local, the session layer makes the one real-profile-or-fresh
decision for the browser it actually launches; browser_exec reports that
session's note instead of its own earlier attempt, so the note can never
describe a different browser.
- The note is delivered on the first result that reaches the model: a
failed first navigation or a timed-out exec no longer swallows it.
With browser.use_real_profile on, every browser call failed whenever the
profile could not be snapshotted: Windows with Chrome open (cookie DB
locked), a non-Chromium default, a bad pin, a launch failure. The browser
tool was unusable until the user quit their browser or found the toggle.
Now the session runs on a fresh browser without the user's logins and the
first result carries `real_profile_unavailable` with the reason, so the
model says it is signed out instead of failing or pretending. Built-in
tools keep the fallback for the session's life; browser_exec remembers it
per route so a task never swaps browsers mid-way.
Docs and config comments describe the new behaviour. The touched real-profile
test file also gets explicit encodings (Windows footgun checker).