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).
The supervisor starts lazily, on the first owned spawn of any family (slash worker, terminal job,
...). When that lands between an MCP stdio connect's before/after child snapshots, the delta holds
the supervisor and _filter_mcp_children kept it: MCP tracked it as its own server, and teardown or
the orphan sweep would group-kill it, leaving every other owned child unreaped if Hermes then died.
_filter_mcp_children now drops this process's supervisor, matched by its live pid and its script
argv (process_identity.is_owner_death_supervisor). New test drives the race with a real owned spawn
and a real supervisor; it fails with the check removed (supervisor pid in the adopted set).
Reported by Greptile on #137057.
LSP, the code kernel and the slash worker each had their own "release the group once nothing in
it is left" (a killpg(pgid, 0) probe; the kernel's version also waited for reaps). They are now
one helper, process_identity.release_process_group_once_empty(pgid, proc=, timeout=). It polls
the leader so a zombie leader does not keep the group alive, waits up to `timeout` for killed
members to be reaped by init, and keeps covering a group that still has a member. LSP's async
close path probes once (timeout=0), as before.
The slash worker used to probe exactly once right after SIGKILL. On a loaded macOS host (load
25+) init had not reaped the killed members yet, so a group that was about to be empty stayed
registered (test_close_stops_the_whole_group_then_releases_it, flaky). It now waits up to 1 s,
like the kernel did.
The kernel survivor test raced too: under load the cell child's `trap '' TERM` could land after
the teardown's SIGTERM, and the 5 s escalation could SIGKILL it. The child now signals once its
trap is installed, and the test turns escalation off (the escalation is not what it pins).
New tests/hermes_cli/test_process_identity_release_once_empty.py: an unreaped empty group is
released, a live member keeps it covered, a late exit is waited for, and Windows never releases.
Teeth: forcing the helper to always release, or to never release, turns 5 tests red in the 4
touched files. macOS: the 9 owned-child files, 78 tests, 3 runs in a row, 0 flaky.
A session in a non-standard permission mode (unrestricted = YOLO, or bounded) gets a private
`cua-driver serve --embedded` daemon. On Linux/Windows it was a plain Popen child. Only
_EmbeddedCuaDaemon.stop() (session release / the computer_use atexit handler) ended it, and cua-driver
does not exit when its parent dies. A SIGKILLed or OOM-killed Hermes therefore left an approval-bypassing
daemon listening on its socket with nothing left to stop it.
On POSIX non-macOS the daemon is now started with process_identity.spawn_owned and released in
stop(). macOS is unchanged: there the launch goes through `/usr/bin/open` to LaunchServices, so the
daemon is launchd's child and never in our tree. Windows keeps the plain Popen (spawn_owned is a plain
Popen there; the layer-3 job object covers it). The cua-driver MCP proxy needs nothing: it is an stdio
child of the MCP SDK (already start_new_session) and exits on stdin EOF, measured 0/3 alive 0.1 s after
the owner's SIGKILL on base.
Measured on Linux (real cua-driver 0.21.0 serve --embedded, kill -9 of a real owner process):
base: 1/1 cua-driver serve alive 8 s after SIGKILL
branch: 0/1 alive after 0.0 s; with the owner still alive, 1/1 untouched after 6 s
Tests: the kill -9 + live-owner-control case (red when spawn_owned is reverted); the socket/ack contract
test now also pins the register at start / unregister at stop. Three existing tests that hand the
daemon a fake Popen stub the supervisor so a fake pid never reaches it.
Command providers run in their own session so the IDLE timeout (default 120 s, reset by every byte
of output) can kill the whole tree. That timer lives in the Hermes process: a SIGKILLed or
OOM-killed gateway left a stalled or long-running provider (a shell plus its synthesiser) running
forever, detached and reparented to init.
run_command_provider now starts the command through process_identity.spawn_owned (POSIX: group
leader, group handed to the owner-death supervisor, so provider_popen_group_kwargs no longer adds
start_new_session) and releases the group once the command has exited or the idle kill stopped it.
Windows keeps its CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW flags and taskkill tree kill.
Measured on Linux, owner killed inside the idle timeout, 6 s settle: origin/main 3 of 3
survived; this commit 0 of 4 descendants. New kill -9 / live-owner case and an own-then-release
test (success and idle kill); reverting spawn_owned to the main-era Popen turns the kill -9 case
red. Existing spawn-kwargs tests now patch the module's spawn_owned seam.
Symptom: ProcessRegistry.spawn_local starts every terminal(background=true) job in its own session, and
the agent-lifecycle sweeps that stop jobs (kill_all on release, agent_close, a turn timeout) only run
while the owner is alive. A CLI, TUI or worker that is SIGKILLed / OOM-killed / crashes left every job
running on init. Measured on Linux (tbg_probe, kill -9 the owner, check at +10 s, 2/2 runs): pipe job
1/1 alive, pipe job with a child 2/2 alive. A PTY job's hangup stops only jobs that keep the default
SIGHUP action: a HUP-ignoring PTY job (`nohup`'d server, trap '' HUP) and its child 2/2 alive.
Change (tools/process_registry_ownership.py, a new ProcessRegistry mixin; process_registry.py is at its
size cap and shrinks by 10 lines): a local background job's process group goes to the owner-death
supervisor (process_identity layer 4) for as long as the job's own process runs: pipe jobs start through spawn_owned
(purpose="terminal-background", recorded in the spawn ledger), PTY jobs hand their pty.fork group to
own_process_groups. The group is released when the job leaves _running (exit, kill, reconcile) and by
_reap_untracked after a failed setup, so a job's deliberate `server &` survivors keep today's
behaviour once the job ends. A foreground command that yields to background (adopt_local) hands its
supervised group to the job instead of releasing it.
Deliberately NOT owned (they must outlive the owner):
- persist_on_release jobs (#41225, ec5c9c738a): the user asked for them to outlive the agent.
- every job of a gateway (a host that ran recover_from_checkpoint, or a supervised gateway): it
re-adopts the jobs a crashed predecessor left running, so its own jobs must survive its crash the
same way. Its clean shutdown still kills them (kill_all(source="gateway_shutdown")).
- Windows: the layer-3 job object covers ownership; the spawn path there is unchanged.
The systemd-scope, TERM->KILL tree kill, start-time PID-reuse guards and post-kill survivor checks stay:
they cover a live owner.
Result: same probe, 3/3 runs: pipe 0/1, pipe+child 0/2, HUP-ignoring PTY job + child 0/2 alive; the
persist_on_release job 1/1 alive (as intended). tests/tools/test_terminal_owned_jobs.py now also covers
jobs: kill -9 owner vs live control owner (jobs + PTY job + command die, persist_on_release job lives,
control untouched), a recovering host's jobs outlive its kill -9, finished job releases, yielded
command keeps its group until the job ends, unowned jobs never reach the supervisor. 5/5 green x3, 5/5
red on the pre-change code, each red on its own mutation (8 mutations). Two existing tests build
sessions by hand or fake Popen + os.killpg; they now carry the new field / stub the supervisor.
_reap_untracked moves into the mixin unchanged apart from the release.
Symptom: LocalEnvironment._run_bash starts every terminal command in its own session
(start_new_session=True, so the TERM->KILL group teardown reaches its children). Nothing reaps that
group when the Hermes process dies without running its cleanup (SIGKILL, OOM killer, crash): the
command and everything it started reparent to init and keep running. Measured on Linux (tbg_probe:
an owner runs `sleep 305` in env.execute() on a thread, owner gets kill -9, check at +10 s): bash and
sleep 2/2 alive, 2/2 runs.
Change: _run_bash hands the command's group to the owner-death supervisor
(process_identity.own_process_groups; pipe EOF -> TERM, 3 s, KILL). LocalEnvironment._wait_for_process
releases it once the wait returns, by any path (exit, timeout, interrupt), so what a command
deliberately leaves in the background after it returns (`server &`) keeps its current behaviour, the
same as a graceful exit. Not spawn_owned: an awaited command needs no spawn-ledger entry. Windows is
unchanged (the layer-3 job object). The existing TERM->KILL teardown, the setsid-escapee sweep and the
start-time PID-reuse guards stay: they cover a live owner.
Result: same probe, 3/3 runs: 0/2 alive. Per-command cost with the supervisor resident: own+release is
0.02 ms (3.4 ms when it has to start the supervisor); env.execute("true") 20.8-24.2 ms on the base vs
22.4-23.4 ms here, inside load noise. New tests/tools/test_terminal_owned_jobs.py (kill -9 owner vs live
control owner; a returned command releases its group): green x3, both red on the pre-change code and red
on their own mutation (no own / no release). test_local_env_cwd_recovery fakes subprocess.Popen, so its
class now stubs the supervisor calls.
Symptom: the POSIX death pipe (365e2835d4) only told the KERNEL its host had died. Every subprocess a
cell starts (a dev server, a `sleep`, a training job) shares the kernel's process group and never sees
that pipe, so a SIGKILLed / OOM-killed host left them running on init indefinitely. Measured on Linux
against origin/main 7770e397f3 (ck_probe: host spawns a kernel, the cell Popen()s `sleep 300`, host
gets kill -9, check at +10 s): kernel 0/3 alive, cell child 3/3 alive.
Change: _spawn starts the kernel through process_identity.spawn_owned(purpose="code-kernel"): it leads
its own group (as before, via start_new_session), that group goes to the per-process owner-death
supervisor, which killpg()s it the moment the host dies by any cause, and the kernel is recorded in
the spawn ledger. teardown() releases the group once it is empty (waiting up to 1 s for SIGTERMed
cell children to exit); a cell child that survives the teardown's SIGTERM keeps the group registered
until it exits. The kernel-only death pipe (runner watchdog thread, pipe plumbing,
HERMES_KERNEL_PARENT_DEATH_FD) is deleted: the supervisor kills the kernel too. Windows keeps its
SYNCHRONIZE-handle watchdog unchanged; atexit graceful shutdown, the idle reaper and the
stale-staging-dir sweep stay (they cover a live host and disk, not owner death).
Result: same probe, 3/3 runs: kernel 0 alive, cell child 0 alive. tools/code_kernel.py +25/-57.
New tests/tools/test_code_kernel_owned_group.py (kill -9 owner vs live control owner, graceful
release, surviving-child coverage): 3/3 green x10 runs, all 3 red on the pre-change spawn, each red
on its own mutation (no registration / no release / unconditional release). Family files on main
75 passed; on this branch 78 passed (75 + 3 new).
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.
Narrow the release-time wait to subprocess.TimeoutExpired and log it, instead of a silent blind
except (health BLE001/S110). subprocess becomes a top-level import. The Browser Use kill -9 test
polls with tests.waiting.wait_until rather than a hand-rolled sleep loop (HX013).
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.
The parent-death supervisor that only stdio MCP servers could use (tools/mcp_death_supervisor.py
+ the client in tools/mcp_tool.py) becomes layer 4 of hermes_cli/process_identity.py, next to the
spawn ledger and the Windows job object, so every long-lived child family can use the same path
instead of shipping its own reaper. MCP's three call sites now call
process_identity.update_supervised_pgids; the protocol (register/unregister <pgid>, EOF = owner
died, TERM -> 3 s -> KILL, unsafe targets refused, replay on respawn, release when empty) is
unchanged and every existing contract test moves with it.
The supervisor itself is now POSIX sh (hermes_cli/process_supervisor.sh) instead of a second
CPython: it stays resident for the life of any Hermes process with a supervised child, and an
idle sh is 0.5 MB USS against 8.1 MB for the Python supervisor (Linux, py3.14, measured).
Malformed and over-long lines are skipped exactly as before; the only protocol difference is
that a line is no longer length-capped while being read (sh's read has no cap), which only a
writer inside Hermes could exploit.
Greptile on #146352: `printf x > "/proc/self/comm"` slipped past the write check because the
redirect form required an unquoted path, and `from plugins.memory.<name> import _db` still warned
because only the module part was matched against the plugin's own files. Both now covered, with
attack/false-positive twins red on the previous head.
Install scanner (tools/plugin_guard*, PLUGIN_SCANNER_VERSION bumped once):
- hardcoded_secret: a PostHog project key (phc_, write-only ingest key) joins the
Google installed-app secret as a public client key -> high (caution), only
when every matched literal on the line has a public prefix (telesec
telemetry.py:27 was dangerous). phx_ personal keys and any other token stay
critical.
- proc_access: reads of /proc/self|<pid>/{cgroup,mountinfo,stat,status,...}
(container placement, pid start time) land at low instead of high
(hermes-lcm-x cpu_capacity.py was caution). environ, cmdline, mem, maps, fd,
root/cwd, ns, bare /proc/self, any unlisted leaf and any write keep high.
Generalises #144304's cgroup/mountinfo allowance and keeps the finding
visible instead of dropping it.
- bytecode_file: a committed .pyc/.pyo (git ls-files; plus any bytecode outside
__pycache__) is a high structural finding, the binary_file tier (rule 17;
hermes-emotion shipped tests/__pycache__/*.pyc and scanned safe). Untracked
caches the validate run writes are not flagged.
Validator (hermes plugins validate, warnings only):
- private imports: gateway.session_context.get_session_env is the documented
route (plugins/index.md) and a plugin's fallback import of its own install
path (plugins.memory.openltm._db) is not a core import.
- new warning for private-method calls on core handles (SessionDB, AIAgent,
GatewayRunner, PluginContext) the plugin does not define itself
(opencode-sync db._execute_write, runner._evict_cached_agent).
- desktop surface review warning for raw window.hermesDesktop calls and app
markup selectors ([data-slot], [data-tree-*], [data-pane-host]) in CSS text
or closest() (squad-hub, novel-reader, search-sources).
Container CPU-quota detection needs the process's cgroup membership and mount layout, and language runtimes read them for container resource discovery. proc_access flagged the plain reads as high, so a plugin that sizes local work inside a container scanned CAUTION and unattended updates stopped (#144123).
Drop the finding only when every /proc path on the (logical) line is one of those two reads: a write, any other proc path or a bare /proc/self keeps it. Scanner version bumped so quarantined pins are re-scanned.
(cherry picked from commit 481c5ca3bfa9c4c68547144b141a2f2acd8afc48)
They resolve against the terminal's cwd, so checking them with isdir from
the Python process's cwd dropped a project's 'bin' whenever the two
differed. Only absolute entries are checked for existence now.
A CI runner's login shell picks its own HOME and startup files, so a
test-written ~/.profile was never read there (HOME=/home/runner in the
child even with the profile home mode). The stand-in shell resets PATH
itself, then runs the command; spawn env, argv and the restore helper
stay the production ones. Polls with wait_until instead of sleep.
Spawns re-derive HOME (a host keeps the real one), so on CI the login
shell read /home/runner's startup files and the test's ~/.profile never
ran. TERMINAL_HOME_MODE=profile makes the child's HOME
{HERMES_HOME}/home on every runner; the .profile lives there.
The login shell read the CI runner's own startup files instead of the
test's ~/.profile, so the profile-first ordering never applied there.
HOME now rides in the spawn env and the child's HOME is asserted, so a
miss names its cause.
Background terminal commands run `bash -lic` with no env snapshot, so a
~/.profile or distro /etc/profile that resets PATH dropped every parent-only
dir (bare `hermes` / the venv's tools: command not found), while the same
command in the foreground now resolved. spawn_local gains an opt-in
restore_login_path that prepends the SAME _append_dropped_path_entries
prelude the foreground snapshot uses, fed from the spawn env's PATH; the
terminal tool's local background spawn turns it on. The registry's shell
argv shape is unchanged.
The terminal tool's env snapshot is captured by `bash -l`, and Debian's
/etc/profile resets PATH for every login shell, so the snapshot pinned the
reset PATH over the spawn env for every later command. In the Docker image
that dropped /opt/hermes/bin and bare `hermes` exited 127 (#56634).
The snapshot bootstrap now re-appends, in parent order, every spawn-env PATH
dir the login shell dropped (not only Hermes' bin dir: the gateway's pm
runtime dirs and `docker run -e PATH=` additions too). They go after the
login PATH, so a command that resolved before resolves to the same binary
and the user's ~/.profile additions keep precedence.
The image also ships /etc/profile.d/hermes.sh, which re-adds the ENV PATH
dirs for login shells the snapshot never covers: the terminal tool's
background `bash -lic`, `docker exec <c> bash -l` and ssh.
Found on Hermes Cloud staging.
Debian's /etc/profile unconditionally resets PATH for non-root shells
before sourcing /etc/profile.d/*.sh, so the login-shell env snapshot
serialised the reset PATH and dropped the venv dir the process env put
there (#56634) — bare python3/pip then resolved to the system
interpreter.
The previous approach wrapped the command with a save/restore pair,
but the restore landed after the bootstrap's export -p, so the snapshot
kept the reset PATH anyway. Restore now runs between the init-file
prelude and the command, via idempotent per-entry case guards for
_resolve_hermes_bin_dir() + _managed_runtime_path_entries(), so
restored entries survive into the snapshot and reruns stay
duplicate-free. Tests read the PATH back from a real init_session
snapshot instead of asserting on injected markers.
Rebased onto current main (the branch had gone CONFLICTING).
Covers the private XDG runtime dir being chosen (and an open, symlinked,
relative or missing one rejected), the short dir landing 0700 under it,
and an existing short dir claimed only when it is a private real dir.
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 cronjob schema is sent on every API call. Keep `timezone` (the feature)
with a one-line description and leave the catch-up window override
(`grace_minutes`) to the CLI and dashboard, where it is already settable.
The handler still accepts it, so nothing that passes it breaks.
The catch-up window (how late a missed cron occurrence may run instead of being skipped) was
half the job's period, clamped to 120s-2h, for every job. A job can now override it outright:
0-1440 minutes, `0` meaning never catch up.
`grace_minutes` is a real 0, not "unset" — and the obvious write pattern would eat it:
`v in {None, "", False}` (the `workdir` update lambda) and `if value:` both treat `0` as
False in Python. Both doors therefore share `jobs_time.normalize_grace_minutes`, reads test
`is None`, and the renderer formats before testing truthiness.
The override moves the dispatch stamp too: `_classify_dispatch_lateness` and the dispatch
health metric read the same window, so a job the scheduler calls "late" is never reported
overdue by the dashboard.
Refused on `once`/`interval` schedules: the window describes a missed wall clock, and a
duration has none.
Split from the timezone commit so it can be reverted alone.
A job may pin its own IANA timezone; its cron expression is then that zone's wall clock,
independent of the profile's configured timezone. Absent/None inherits the profile, so an
existing jobs.json keeps byte-identical behaviour and needs no migration.
The dispatch path needs the pin as much as the compute does. `compute_next_run()` resolves
the zone as job pin -> profile zone -> base offset, and every site that writes `next_run_at`
now passes it (advance, claim, resume, re-arm, recovery, and the quota/unreachable
planners); one missed site re-fires or skips a slot because the stored instant and the
expression would be read in different zones.
`_evaluate_due_job()` normalizes the stored instant into the JOB's zone, which hands every
downstream cron predicate the job's clock, and a pinned job skips
`_repair_timezone_shifted_cron` outright. That repair exists for jobs that FOLLOW the profile
zone across a zone change: on a pinned job its wall-clock comparison reads a due occurrence
as still-in-the-future and re-anchors past it.
Failing shape this fixes (profile America/Los_Angeles, job 0 9 * * 1-5 pinned to
America/New_York, scanned at 09:00 New York): `get_due_jobs()` returned [] and the job was
re-anchored to the next day, i.e. job zones east of the profile zone silently never fired.
The regression test drives the public store API and asserts both the fire and the absence of
the repair, and is proven red on main ([] and a rewritten instant).
Knobs live in the new sibling `cron/jobs_time.py`; `cron/jobs.py` stays over the file-lines
ratchet and only gained the call-site plumbing.
A scheduled heartbeat muted interim messages by rewriting the turn's display
settings, and the agent build read that muted value to freeze the session's
delegation mode. Heartbeats run under the user's session key, so on a cold
agent cache a heartbeat built (and cached, and pinned) an inline agent for an
interim-on chat, and the user's later turns ran inline. The heartbeat rewrite
no longer touches interim: TurnRunner already drops interim messages for a
heartbeat turn, and the TurnContext keeps the chat's configured value, which
is what a fresh agent's delegation.gateway_mode reads.
A fresh agent restored its session's tools[] pin (schema bytes) but kept the
build-time inline flag, so the next rebuild from fresh definitions
(compaction boundary, /reload-mcp, Bot Chat refresh) re-derived the other
variant and flipped the chat mid-conversation. restore_agent_tool_prefix now
re-freezes the flag from the restored delegate_task, making the pin
authoritative.
Docs: inline turns past the notify interval still get the long-running
notice (display.long_running_notifications); the stability sentence now
names compaction, /reload-mcp and heartbeats, and the post-update exception;
a deferred delegate_task (tool_search.defer) stays background.
Tests: heartbeat-first turn with an agent cache (interim on stays
background, control, interim off stays inline), a composed cell with agent
cache + real SessionDB pin + heartbeat + restart, and pin restore followed by
a compaction or /reload-mcp refresh in both directions.
On a messaging chat with display.interim_assistant_messages off, a top-level
delegate_task still produced two messages: a "checks are running, I don't have
the findings yet" reply and, later, the real answer. Top-level model
delegations always run in the background (ea8a8b4af8), and the tool text tells
the model to "give a one-line status and END YOUR TURN" (c89f3b8800). That
status is the turn's final answer, not interim text, so no display setting
held it back.
New key delegation.gateway_mode: auto | inline | background (alias async).
auto (default) joins the children inside the turn on a messaging chat whose
resolved interim setting is off (global, display.platforms.<p> override or
platform default). The parent waits in the tool call, gets the results there
and sends one answer. API, local and webhook surfaces keep the background
path under auto. Chats with interim messages on are unchanged: same schema
bytes, same async dispatch.
How it works:
- The gateway resolves the mode from the turn's own profile-scoped config
when it builds a session's agent (gateway/session_execution.py), and the
agent's first tool build freezes it (like the one-shot pin).
- An inline session carries the joined delegate_task variant the one-shot
path already uses: "results return in this tool call", no live-control
parameters, no END YOUR TURN.
- Dispatch follows the delegate_task schema the session carries
(session_joins_delegation), so schema and behaviour cannot disagree. The
schema rides the session's tools[] pin: a config change applies from the
next session (/new), as delegation.backend does, and a cache eviction or
restart never flips a running chat.
- Inline children run on the existing synchronous path: attached to the
parent, so /stop and an interrupting follow-up stop them; the per-child
heartbeat keeps the parent's activity fresh for the inactivity watchdog;
the async completion registry is not used. Nested and one-shot delegation
are unchanged.
Refs #95522.
The metadata floor and the guard-on private check scanned every string in
every CDP call, so Input.insertText typing 'http://169.254.169.254/' (or a
LAN URL with the guard on) was refused although typing fetches nothing.
Input.* methods only insert text or dispatch key/mouse events; skip the
URL-literal scan for them.
The cloud-metadata check on raw CDP ran only with the private-address
guard off, and only on a `url` param. With the guard on, an unlisted
method such as Network.loadNetworkResource fetched a metadata host or a
loopback URL from a public page, because only the page URL was checked.
Every CDP call now screens each `url` param and every http(s) literal
in its string params (function bodies, injected scripts, HTML) against
the metadata floor whatever the guard says. With the guard on, unlisted
methods also refuse private literals in their own params.
browser_exec still follows a page's own redirect or fetch to a metadata
address: the floor reads the URLs the agent writes, not the browser's
later traffic. security.md and browser.md now say that instead of
"refused on every route", and point at network-level IMDS blocking.
With the private-URL guard off (local backend, or browser.allow_private_urls on
a cloud/CDP backend) the floor only checked Page.navigate/Target.createTarget, so
Runtime.evaluate("fetch('http://169.254.169.254/...')"), Network.loadNetworkResource
and Fetch.continueRequest reached the metadata endpoint that browser_exec refuses on
every path. The guard-off branch now runs every _METHOD_PARAM_GUARDS probe (and the
url param of any other method) with an is_always_blocked_url-only predicate.
browser_cdp skipped its whole URL guard on a local terminal backend or
with browser.allow_private_urls: true, so Page.navigate and
Target.createTarget could open 169.254.169.254 while browser_exec
refuses it unconditionally (#16234). The metadata check now runs on
those two methods regardless, which is what the security docs state.
process_registry.py and its test file are over the 2,000-line target and may
only shrink: the PTY/pipe Enter choice collapses to one expression and the two
submit_stdin tests move to tests/tools/test_process_registry_submit.py.
submit_stdin appended \n unconditionally, but raw-mode TUIs (claude,
vim, htop) bind Enter to \r — what a real keyboard sends — so submitted
input never registered as Enter in interactive TUI sessions. Send \r
for PTY sessions instead; canonical-mode children are unaffected since
the tty driver's ICRNL maps \r to \n. Same reason tmux send-keys Enter
transmits \r. Non-PTY (pipe) sessions keep \n.
Claude-Session: https://claude.ai/code/session_013LH6C3g6wjMjhSXRauyVCW
browser_vault reached pages only through the task's CDP supervisor. Camofox (now a plugin) has no
CDP endpoint, so every fill on a Camofox tab ended with "Could not determine the current page
origin": the username from browser_vault list worked, the password never filled.
ctx.register_browser_page_backend lets a plugin browser carry the vault's origin read, form
inspection and fill script to its own page. Core keeps the secret contract: the exact-origin
pre-check and in-page re-check, the Bot Desktop takeover check, an in-page try/catch around the
secret script, and fixed failure text on that path. Registration follows the login-backend
provenance rule (bundled, or catalog verified/official at its pin) and is refused under
plugins.isolation: host.
Consolidates the core half of #127179 and #135204 (the Camofox halves already shipped in the
official plugin); the in-page wrapper follows #114414.
Co-authored-by: Jonathan Bruce <jonathan.bruce369@gmail.com>
Co-authored-by: clsferguson <cferguson@live.ca>
Co-authored-by: Benjamin PERRY <benjaminperry6@yahoo.fr>
The multi-root merge rebuilt each root's skipped-path list by regex-parsing
the "Skipped N unreadable path(s)..." sentence and splitting on ", ", so a
skipped directory named "one, two" became two fragments and the merged
count was wrong (3 instead of 2). SearchResult now carries skipped_paths and
skipped_omitted beside the warning; the merge sums those and composes the
one sentence itself. Single-root warning text is unchanged.
A comma/space multi-path search merged per-root results but dropped each
root's skipped-unreadable-path warning (content mode) and overwrote the
traversal warning with its "searched N that exist" note (filename mode),
so a search that skipped mode-000 directories looked complete.
Child warnings are now merged (skipped-path sentences collapse into one
with the summed count; other notes deduplicated; the nothing-matched hint
dropped once any root produced results) and the multi-root note is
appended. The macOS protected-folder note on single-root searches is
appended the same way instead of replacing the existing warning.
_PERMISSION_DENIED_RE made the rg:/grep:/find: prefix optional, so the shell's
own 'bash: /usr/bin/rg: Permission denied' (exit 126 under pipefail) parsed as
an unreadable path and content search returned an empty result with a
'Skipped 1 unreadable path(s): bash: /usr/bin/rg' note. Require the tool
prefix, and report the shell's exec failures (126/127) as a search error.
Once permission errors filled the 64 KiB retention cap, later lines were
dropped unread, so a vanished path or read failure behind them left a
permission-only diagnostic and the search reported partial success.
The drain now keeps the first non-permission line past the cap.
- The native rg runner keeps draining stderr but retains at most 64 KiB
(first line always kept); dropped lines are tallied and still counted in
"Skipped N ... (+N more)". Unreadable-path dedupe uses a set (first-seen
order kept).
- find exit 1 with results now names the first non-permission diagnostic
("Some paths could not be read: ...") instead of reporting a permission
problem; the rg/grep content lane does the same when a non-permission
error sits beside permission skips.
- The unreadable-bound test checks the exact skip count only on a run whose
limit lets traversal finish; the bounded run asserts the budget and the
warning's presence.
Layered on the salvaged #114655 commits:
- The native rg lane merged stderr into the bounded stdout stream, so 60
permission-denied lines filled a limit=3 page and search_files returned
zero files for a tree that had five. Kept stderr now drains on its own
pipe (the shell lane never piped stderr into `| head` either) and is
prepended to the output for the diagnostics parser.
- The no-rg find lane keeps find's stderr (outside sort/head) so the
warning names the unreadable paths instead of a generic sentence, and a
permission-only exit 1 with no matches is an empty result plus warning;
any other exit-1 failure shows find's first diagnostic.
- rg exit 2 beside real output with a non-permission diagnostic keeps the
output too (rg printed every path it could), with a warning naming the
first error. Same for content search.
- Warning text no longer tells the model to "search the path directly"
(that cannot help with EACCES) or claims the whole scope is unreadable
when nothing matched in the readable part.
Found on Hermes Cloud staging: search_files(target="files") on a data dir
holding a root-owned mode-700 lost+found failed outright.
The find -prune -exec grep lane discarded stderr (2>/dev/null), so find's
"Permission denied" diagnostic never reached the parser and a readable match
beside an unreadable subtree came back warning-free. Keep stderr attached and
recognise find's quoted diagnostic shape in the permission classifier.
The count branch of _parse_search_output computed the partial-result warning but did not pass it to SearchResult. Add count-mode regression tests (partial warning kept, clean count stays warning-free).
rg --files exit 2 (EACCES on any walked path) was treated as an invocation
failure in the file-discovery lane: stderr was discarded (2>/dev/null) and
exit 2 was outside the accepted {0,1,124} set, so one unreadable directory
anywhere under the search root produced the bare error "File search failed
while running ripgrep." with no detail and no results.
- _search_files_rg merges stderr, separates diagnostics from paths by the
"rg: "/"grep: " prefix, and degrades a permission-only exit 2 to partial
results plus a "Skipped N unreadable path(s)" warning, in both orders.
The directory supplement (#54347) still runs on the degraded path.
- Content search keeps the same partial-success contract for rg AND grep:
the unreadable-path matcher accepts grep's "grep: <path>: Permission
denied" as well as ripgrep's "(os error N)" spellings, so the grep
fallback no longer hard-fails on a tree with an unreadable directory.
- Bad regex/glob and other IO errors still fail closed, now with the
diagnostic text; the modified-order failure no longer blames the ripgrep
version the capability gate already accepted.
- The bounded-find fallback treats find exit 1 with a payload as partial
results plus a warning (empty payload still fails closed).
The content digest hashed the provider's raw text, but the cache reads
the file in text mode (CRLF/CR -> LF) with utf-8-sig (BOM dropped), so
a CRLF page never matched and every call re-bought the vendor fetch.
Hash the normalized form on both sides.
The cache body and its final-URL annotation were separate writes, so two fetches of one key
interleaved as A-put, B-put, B-final, A-final left B's body validated against A's destination.
The index entry now records the body's sha256; the final-URL write is compare-and-set on it and
a hit is served only when the body on disk matches the entry it was recorded for.
The keyless Firecrawl path returned the requested URL and dropped metadata.url, so the shared
redirect gate never saw the destination. It now reports metadata.url (sourceURL = requested).