fix: /stop command crash + UnboundLocalError in streaming media delivery

Two fixes:

1. CLI /stop command crashed with 'cannot import name get_registry' —
   the code imported a non-existent function. Fixed to use the actual
   process_registry singleton and list_sessions() method.
   (Reported in #2458 by haiyuzhong1980)

2. Streaming media delivery used undefined 'adapter' variable —
   our PR #2382 called _deliver_media_from_response(adapter=adapter)
   but 'adapter' wasn't guaranteed to be defined in that scope.
   Fixed to resolve via self.adapters.get(source.platform).
   (Reported in #2424 by 42-evey)
This commit is contained in:
Teknium 2026-03-22 04:35:27 -07:00
parent f84230527c
commit f69c47d9ae
No known key found for this signature in database
2 changed files with 8 additions and 7 deletions

7
cli.py
View file

@ -2328,10 +2328,9 @@ class HermesCLI:
Inspired by OpenAI Codex's separation of interrupt (stop current turn)
from /stop (clean up background processes). See openai/codex#14602.
"""
from tools.process_registry import get_registry
from tools.process_registry import process_registry
registry = get_registry()
processes = registry.list_processes()
processes = process_registry.list_sessions()
running = [p for p in processes if p.get("status") == "running"]
if not running:
@ -2339,7 +2338,7 @@ class HermesCLI:
return
print(f" Stopping {len(running)} background process(es)...")
killed = registry.kill_all()
killed = process_registry.kill_all()
print(f" ✅ Stopped {killed} process(es).")
def _handle_paste_command(self):

View file

@ -2317,9 +2317,11 @@ class GatewayRunner:
# delivered without this.
if agent_result.get("already_sent"):
if response:
await self._deliver_media_from_response(
response, event, adapter,
)
_media_adapter = self.adapters.get(source.platform)
if _media_adapter:
await self._deliver_media_from_response(
response, event, _media_adapter,
)
return None
return response