The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(sessions): an explicit --source tui|desktop survives the one-shot label drop
teknium10010273f1e48
diff --git a/hermes_cli/main.py b/hermes_cli/main.pyindex 85038cabc33..e27e54df7f1 100644--- a/hermes_cli/main.py+++ b/hermes_cli/main.py@@ -1772,6 +1772,9 @@ def cmd_chat(args):# --source: tag session source for filtering (e.g. 'tool' for integrations)if getattr(args, "source", None):os.environ["HERMES_SESSION_SOURCE"] = args.source+ # Explicit flag, not a label inherited from a parent TUI/Desktop session — one-shot+ # runs must keep it (see run_agent._session_source_for_agent).+ os.environ["HERMES_SESSION_SOURCE_EXPLICIT"] = "1"_pin_kanban_board_env()_confirm_startup_expensive_model_override(args)diff --git a/run_agent.py b/run_agent.pyindex 034796ea5cd..dc954fe503b 100644--- a/run_agent.py+++ b/run_agent.py@@ -57,7 +57,8 @@ def _session_source_for_agent(platform: Optional[str]) -> str:except Exception:get_session_env = os.environ.getsource = str(get_session_env("HERMES_SESSION_SOURCE", "") or "").strip()- if source in _UI_TRANSPORT_SOURCES and get_session_env("HERMES_SINGLE_QUERY_SESSION", "") == "1":+ if (source in _UI_TRANSPORT_SOURCES and get_session_env("HERMES_SINGLE_QUERY_SESSION", "") == "1"+ and get_session_env("HERMES_SESSION_SOURCE_EXPLICIT", "") != "1"):source = ""return source or platform or "cli"diff --git a/tests/agent/test_session_source.py b/tests/agent/test_session_source.pyindex 5774e5a2175..d694b5d3eeb 100644--- a/tests/agent/test_session_source.py+++ b/tests/agent/test_session_source.py@@ -47,3 +47,14 @@ def test_oneshot_child_keeps_inherited_automation_source(monkeypatch, inherited)monkeypatch.setenv("HERMES_SINGLE_QUERY_SESSION", "1")assert _session_source_for_agent("cli") == inherited++[email protected]("explicit", ["tui", "desktop"])+def test_oneshot_keeps_explicit_source_flag(monkeypatch, explicit):+ """`hermes chat -q --source tui` is a documented flag, not an inherited transport label: main.py+ marks it HERMES_SESSION_SOURCE_EXPLICIT=1 and the one-shot drop must not override it."""+ monkeypatch.setenv("HERMES_SESSION_SOURCE", explicit)+ monkeypatch.setenv("HERMES_SESSION_SOURCE_EXPLICIT", "1")+ monkeypatch.setenv("HERMES_SINGLE_QUERY_SESSION", "1")++ assert _session_source_for_agent("cli") == explicit