Skip to content

The agent that grows with you

refactor(cli): one copy of the gateway-disconnected text

Teknium2a5aa2a40624
diff --git a/hermes_cli/gateway_client.py b/hermes_cli/gateway_client.py
index 6b462673392..1eaf0d48a05 100644
--- a/hermes_cli/gateway_client.py
+++ b/hermes_cli/gateway_client.py
@@ -49,8 +49,8 @@ class GatewayClientError(ValueError):
pass
-_DISCONNECTED = ("Gateway disconnected; turn outcome is unknown. "
- "Resume the printed session ID to check whether it completed or was interrupted; do not resend the work.")
+DISCONNECTED = ("Gateway disconnected; turn outcome is unknown. "
+ "Resume the printed session ID to check whether it completed or was interrupted; do not resend the work.")
class GatewayRPCError(GatewayClientError):
@@ -200,7 +200,7 @@ class GatewayClient:
except (ConnectionClosed, OSError, ValueError, TimeoutError):
pass
finally:
- error = GatewayClientError(_DISCONNECTED)
+ error = GatewayClientError(DISCONNECTED)
for future in self.pending.values():
if not future.done():
future.set_exception(error)
@@ -225,7 +225,7 @@ class GatewayClient:
await self.websocket.send(json.dumps({"jsonrpc": "2.0", "id": rid, "method": method, "params": params}))
except (ConnectionClosed, OSError) as exc:
# The frame may have left before the socket died: the same unknown outcome as a lost answer.
- raise GatewayClientError(_DISCONNECTED) from exc
+ raise GatewayClientError(DISCONNECTED) from exc
budget = DEFAULT_RPC_TIMEOUT if _timeout is None else _timeout
return await asyncio.wait_for(future, None if budget == float("inf") else budget)
finally:
diff --git a/hermes_cli/gateway_connection.py b/hermes_cli/gateway_connection.py
index f012b34b763..525ef5ac6fb 100644
--- a/hermes_cli/gateway_connection.py
+++ b/hermes_cli/gateway_connection.py
@@ -16,13 +16,12 @@ import queue
import threading
import time
-from hermes_cli.gateway_client import DEFAULT_RPC_TIMEOUT, RESUME_KEY_MISMATCH, GatewayClientError, GatewayRPCError
+from hermes_cli.gateway_client import (DEFAULT_RPC_TIMEOUT, DISCONNECTED, RESUME_KEY_MISMATCH, GatewayClientError,
+ GatewayRPCError)
logger = logging.getLogger(__name__)
-DISCONNECTED = ("Gateway disconnected; turn outcome is unknown. Resume the printed session ID to check "
- "whether it completed or was interrupted; do not resend the work.")
-# A request refused before it reached any socket: nothing is in doubt, so never the copy above.
+# A request refused before it reached any socket: nothing is in doubt, so never DISCONNECTED.
NOT_SENT = "Gateway disconnected before the request was sent; nothing was sent."
# ``session.resume`` refusals that mean "this viewer may not open that session": the caller keeps the
# session it is on instead of adopting the target (startup resume, bare -c fallback).