fix(yuanbao): auto-sethome persists platforms.yuanbao.home_channel and updates the live config
For a multiplexed secondary the middleware wrote a top-level YUANBAO_HOME_CHANNEL key that load_gateway_config never reads and skipped the (correctly suppressed) process-env write, so cron and home-channel delivery had no target in-process and none after a reload either. Persist through the gateway's persist_home_channel (the profile-aware config path every /sethome uses) and set the live PlatformConfig.home_channel; the process env is still untouched under a secondary's scope. Refs #108440 (ehz0ah inline, gateway/platforms/yuanbao.py)
This commit is contained in:
@@ -764,16 +764,15 @@ class AutoSetHomeMiddleware(InboundMiddleware):
|
||||
@staticmethod
|
||||
def _persist_home(adapter, ctx: InboundContext) -> None:
|
||||
try:
|
||||
from hermes_constants import get_hermes_home
|
||||
from hermes_cli.config import atomic_config_write, read_user_config_raw
|
||||
config_path = get_hermes_home() / "config.yaml"
|
||||
# Raw read: merged defaults must not be persisted to the user's file.
|
||||
user_config: dict = read_user_config_raw(config_path)
|
||||
user_config["YUANBAO_HOME_CHANNEL"] = ctx.chat_id
|
||||
atomic_config_write(config_path, user_config)
|
||||
# The profile's config.yaml (scoped home above) is the durable record. Under a multiplexed
|
||||
# secondary's scope the process env is the DEFAULT profile's; writing there would make this
|
||||
# tenant's chat the default profile's cron/notification home.
|
||||
from gateway.config import HomeChannel, persist_home_channel
|
||||
home = HomeChannel(platform=Platform.YUANBAO, chat_id=str(ctx.chat_id), name=str(ctx.chat_name or "Home"))
|
||||
# ``platforms.yuanbao.home_channel`` in the owning profile's config.yaml is the durable record
|
||||
# ``load_gateway_config`` reads back; the live PlatformConfig is updated so cron/home-channel
|
||||
# delivery in THIS process has a target without a restart.
|
||||
persist_home_channel(home)
|
||||
adapter.config.home_channel = home
|
||||
# Under a multiplexed secondary's scope the process env is the DEFAULT profile's; writing there
|
||||
# would make this tenant's chat the default profile's cron/notification home.
|
||||
if not _profile_scoped():
|
||||
os.environ["YUANBAO_HOME_CHANNEL"] = str(ctx.chat_id)
|
||||
logger.info("[%s] Auto-sethome: designated %s (%s) as Yuanbao home channel", adapter.name, ctx.chat_id, ctx.chat_name)
|
||||
|
||||
Reference in New Issue
Block a user