diff --git a/cli.py b/cli.py index b80ac2097..8490cc7cb 100644 --- a/cli.py +++ b/cli.py @@ -8695,6 +8695,9 @@ class HermesCLI: if _should_auto_attach_clipboard_image_on_paste(pasted_text) and self._try_attach_clipboard_image(): event.app.invalidate() if pasted_text: + # Sanitize surrogate characters (e.g. from Word/Google Docs paste) before writing + from run_agent import _sanitize_surrogates + pasted_text = _sanitize_surrogates(pasted_text) line_count = pasted_text.count('\n') buf = event.current_buffer if line_count >= 5 and not buf.text.strip().startswith('/'):