diff --git a/gateway/slash_commands_session.py b/gateway/slash_commands_session.py index 17dbcda6b4..e64d9dd118 100644 --- a/gateway/slash_commands_session.py +++ b/gateway/slash_commands_session.py @@ -1042,11 +1042,7 @@ class GatewaySessionCommandsMixin: # The child sends the parent's exact system prompt: a row without one makes the branch's # first turn rebuild (re-probing the workspace) and forfeits the warm cache the copied # transcript buys. - parent_prompt = None - try: - parent_prompt = ((await self._session_db.get_session(parent_session_id)) or {}).get("system_prompt") - except Exception: - logger.debug("branch: parent system prompt read failed for %s", parent_session_id, exc_info=True) + parent = await self._session_db.get_session(parent_session_id) try: await self._session_db.create_session( session_id=new_session_id, @@ -1056,7 +1052,7 @@ class GatewaySessionCommandsMixin: parent_session_id=parent_session_id, user_id=dest_source.user_id, session_key=dest_key, chat_id=dest_source.chat_id, chat_type=dest_source.chat_type, thread_id=dest_source.thread_id, origin_json=_branch_origin_json, - display_name=current_entry.display_name, system_prompt=parent_prompt or None) + display_name=current_entry.display_name, system_prompt=(parent or {}).get("system_prompt") or None) except Exception as e: logger.error("Failed to create branch session: %s", e) return t("gateway.branch.create_failed", error=e)