The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): holder classifier derives value-flags from the real parser; de-flake goal-resume fixture
Teknium7d6db4efb885
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex 4ad10d8d58e..1144400025f 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -3935,6 +3935,49 @@ def _defer_update_for_self_lock(loaded: list[str]) -> None:_m()._write_update_incomplete_marker()+_HOLDER_VALUE_FLAGS_FALLBACK = frozenset(+ {+ "--profile", "-p", "--config",+ "--model", "-m", "--provider", "--reasoning",+ "--toolsets", "-t", "--skills", "-s",+ "--continue", "-c", "--resume", "-r",+ "--oneshot", "-z", "--in", "--usage-file",+ }+)+_holder_value_flags_cache: frozenset | None = None+++def _holder_value_flags() -> frozenset:+ """Top-level CLI flags that consume a value — derived from the REAL parser.++ Introspects ``build_top_level_parser()`` (every option with nargs != 0)+ so the holder classifier can never drift from the argparse surface+ (#91869 review: a handwritten subset misparsed ``--reasoning high+ serve`` as subcommand ``high`` and ``-m dashboard serve`` as+ ``dashboard`` — recreating the wrong-hint class). The pre-argparse+ profile selectors (``--profile``/``-p``, ``--config``) are added+ explicitly since they are stripped before argparse sees argv. Falls+ back to a static snapshot when the parser cannot be imported (the+ updater must classify holders even mid-upgrade on a broken tree).+ Cached per process.+ """+ global _holder_value_flags_cache+ if _holder_value_flags_cache is not None:+ return _holder_value_flags_cache+ flags: set[str] = {"--profile", "-p", "--config"}+ try:+ from hermes_cli._parser import build_top_level_parser++ parser = build_top_level_parser()[0]+ for action in parser._actions:+ if action.option_strings and action.nargs != 0:+ flags.update(action.option_strings)+ _holder_value_flags_cache = frozenset(flags)+ except Exception:+ _holder_value_flags_cache = _HOLDER_VALUE_FLAGS_FALLBACK+ return _holder_value_flags_cache++def _hermes_holder_subcommand(cmdline: str) -> str | None:"""The actual Hermes SUBCOMMAND a venv-holder argv runs, or None.@@ -3966,12 +4009,13 @@ def _hermes_holder_subcommand(cmdline: str) -> str | None:if entry_idx is None:return None- value_flags = {"--profile", "-p", "--config", "--model", "--provider"}+ value_flags = _holder_value_flags()i = entry_idx + 1while i < len(tokens):token = tokens[i]- if token in value_flags:- i += 2+ if token in value_flags or token.split("=", 1)[0] in value_flags:+ # --flag value consumes two tokens; --flag=value consumes one.+ i += 1 if "=" in token else 2continueif token.startswith("-"):i += 1diff --git a/tests/gateway/test_goal_resume_restart.py b/tests/gateway/test_goal_resume_restart.pyindex bc7efa77452..7b9be97ad30 100644--- a/tests/gateway/test_goal_resume_restart.py+++ b/tests/gateway/test_goal_resume_restart.py@@ -34,8 +34,23 @@ def hermes_home(tmp_path, monkeypatch):home.mkdir()monkeypatch.setattr(Path, "home", lambda: tmp_path)monkeypatch.setenv("HERMES_HOME", str(home))+ # get_hermes_home() prefers the context-local override over the env+ # var, so a set_hermes_home_override() leaked by ANY earlier test in+ # this xdist worker would silently point the goals DB at a dead tmp+ # dir and make resume enqueue nothing (CI-only flake). Pin the+ # override to THIS home so the fixture is immune to leaks.+ from hermes_constants import (+ reset_hermes_home_override,+ set_hermes_home_override,+ )++ token = set_hermes_home_override(str(home))goals._DB_CACHE.clear()yield home+ try:+ reset_hermes_home_override(token)+ except Exception:+ passgoals._DB_CACHE.clear()diff --git a/tests/hermes_cli/test_venv_holder_classifier.py b/tests/hermes_cli/test_venv_holder_classifier.pyindex 2b17573d529..ebba2f4d8c1 100644--- a/tests/hermes_cli/test_venv_holder_classifier.py+++ b/tests/hermes_cli/test_venv_holder_classifier.py@@ -20,6 +20,15 @@ class TestHolderSubcommand:(r"python -m hermes_cli.main -p work serve", "serve"),# 90778: flags containing subcommand words are not subcommands(r"python -m hermes_cli.main kanban --preserve-cache", "kanban"),+ # 91869 review: EVERY top-level value flag must be skipped —+ # a flag VALUE equal to a subcommand must not become the label+ (r"python -m hermes_cli.main --reasoning high serve", "serve"),+ (r"python -m hermes_cli.main -m dashboard serve", "serve"),+ (r"python -m hermes_cli.main -t browser,files gateway run", "gateway"),+ (r"python -m hermes_cli.main --model=dashboard serve", "serve"),+ # -c consumes ONE value token; later bare tokens are (harmless,+ # unhinted) subcommand candidates — pin that shape honestly+ (r"python -m hermes_cli.main -c mysession serve", "serve"),(r"C:\bin\hermes.exe dashboard", "dashboard"),(r"/usr/local/bin/hermes serve", "serve"),# no hermes entry at all