Skip to content

perf(cli): dispatch serve without the full parser tree - #96749

Closed
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:feat/serve-lean-dispatch
Closed

helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:feat/serve-lean-dispatch

Conversation

@helix4u

@helix4u helix4u commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Desktop starts a new hermes serve process for its backend, but that exact built-in command currently constructs the complete Hermes argparse tree before it can dispatch. On Windows, the unrelated command and plugin parser setup adds filesystem and translation work to every cold Desktop launch.

This adds a narrow serve fast path built from the same parser configuration function as the normal command tree. Unrecognized arguments, global options, help, container routing, and an explicit opt-out all fall back to the existing parser, so the optimization does not create a second command contract.

Desktop performance series

image

This change is one independently reviewable layer of the same Desktop startup and first-interaction performance pass.

The three Python backend PRs share startup files but solve separate stages. Recommended landing order is #96749, then #96750, then #96751, rebasing the next PR only after the preceding one lands. #97032 is an independently reviewable Electron ordering change. The remaining renderer and Bot Mode PRs can also land independently; their effects compose without making cached state authoritative.
This PR owns the earliest Python entry layer: an unambiguous Desktop serve launch avoids building the unrelated CLI parser tree.

Related Issue

N/A

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Extract the canonical serve parser configuration in hermes_cli/subcommands/dashboard.py so both launch paths share every option and default.
  • Dispatch an unambiguous built-in serve before constructing the full parser tree in hermes_cli/main.py.
  • Preserve normal handling for help, global or unknown arguments, container routing, and HERMES_DISABLE_FAST_SERVE_LAUNCH=1.
  • Add behavioral coverage for fast dispatch and every fallback boundary.

How to Test

  1. Run scripts/run_tests.sh tests/hermes_cli/test_fast_serve_launch.py -q -j 4.
  2. Confirm all 5 focused tests pass.
  3. Launch hermes serve --port 0 --no-open and confirm it reaches the normal backend command implementation; launch hermes serve --help and confirm it uses the complete parser help path.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Windows 11

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Focused result: 5 tests passed.

@helix4u

helix4u commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator Author
image

@teknium1

teknium1 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks — landed on main via #101265 (your commit cherry-picked, authorship preserved; tests trimmed). Measured: dispatch 77ms → 2ms, real hermes serve READY 1.176s → 1.090s (n=9). Closing the original in favor of the merged salvage.

@teknium1 teknium1 closed this Sep 2, 2026
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 P3 Low — cosmetic, nice to have type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants