Your sandbox runs the profile. Your host was still running its scripts.


You hand one profile to a sandbox. The plugin boots a full Hermes backend inside a container: separate filesystem, separate network, no surprises. Two days later you are reading host logs and notice that profile’s cron script ran on the host — using the config.yaml the sandbox had rewritten. Nothing broke out. You just made a second copy of the key to the same room.

This is the classic failure mode of self-hosted agents: the moment two backends share one home directory, isolation becomes a feeling rather than a property. A recent group of Hermes changes (PRs #156725, #156727 and #156726) closes that hole with a deliberately boring idea — tell the host that a profile is no longer its business, and make the host actually believe it.

The problem is not the sandbox, it is two owners

By default one host gateway serves every profile: messaging platforms, cron, Kanban dispatch, the Webapp, plus agents started from the CLI, the TUI and the desktop app.

Now suppose a plugin (OpenShell is the first) moves profile ops into a sandbox. The host does not stop:

  • the gateway keeps polling ops’ Telegram bot token;
  • cron keeps firing scripts named in ops’ config.yaml;
  • MCP stdio servers, shell hooks and type: exec entries under quick_commands keep forking processes on the host.

Meanwhile the sandboxed backend can write that same home. It can edit config.yaml, write .env, add a secrets.command. That gives you the full chain: sandbox writes config, host reads config, host executes. You isolated the runtime and left the “config is code” path outside the fence.

The PR description puts it plainly: while a plugin runs a profile’s backend elsewhere, all of that keeps running the same profile on the host, outside the sandbox, reading config and running cron scripts, MCP commands and hooks that the sandbox can write.

One JSON file is the whole switch

The fix is almost anticlimactic — a marker file:

<hermes root>/profiles_run_elsewhere/<profile>.json

with contents that only name the owner:

{ "plugin": "openshell", "since": "2026-11-23T08:12:04+00:00" }

Two design decisions carry the weight:

  1. Existence is the marker. The contents are only used to say who is running the profile in an error message. An unreadable marker still counts — the failure direction is closed, not open.
  2. The marker lives under the Hermes root, never inside a profile home. The sandboxed backend cannot delete it. If the isolated side could clear its own leash, the whole mechanism would be theatre.

Plugins drive it with three functions from hermes_cli.profiles_run_elsewhere:

from hermes_cli.profiles_run_elsewhere import (
    mark_profile_run_elsewhere, clear_profile_run_elsewhere, run_elsewhere,
)

mark_profile_run_elsewhere("ops", "openshell")   # before the backend starts elsewhere
entry = run_elsewhere("ops")                     # entry.plugin == "openshell"; None when unmarked
clear_profile_run_elsewhere("ops", "openshell")  # once that backend has stopped

mark and clear raise ValueError when the marker belongs to a different plugin, so two plugins cannot quietly fight over one profile.

What the host does while the profile is marked

Refusals, not silent skips — which matters when you are debugging at 11pm and need a reason.

Entry point Behaviour
Host gateway Stops serving the profile: platforms, cron, Kanban watchers and /p/<profile>/ routes; the desktop cron ticker skips it too
Agent construction Refused; an agent built before the profile was marked runs no further turn
hermes -p ops chat / acp / cron run / cron tick Exits with a message naming the plugin
hermes -p ops serve / dashboard Exit code 78
hermes -p ops gateway run Exit code 78; hermes gateway ensure reports profile_runs_elsewhere
Dashboard cron / session / file / Webapp requests 409
Kanban dispatch Cards assigned to it stay in ready with skipped_nonspawnable

One detail worth knowing: a running host gateway drops a newly marked named profile on its next rescan, within 30 seconds — no restart needed.

The default profile can be marked as well, but the host gateway runs as default, so stop the gateway before you mark it. Otherwise it will refuse to start on the next boot.

Why the host also stops reading .env

This is the part that looks like overkill until you trace the order of operations.

While a profile is marked, host processes load no env file and resolve no secret source from its home:

  • hermes -p ops status and hermes -p ops config show the profile’s keys as not set, with one line explaining why;
  • a key saved through the plugin’s host process is still written to the file — writes keep working, reads do not;
  • host commands start nothing the profile’s own files name: hermes -p ops hooks test runs no shell hook, and hermes -p ops mcp test (or mcp add) refuses before it starts or calls a server;
  • the once-per-installed-revision maintenance that every hermes start performs (config migration and friends) is skipped and stays owed until the marker is gone.

Why go that deep? Because Hermes loads .env when hermes_cli.main is imported — before any command has a chance to refuse. If you only guarded “run a turn”, then a secrets.command or a secrets.onepassword.binary_path entry that the sandbox wrote into its own config.yaml would still execute on the host on every hermes -p ops … start. Entry-point checks cannot stop startup-time side effects, so the refusal has to live where values are read.

The same reasoning covers the other programs your config can name: provider key_cmd, tts.providers.<name>.command, stt.providers.<name>.command, password-manager binary_path, and quick_commands entries of type: exec. Each kind has one runner, and each runner now asks whether the home is marked first.

The other half: pointing the desktop at the plugin’s backend

Refusing to run is only half the story; the user still needs to use the profile. PR #156727 adds two calls to the desktop plugin SDK:

host.setProfileBackend({ plugin, profile, purpose, prepare })  // or { url, token }
host.clearProfileBackend({ plugin, profile, beforeApply })
host.profileBackendFeatures                                    // feature detection

The guardrails are proportionate:

  • setProfileBackend raises a native dialog naming the plugin and the profile; the change happens only after the user agrees;
  • only loopback addresses are accepted, so a plugin cannot quietly route a profile to the public internet;
  • with prepare, the plugin starts its backend after the user says yes, not before;
  • it refuses a profile another plugin already runs, or one the user connected to a remote host — and re-checks after a dialog that stayed open too long;
  • the result is the existing per-profile mode: 'remote' entry in connection.json plus one field, launcher: { plugin }. Neither core nor the desktop knows the name OpenShell.

Companion PR #156726 fixes the approval card for that setup. The approval server request gains an optional kind: command (default, unchanged), access (may the agent read this folder, read-only or read-write) and network (may it reach this site). Previously a sandbox refusal had to reuse the dangerous-command card — a button labelled Run, a config.yaml allowlist promise, a terminal block — for something that is none of those. The card now names the path, the access mode or the host, and carries a reason on the answer.

Turning it back on: do not just delete the file

The one operational rule to remember.

To run the profile on the host again, the correct order is: turn it off in the plugin, let the plugin call clear_profile_run_elsewhere, and only then does the host allow it.

If the plugin is uninstalled or no longer loads, the refusal names the marker file’s full path, and deleting it restores the profile on the host. Do not delete it while the plugin still runs the profile — that is precisely the double-run state this mechanism exists to prevent.

A few boundaries worth knowing:

  • Only a missing folder means nothing is marked. If the folder exists but cannot be read, no profile runs on the host until it can be read. Intentional, fail-closed.
  • The marked profile’s own backend is exempt. The plugin keeps that folder away from the backend it runs, so a process denied access to it is treated as that backend and applies none of the refusals — it keeps running its own profile and loading its own env files.
  • A gateway or hermes serve backend started as the marked profile is not killed. It runs no further turn and no cron job, but stays up until you stop it, so stop it before marking.
  • The marker does not follow hermes profile rename or create --clone-from. Rename the home and the marker stays at the old path.

The point

The real question has always been: when two backends own the same profile, who is in charge?

Hermes now answers: whoever runs it, owns it — and the host stops running a spare copy out of habit. The price is a small piece of state and a set of refusal paths. What you buy is an isolation story that survives an audit: anything the sandbox can write, the host will no longer execute.

If a sandbox plugin hosts one of your profiles, look in ~/.hermes/profiles_run_elsewhere/ and see what is there. If a marker exists for a profile you never handed to a plugin, a plugin has claimed it — find out which one before deleting anything. For the wider design, read one gateway per host; if your goal is keeping plugins away from host credentials, start with the plugin isolation guide.