Skip to content

The agent that grows with you

fix(gateway): resolve HERMES_TOOL_PROGRESS_MODE through profile scope (#116898)

chelsealong38c55c7ed524
diff --git a/gateway/run_turn.py b/gateway/run_turn.py
index 4e7d9963744..b8b16459824 100644
--- a/gateway/run_turn.py
+++ b/gateway/run_turn.py
@@ -2901,6 +2901,7 @@ class GatewayTurnMixin:
_gateway_platform_value, _has_platform_display_override, _load_gateway_config,
_platform_config_key,
)
+ from agent.secret_scope import get_secret
from gateway.display_config import resolve_display_setting, resolve_tool_progress
from gateway.status_phrases import choose_status_phrase, resolve_status_phrase_catalog
user_config = _load_gateway_config()
@@ -2918,8 +2919,10 @@ class GatewayTurnMixin:
getattr(_agent_display, _setter)(_cast(_val))
# Resolve the mode and its provenance together: null inherits, tier off is not intent.
+ # A raw os.getenv here reads whichever profile's env loaded last under multiplexing
+ # (#116898); get_secret resolves through the active profile's scope instead.
progress_mode, _tool_progress_explicit = resolve_tool_progress(
- user_config, platform_key, os.getenv("HERMES_TOOL_PROGRESS_MODE"),
+ user_config, platform_key, get_secret("HERMES_TOOL_PROGRESS_MODE"),
)
# "accumulate" (edit one bubble) or "separate" (one msg per tool)
progress_grouping = resolve_display_setting(user_config, platform_key, "tool_progress_grouping") or "accumulate"
diff --git a/tests/gateway/test_run_progress_topics.py b/tests/gateway/test_run_progress_topics.py
index 9ab3ab7c21c..6fdae3ae227 100644
--- a/tests/gateway/test_run_progress_topics.py
+++ b/tests/gateway/test_run_progress_topics.py
@@ -492,6 +492,31 @@ def _make_runner(adapter):
return runner
+def test_tool_progress_mode_reads_profile_scope_not_process_environ(monkeypatch, tmp_path):
+ """HERMES_TOOL_PROGRESS_MODE must resolve through the active profile's secret scope, not
+ process-wide ``os.environ``. Under gateway multiplexing ``os.environ`` carries whichever
+ profile's ``.env`` loaded last, so a raw ``os.getenv`` here would leak that profile's setting
+ into every other profile's turns (#116898)."""
+ from agent import secret_scope
+
+ gateway_run = importlib.import_module("gateway.run")
+ monkeypatch.setattr(gateway_run, "_hermes_home", tmp_path)
+
+ # Simulates a leaked env var from whichever profile's process env loaded last.
+ monkeypatch.setenv("HERMES_TOOL_PROGRESS_MODE", "off")
+ # This profile's OWN scoped value, which must win over the leaked process env.
+ token = secret_scope.set_secret_scope({"HERMES_TOOL_PROGRESS_MODE": "all"})
+ try:
+ adapter = ProgressCaptureAdapter(platform=Platform.SLACK)
+ runner = _make_runner(adapter)
+ source = SessionSource(platform=Platform.SLACK, chat_id="D1", chat_type="dm", thread_id=None)
+ disp = runner._run_agent_display_settings(source)
+ finally:
+ secret_scope.reset_secret_scope(token)
+
+ assert disp.progress_mode == "all"
+
+
@pytest.mark.asyncio
async def test_run_agent_progress_uses_event_message_id_for_slack_dm(monkeypatch, tmp_path):
"""Slack DM progress should keep event ts fallback threading."""