mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
fix(model-switch): normalize Unicode dashes from Telegram/iOS input
Telegram on iOS auto-converts double hyphens (--) to em dashes (—) or en dashes (–) via autocorrect. This breaks /model flag parsing since parse_model_flags() only recognizes literal '--provider' and '--global'. When the flag isn't parsed, the entire string (e.g. 'glm-5.1 —provider zai') gets treated as the model name and fails with 'Model names cannot contain spaces.' Fix: normalize Unicode dashes (U+2012-U+2015) to '--' when they appear before flag keywords (provider, global), before flag extraction. The existing test suite in test_model_switch_provider_routing.py already covers all four dash variants — this commit adds the code that makes them pass.
This commit is contained in:
parent
c6398fcaab
commit
92a23479c0
3 changed files with 64 additions and 0 deletions
|
|
@ -274,6 +274,11 @@ def parse_model_flags(raw_args: str) -> tuple[str, str, bool]:
|
|||
is_global = False
|
||||
explicit_provider = ""
|
||||
|
||||
# Normalize Unicode dashes (Telegram/iOS auto-converts -- to em/en dash)
|
||||
# A single Unicode dash before a flag keyword becomes "--"
|
||||
import re as _re
|
||||
raw_args = _re.sub(r'[\u2012\u2013\u2014\u2015](provider|global)', r'--\1', raw_args)
|
||||
|
||||
# Extract --global
|
||||
if "--global" in raw_args:
|
||||
is_global = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue