From 874843146b0de39289252be03161b4f4ed5513b1 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 21:22:33 -0700 Subject: [PATCH] refactor(agent/relay_runtime): conversation initializer context built once --- agent/relay_runtime.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/agent/relay_runtime.py b/agent/relay_runtime.py index dcff78b1a7..2f28d8c21b 100644 --- a/agent/relay_runtime.py +++ b/agent/relay_runtime.py @@ -934,24 +934,20 @@ class RelaySessionCoordinator: ) session = None if isinstance(host, RelayRuntime): - session = _warn_on_error( - "conversation initialization", self._open_conversation_session, host, profile_key=profile_key, - session_id=session_id, platform=platform, parent_session_id=parent_session_id, model=model, - ) + context = { + "profile_key": profile_key, "session_id": session_id, "platform": platform, + "parent_session_id": parent_session_id, "model": model, + } + session = _warn_on_error("conversation initialization", self._open_conversation_session, host, context) return ConversationLease( profile_key=profile_key, session_id=session_id, platform=platform, host=host, session=session, parent_session_id=parent_session_id, ) - def _open_conversation_session( - self, host: RelayRuntime, *, profile_key: str, session_id: str, platform: str, - parent_session_id: str, model: str, - ) -> RelaySession | None: - self._prepare_session(host, { - "profile_key": profile_key, "session_id": session_id, "platform": platform, - "parent_session_id": parent_session_id, "model": model, - }) - metadata = {"hermes.execution_surface": platform or "unknown"} + def _open_conversation_session(self, host: RelayRuntime, context: dict[str, Any]) -> RelaySession | None: + self._prepare_session(host, context) + session_id, parent_session_id = context["session_id"], context["parent_session_id"] + metadata = {"hermes.execution_surface": context["platform"] or "unknown"} if parent_session_id and parent_session_id != session_id: return host.register_subagent( {"parent_session_id": parent_session_id, "child_session_id": session_id}, metadata=metadata,