from __future__ import annotations def build_thread_id(agent_id: str, space_name: str, user_email: str = "") -> str: if space_name.startswith("spaces/"): space_id = space_name.removeprefix("spaces/") return f"agent:{agent_id}:googlechat:space:{space_id}" return f"agent:main:googlechat:dm:{user_email}"