hermes - ✅(Solved) Fix voice.record_key: alt+* crashes startup — prompt_toolkit rejects a- prefix [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11387Fetched 2026-04-18 06:01:18
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Author
Participants
Timeline (top)
referenced ×4cross-referenced ×3commented ×1

Setting voice.record_key to any alt+<key> value in ~/.hermes/config.yaml crashes Hermes on startup before the prompt is reachable. --resume and -c fail for the same reason.

Error Message

try: from hermes_cli.config import load_config _raw_key = load_config().get("voice", {}).get("record_key", "ctrl+b") _voice_key = _raw_key.lower().replace("ctrl+", "c-").replace("shift+", "s-") if "alt+" in _voice_key or "a-" in _voice_key: raise ValueError(f"Alt modifier not supported for record_key ('{_raw_key}'); use ctrl+* or shift+*") except Exception as e: print(f"[hermes] Warning: invalid voice.record_key, falling back to ctrl+b: {e}", file=sys.stderr) _voice_key = "c-b"

Root Cause

cli.py around line 8854:

_raw_key = load_config().get("voice", {}).get("record_key", "ctrl+b")
_voice_key = _raw_key.lower().replace("ctrl+", "c-").replace("alt+", "a-")
...
@kb.add(_voice_key)

The translation assumes prompt_toolkit understands a- for Alt, but prompt_toolkit only recognizes:

  • c-<key> for Ctrl
  • s-<key> for Shift
  • escape followed by the key (as a two-key sequence) for Alt/Meta

So alt+space becomes a-space, which prompt_toolkit rejects at @kb.add() bind time, raising during startup initialization. The crash happens before interactive prompts, so subcommands like --resume <id> and -c also fail since they go through the same CLI init path.

Fix Action

Workaround

Change to any ctrl+* key. ctrl+t works cleanly (no conflict with existing Ctrl+B / Ctrl+R bindings).

PR fix notes

PR #11397: fix(voice): reject alt+ modifier in voice.record_key, fall back to ctrl+b

Description (problem / solution / changelog)

Summary

Fixes #11387. Setting voice.record_key to any alt+<key> value in ~/.hermes/config.yaml crashes Hermes on startup before the prompt is reachable. --resume and -c fail for the same reason.

Root cause: The key-translation code maps alt+a-, but prompt_toolkit only accepts c- (Ctrl) and s- (Shift) prefixes. @kb.add("a-space") throws during startup initialization.

Fix: Both keybinding setup (~L8855) and voice-mode display (~L7186) now check for alt+ and fall back to ctrl+b with a stderr warning. Also adds shift+s- translation (was missing) and maps s- back to Shift+ in the display string.

Changes

  • cli.py: Validate modifier before prompt_toolkit key translation; reject alt+ with fallback + warning (+13/-2, two call sites)
  • tests/hermes_cli/test_voice_record_key.py: 7 regression tests covering ctrl/shift/alt/case variations (+41)

Test plan

  • alt+space → falls back to c-b, prints warning to stderr
  • ctrl+bc-b (default, unchanged)
  • shift+f1s-f1 (new: was silently broken before)
  • CTRL+Bc-b (case-insensitive)
  • Display string correctly shows SHIFT+F1 for shift keys

Changed files

  • cli.py (modified, +13/-3)
  • tests/hermes_cli/test_voice_record_key.py (added, +41/-0)

PR #11440: fix(cli): support alt push-to-talk record keys

Description (problem / solution / changelog)

Summary

  • Normalize voice.record_key into prompt_toolkit-friendly key sequences.
  • Translate alt+* / meta+* into escape sequences instead of crashing startup.
  • Fall back to ctrl+b with a warning if the configured key is invalid.

Testing

  • python -m pytest tests/tools/test_voice_cli_integration.py -q
  • Verified @kb.add(*("escape", "space")) works with prompt_toolkit.

Closes #11387

Changed files

  • cli.py (modified, +95/-8)
  • tests/tools/test_voice_cli_integration.py (modified, +30/-0)

PR #11859: fix(voice): alt+ record_key crashes on startup with ValueError

Description (problem / solution / changelog)

Problem

Setting voice.record_key: alt+b (or any alt+* key) in config.yaml crashes Hermes on startup with:

ValueError: Invalid key: a-b

The conversion _raw_key.replace("alt+", "a-") produces "a-b", but prompt_toolkit does not recognise the a- prefix as a valid key name.

Closes #11387

Root Cause

prompt_toolkit represents Alt+key as a two-key escape sequence — kb.add("escape", "b") for Alt+B — not as a single "a-b" string. The a- prefix is not a valid prompt_toolkit key.

Fix

Parse alt+ keys into a ("escape", letter) tuple and splat into kb.add(*parts). Ctrl+ keys keep their existing "c-x" string form unchanged. Also fix the display label so it shows Alt+B instead of A-B.

Verification

# Before: ValueError on startup
kb.add("a-b")  # → ValueError: Invalid key: a-b

# After: correct two-step escape sequence
kb.add("escape", "b")  # ✅

Tested all key formats against docker.io/nousresearch/hermes-agent:latest (v0.8.0):

Config valueBeforeAfter
ctrl+b
alt+b❌ crash
alt+r❌ crash
ctrl+r

🤖 Generated with Claude Code

Changed files

  • cli.py (modified, +8/-4)

Code Example

voice:
     record_key: alt+space

---

_raw_key = load_config().get("voice", {}).get("record_key", "ctrl+b")
_voice_key = _raw_key.lower().replace("ctrl+", "c-").replace("alt+", "a-")
...
@kb.add(_voice_key)

---

try:
    from hermes_cli.config import load_config
    _raw_key = load_config().get("voice", {}).get("record_key", "ctrl+b")
    _voice_key = _raw_key.lower().replace("ctrl+", "c-").replace("shift+", "s-")
    if "alt+" in _voice_key or "a-" in _voice_key:
        raise ValueError(f"Alt modifier not supported for record_key ('{_raw_key}'); use ctrl+* or shift+*")
except Exception as e:
    print(f"[hermes] Warning: invalid voice.record_key, falling back to ctrl+b: {e}", file=sys.stderr)
    _voice_key = "c-b"
RAW_BUFFERClick to expand / collapse

Summary

Setting voice.record_key to any alt+<key> value in ~/.hermes/config.yaml crashes Hermes on startup before the prompt is reachable. --resume and -c fail for the same reason.

Reproduction

  1. Edit ~/.hermes/config.yaml:
    voice:
      record_key: alt+space
  2. Launch hermes.
  3. Startup aborts with a prompt_toolkit error like Invalid key: a-space.

Root cause

cli.py around line 8854:

_raw_key = load_config().get("voice", {}).get("record_key", "ctrl+b")
_voice_key = _raw_key.lower().replace("ctrl+", "c-").replace("alt+", "a-")
...
@kb.add(_voice_key)

The translation assumes prompt_toolkit understands a- for Alt, but prompt_toolkit only recognizes:

  • c-<key> for Ctrl
  • s-<key> for Shift
  • escape followed by the key (as a two-key sequence) for Alt/Meta

So alt+space becomes a-space, which prompt_toolkit rejects at @kb.add() bind time, raising during startup initialization. The crash happens before interactive prompts, so subcommands like --resume <id> and -c also fail since they go through the same CLI init path.

Expected behaviour

One of:

  1. Validate at config load — in hermes_cli/config.py, reject alt+* with a clear error message pointing the user at supported modifiers (ctrl+*, shift+*) or instructing them how to use escape sequences for Alt if that's intentionally supported.
  2. Translate correctly — map alt+space to the prompt_toolkit two-key sequence ("escape", "space") and pass that to @kb.add.
  3. Fall back to ctrl+b on invalid key — instead of bubbling the exception, log a warning and use the default, so a bad record_key never blocks startup.

Option 3 alone is the minimum to prevent startup lockout. Option 1 or 2 is the real fix.

Environment

  • Hermes pulled from NousResearch/hermes-agent main
  • OS: Debian questing (Python 3.13.7)
  • prompt_toolkit: from hermes-agent venv

Workaround

Change to any ctrl+* key. ctrl+t works cleanly (no conflict with existing Ctrl+B / Ctrl+R bindings).

Suggested fix (minimal)

try:
    from hermes_cli.config import load_config
    _raw_key = load_config().get("voice", {}).get("record_key", "ctrl+b")
    _voice_key = _raw_key.lower().replace("ctrl+", "c-").replace("shift+", "s-")
    if "alt+" in _voice_key or "a-" in _voice_key:
        raise ValueError(f"Alt modifier not supported for record_key ('{_raw_key}'); use ctrl+* or shift+*")
except Exception as e:
    print(f"[hermes] Warning: invalid voice.record_key, falling back to ctrl+b: {e}", file=sys.stderr)
    _voice_key = "c-b"

extent analysis

TL;DR

To fix the issue, modify the cli.py file to correctly handle alt+ keys or validate the record_key configuration to prevent startup crashes.

Guidance

  • Identify the problematic line in cli.py where the _voice_key is defined and modify it to either validate the record_key configuration or correctly translate alt+ keys.
  • Consider implementing a fallback to the default ctrl+b key when an invalid record_key is encountered to prevent startup lockout.
  • Review the suggested fix provided in the issue body, which includes a try-except block to handle invalid record_key values and fall back to the default key.
  • Test the modified code with different record_key configurations to ensure it works as expected.

Example

The suggested fix provided in the issue body includes a code snippet that demonstrates how to validate the record_key configuration and fall back to the default key:

try:
    ...
    if "alt+" in _voice_key or "a-" in _voice_key:
        raise ValueError(f"Alt modifier not supported for record_key ('{_raw_key}'); use ctrl+* or shift+*")
except Exception as e:
    print(f"[hermes] Warning: invalid voice.record_key, falling back to ctrl+b: {e}", file=sys.stderr)
    _voice_key = "c-b"

This code snippet can be used as a starting point to implement the fix.

Notes

The provided fix assumes that the alt+ modifier is not supported by prompt_toolkit. If this modifier is intended to be supported, the code will need to be modified to correctly translate alt+ keys to the prompt_toolkit two-key sequence.

Recommendation

Apply the suggested fix to validate the record_key configuration and fall back to the default key when an invalid value is encountered. This will prevent startup crashes and provide a clear error message to the user when an invalid record_key is used.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING