diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 318e55d3efe..a178daf581e 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -1146,7 +1146,7 @@ def _make_tui_argv(tui_dir: Path, tui_dev: bool) -> tuple[list[str], Path]: p = Path(ext_dir) if (p / "dist" / "entry.js").is_file(): node = _node_bin("node") - return [node, str(p / "dist" / "entry.js")], p + return [node, "--expose-gc", str(p / "dist" / "entry.js")], p # 1b. Bundled in wheel (pip install) bundled = _find_bundled_tui() @@ -1229,7 +1229,7 @@ def _make_tui_argv(tui_dir: Path, tui_dev: bool) -> tuple[list[str], Path]: sys.exit(1) node = _node_bin("node") - return [node, str(tui_dir / "dist" / "entry.js")], tui_dir + return [node, "--expose-gc", str(tui_dir / "dist" / "entry.js")], tui_dir def _normalize_tui_toolsets(toolsets: object) -> list[str]: @@ -1351,16 +1351,16 @@ def _launch_tui( env["HERMES_TUI_TOOL_PROGRESS"] = "off" if accept_hooks: env["HERMES_ACCEPT_HOOKS"] = "1" - # Guarantee an 8GB V8 heap + exposed GC for the TUI. Default node cap is - # ~1.5–4GB depending on version and can fatal-OOM on long sessions with - # large transcripts / reasoning blobs. Token-level merge: respect any - # user-supplied --max-old-space-size (they may have set it higher) and - # avoid duplicating --expose-gc. + # Guarantee an 8GB V8 heap for the TUI. Default node cap is ~1.5–4GB + # depending on version and can fatal-OOM on long sessions with large + # transcripts / reasoning blobs. Token-level merge: respect any + # user-supplied --max-old-space-size (they may have set it higher). + # --expose-gc is *not* added here: Node rejects it in NODE_OPTIONS + # ("--expose-gc is not allowed in NODE_OPTIONS") and refuses to start. + # It is passed as a direct argv flag in _make_tui_argv() instead. _tokens = env.get("NODE_OPTIONS", "").split() if not any(t.startswith("--max-old-space-size=") for t in _tokens): _tokens.append("--max-old-space-size=8192") - if "--expose-gc" not in _tokens: - _tokens.append("--expose-gc") env["NODE_OPTIONS"] = " ".join(_tokens) # HERMES_TUI_RESUME is an internal hand-off from the Python wrapper to the # Ink app. Because we start from os.environ.copy(), an exported/stale value