The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): publish message.complete for an active-session refusal
unsupportedpastelsa5d3c25664a5
diff --git a/hermes_cli/active_sessions.py b/hermes_cli/active_sessions.pyindex 7a279f97379..97b6f8a2289 100644--- a/hermes_cli/active_sessions.py+++ b/hermes_cli/active_sessions.py@@ -127,6 +127,11 @@ class ActiveSessionRefusal(str):obj.reason = reasonreturn obj+ def __getnewargs_ex__(self) -> tuple[tuple[str, str], dict[str, Any]]:+ # copy/pickle rebuild via __new__: without the reason, publishing a refused turn's+ # message.complete (deepcopy of the payload) raises and the viewer hangs.+ return (str(self), self.reason), {}+def format_refusal_stderr(message: str) -> str:"""Keep the refusal contract across the one-shot CLI subprocess boundary."""diff --git a/tests/gateway/test_active_session_refusal_completion.py b/tests/gateway/test_active_session_refusal_completion.pynew file mode 100644index 00000000000..9c84d60e897--- /dev/null+++ b/tests/gateway/test_active_session_refusal_completion.py@@ -0,0 +1,23 @@+"""A refused turn still ends with message.complete, so the viewer never hangs."""+from types import SimpleNamespace++from gateway.session_events import SessionEvents+from gateway.session_settlement_recovery import _publish_completion+from hermes_cli.active_sessions import MAX_CONCURRENT_SESSIONS, ActiveSessionRefusal+++def test_refused_turn_publishes_completion_with_its_reason():+ stream = SessionEvents()+ received = []+ stream.observers.add(received.append)+ live = SimpleNamespace(controls=SimpleNamespace(snapshot=lambda *a: None), event_stream=stream)+ refusal = ActiveSessionRefusal('Too many active sessions.', MAX_CONCURRENT_SESSIONS)++ _publish_completion(SimpleNamespace(runner=None), live, SimpleNamespace(session_id='s'),+ {'admission_id': 'a1', 'request_id': 'r1'}, {'outcome': 'failed'}, refusal, None)++ [frame] = received+ payload = frame['params']['payload']+ assert frame['params']['type'] == 'message.complete'+ assert payload['text'] == 'Too many active sessions.'+ assert payload['text'].reason == MAX_CONCURRENT_SESSIONS