Skip to content

The agent that grows with you

fix(child-env): the bot desktop and gmail-triage scripts start from the scrubbed env

kshitijk4poor43800d55f234
diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.py
index 4af4ffe02b2..c7c91a5c44f 100644
--- a/plugins/platforms/telegram/adapter.py
+++ b/plugins/platforms/telegram/adapter.py
@@ -4945,8 +4945,11 @@ class TelegramAdapter(BasePlatformAdapter):
return
success = False
try:
+ # A user script under HERMES_HOME the agent can write: scrubbed like cron and quick-command scripts.
+ from tools.environments.local import build_subprocess_env
proc = await asyncio.create_subprocess_exec(
- str(script_path), arg, *extra_args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
+ str(script_path), arg, *extra_args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
+ env=build_subprocess_env(strip_launch_profile=True))
_stdout_bytes, stderr_bytes = await asyncio.wait_for(proc.communicate(), timeout=60)
if proc.returncode == 0:
label = success_label
diff --git a/tools/bot_desktop/runtime.py b/tools/bot_desktop/runtime.py
index 69121b8bfec..3e5a4a8f94f 100644
--- a/tools/bot_desktop/runtime.py
+++ b/tools/bot_desktop/runtime.py
@@ -720,8 +720,13 @@ def _spawn_and_wait(sd: Path, wait_seconds: float) -> DesktopStatus:
env_file = sd / "env"
env_file.unlink(missing_ok=True)
- child_env = {k: v for k, v in os.environ.items() if k not in {
- "DISPLAY", "XAUTHORITY", "WAYLAND_DISPLAY", "DBUS_SESSION_BUS_ADDRESS", "SESSION_MANAGER"}}
+ # The agent drives this desktop and its dock opens a terminal, so it starts from the
+ # scrubbed child env like any other agent child, keeping the user's HOME.
+ from tools.environments.local import served_profile_child_env
+ child_env = served_profile_child_env(inherit_credentials=False)
+ child_env["HOME"] = child_env["HERMES_REAL_HOME"]
+ for key in ("DISPLAY", "XAUTHORITY", "WAYLAND_DISPLAY", "DBUS_SESSION_BUS_ADDRESS", "SESSION_MANAGER"):
+ child_env.pop(key, None)
child_env.update({
"HERMES_BD_PROFILE": _profile_name(),
"HERMES_BD_DISPLAY_NUM": str(num),