Skip to content

salvage(#55954): Hermes Console REPL + perf follow-ups (NS-574) - #57781

Merged
kshitijk4poor merged 5 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/ns-574-console
Jul 3, 2026
Merged

salvage(#55954): Hermes Console REPL + perf follow-ups (NS-574)#57781
kshitijk4poor merged 5 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/ns-574-console

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

Salvages @shannonsands' Hermes Console REPL (NS-574, #55954) onto current main and lands two perf fixes for the non-blocking review notes.

The console gives hosted/managed users a curated, safe subset of hermes operations (MCP mgmt, config, etc.) via CLI + dashboard websocket + xterm UI — without raw shell access.

Changes

  • Contributor work (4 commits, authorship preserved via cherry-pick): console REPL engine, dashboard console websocket, dashboard console UI, and shared-ANSI-stripping fix (the one blocking review note — @shannonsands already addressed it by switching to tools.ansi_strip.strip_ansi).
  • Our follow-up (1 commit): the two remaining non-blocking review notes:
    • console_engine: memoize the 4 process-static _*_summaries builders with functools.lru_cache. The dashboard opens a fresh engine per /api/console connection, so every reconnect was re-importing + re-parsing the whole CLI surface. Callers only read the returned map.
    • web_server: run console commands on a dedicated bounded ThreadPoolExecutor(max_workers=4) instead of asyncio.to_thread. On the 60s command timeout, wait_for cancels the awaitable but the non-preemptible worker thread keeps running — the shared default pool would accumulate leaked threads. Bounding caps that. Executor is torn down at exit via atexit (cancel_futures=True, no wait).

Validation

Result
test_console_engine.py + test_web_server_console_ws.py + test_dashboard_auth_ws_auth.py 165 passed, 0 failed
ruff (console_engine, web_server) clean
E2E: 2nd engine construction 21 cache hits, 0 new imports/parses (per-connection cost eliminated)
E2E: console executor max_workers=4, singleton, atexit shutdown registered

Review notes addressed (from the original #55954 review)

  1. ANSI strip → use canonical strip_ansidone by @shannonsands.
  2. Thread leak on timeout → fixed (bounded executor).
  3. Per-connection CLI-surface re-import → fixed (lru_cache).
  4. Dispatcher factoring (~150 LOC) → deferred as a follow-up; it's a pure structural refactor of the dispatch core (low value / higher risk on an internal keystone file), not landed here.

Salvage of #55954. Contributor commits cherry-picked with authorship preserved; perf follow-up by @kshitijk4poor.

shannonsands and others added 5 commits July 3, 2026 19:52
Addresses two non-blocking review notes on the Hermes Console PR:

- console_engine: the four _*_summaries helpers import a subcommand module
  and build a throwaway argparse tree purely to extract help summaries. The
  dashboard opens a fresh HermesConsoleEngine per /api/console connection, so
  every reconnect re-imported + re-parsed the whole CLI surface. The surface
  is process-static, so memoize with functools.lru_cache — callers only read
  the returned map.

- web_server: console commands run in a worker thread via asyncio.to_thread.
  On a 60s timeout asyncio.wait_for cancels the awaitable, but Python threads
  aren't preemptible, so a stuck worker keeps running and would leak into the
  shared default thread pool. Route console execution through a small
  dedicated bounded ThreadPoolExecutor (max_workers=4) so a leaked worker is
  capped and concurrent console execution is bounded regardless of reconnects.

Follow-up on top of @shannonsands' NS-574 Hermes Console.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/dashboard Web dashboard / control panel UI (dashboard/, landing) labels Jul 3, 2026
@kshitijk4poor
kshitijk4poor merged commit a6b9597 into NousResearch:main Jul 3, 2026
36 checks passed
@kshitijk4poor
kshitijk4poor deleted the salvage/ns-574-console branch August 5, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/dashboard Web dashboard / control panel UI (dashboard/, landing) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants