Buzz adapter: honor reply_to_mode instead of always threading replies

The Buzz adapter appended --reply-to unconditionally, so every agent reply
threaded onto its parent event id with no way to turn it off.

reply_to_mode is already a generic PlatformConfig field, parsed for any
platform from gateway.platforms.<name>.reply_to_mode, and the Discord and
Telegram adapters both honor it. Buzz never read it, so setting it was a
silent no-op.

Read it in __init__ (BUZZ_REPLY_TO_MODE overrides config.yaml, matching how
require_mention and transport already work in this adapter) and skip the
--reply-to append when it is "off", at all three send paths: send(),
send_image(), and the out-of-process _standalone_send() used for
deliver=buzz cron delivery.

Default is unchanged ("first"), so existing installs keep threading.
This commit is contained in:
al9000-max
2026-08-13 22:22:35 +02:00
committed by Teknium
parent 09cbce43e0
commit 5d73a11a97
+16 -3
View File
@@ -540,6 +540,15 @@ class BuzzAdapter(BasePlatformAdapter):
_rm_cfg = _rm_raw
self.require_mention = str(_rm_cfg).strip().lower() not in ("false", "0", "no", "off")
# Reply anchoring: "first"/"all" thread the reply onto the parent event
# id, "off" posts every reply as a normal top-level channel message.
# Mirrors the Discord/Telegram adapters, which already honor this
# PlatformConfig field; without it Buzz threaded unconditionally.
# Env (BUZZ_REPLY_TO_MODE) overrides config.yaml.
_rtm = (os.getenv("BUZZ_REPLY_TO_MODE") or getattr(config, "reply_to_mode", "first")
or "first")
self._reply_to_mode: str = str(_rtm).strip().lower()
# Inbound transport: "auto" (WebSocket with poll fallback, default),
# "websocket" (require WS; fail connect when it can't authenticate),
# or "poll" (CLI polling only). Env (BUZZ_TRANSPORT) overrides
@@ -783,7 +792,7 @@ class BuzzAdapter(BasePlatformAdapter):
return SendResult(success=False, error="Empty message")
args = ["messages", "send", "--channel", str(chat_id), "--content", "-"]
reply_target = (metadata or {}).get("thread_id") or reply_to
if reply_target:
if reply_target and self._reply_to_mode != "off":
args += ["--reply-to", str(reply_target)]
code, out, err = await self._run_cli(args, input_text=content)
if code != 0:
@@ -930,7 +939,7 @@ class BuzzAdapter(BasePlatformAdapter):
"--content", "-",
]
reply_target = (metadata or {}).get("thread_id") or reply_to
if reply_target:
if reply_target and self._reply_to_mode != "off":
args += ["--reply-to", str(reply_target)]
code, out, err = await self._run_cli(args, input_text=caption or "")
if code != 0:
@@ -1734,7 +1743,11 @@ async def _standalone_send(
return {"error": "Buzz standalone send: no target channel (set BUZZ_HOME_CHANNEL)"}
args = ["messages", "send", "--channel", target, "--content", "-"]
if thread_id:
# Same reply_to_mode gate as the live adapter, so out-of-process cron
# delivery (deliver=buzz) doesn't thread when the operator asked for flat.
_rtm = (os.getenv("BUZZ_REPLY_TO_MODE")
or getattr(pconfig, "reply_to_mode", "first") or "first")
if thread_id and str(_rtm).strip().lower() != "off":
args += ["--reply-to", str(thread_id)]
for path in media_files or []:
args += ["--file", str(path)]