The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(buzz): compose thread-topology cluster — reply_in_thread opt-out, NIP-10 root anchoring on all send paths, _PLATFORM_DEFAULTS tier
Teknium972f0314de4d
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..08d2a46581a--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+nanakoicediff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..15de43e3837--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+tieubaodiff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..d8499ffdfbc--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+tomwattscadiff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..f5120dd1720--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+yuvalfisdiff --git a/gateway/display_config.py b/gateway/display_config.pyindex 656a30d69ce..fe07268b7f5 100644--- a/gateway/display_config.py+++ b/gateway/display_config.py@@ -149,6 +149,12 @@ _PLATFORM_DEFAULTS: dict[str, dict[str, Any]] = {"mattermost": _TIER_MEDIUM,"matrix": _TIER_MEDIUM,"feishu": _TIER_MEDIUM,+ # Buzz (Nostr relay via buzz-cli): messages can be edited in place+ # (`buzz messages edit`), so grouped/accumulating progress works, but+ # channels are shared community spaces — keep the medium tier. Without+ # this entry Buzz inherited the verbose _GLOBAL_DEFAULTS and every+ # interim update became a separate permanent channel post (#95841).+ "buzz": _TIER_MEDIUM,# Tier 3 — no edit support, progress messages are permanent"signal": _TIER_LOW,diff --git a/gateway/run.py b/gateway/run.pyindex a11315e8252..3ce89c3b739 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -30016,6 +30016,19 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew)except Exception:_progress_reply_in_thread = True+ elif str(getattr(source.platform, "value", source.platform) or "").lower() == "buzz":+ # Buzz honours the same opt-out (reply_to_mode: off /+ # extra.reply_in_thread: false). When the user asked for flat+ # channel replies, progress must not synthesise a thread either.+ _buzz_adapter_for_progress = self._adapter_for_source(source)+ if _buzz_adapter_for_progress is not None:+ try:+ _progress_reply_in_thread = (+ getattr(_buzz_adapter_for_progress, "_reply_to_mode", "first")+ != "off"+ )+ except Exception:+ _progress_reply_in_thread = True_progress_thread_id = _resolve_progress_thread_id(source.platform, source.thread_id, event_message_id,reply_in_thread=_progress_reply_in_thread,@@ -30071,9 +30084,11 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew)or (# Buzz has no native thread_id; threading is always via reply-to- # the triggering event id (channel clutter otherwise).+ # the triggering event id (channel clutter otherwise). Skipped+ # when the user opted out of threaded replies.str(getattr(source.platform, "value", source.platform) or "").lower() == "buzz"and event_message_id+ and _progress_reply_in_thread)or _relay_prospective_thread_idelse Nonediff --git a/plugins/platforms/buzz/adapter.py b/plugins/platforms/buzz/adapter.pyindex a60e182c67f..3cfcdcb5106 100644--- a/plugins/platforms/buzz/adapter.py+++ b/plugins/platforms/buzz/adapter.py@@ -25,11 +25,12 @@ Configuration in config.yaml::cli_path: "" # path to the buzz binary (default: PATH, then ~/bin/buzz)credentials_file: "" # JSON file holding the nsec (fallback for BUZZ_PRIVATE_KEY)allowed_users: [] # empty = allow all; entries are hex pubkeys or npubs+ reply_in_thread: true # false = post replies flat to the channel timelineOr via environment variables (overrides config.yaml):BUZZ_RELAY_URL, BUZZ_CHANNELS, BUZZ_HOME_CHANNEL, BUZZ_POLL_INTERVAL,BUZZ_CLI_PATH, BUZZ_CREDENTIALS_FILE, BUZZ_ALLOWED_USERS,- BUZZ_ALLOW_ALL_USERS+ BUZZ_ALLOW_ALL_USERS, BUZZ_REPLY_IN_THREAD, BUZZ_REPLY_TO_MODEThe only secret is BUZZ_PRIVATE_KEY (nsec or hex) — it belongs in``~/.hermes/.env``. It is passed to the CLI via the subprocess@@ -548,6 +549,14 @@ class BuzzAdapter(BasePlatformAdapter):_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()+ # Slack-convention alias: platforms.buzz.extra.reply_in_thread: false+ # (the key users already know from Slack) opts out of threading the+ # same way reply_to_mode: off does. Env (BUZZ_REPLY_IN_THREAD)+ # overrides config.yaml. See #95842 / #75082.+ _rit_raw = os.getenv("BUZZ_REPLY_IN_THREAD")+ _rit = extra.get("reply_in_thread") if _rit_raw is None else _rit_raw+ if _rit is not None and str(_rit).strip().lower() in ("false", "0", "no", "off"):+ self._reply_to_mode = "off"# Inbound transport: "auto" (WebSocket with poll fallback, default),# "websocket" (require WS; fail connect when it can't authenticate),@@ -1333,23 +1342,10 @@ class BuzzAdapter(BasePlatformAdapter):# open with "@Chip" even though no mention is required there, so the# strip applies to both chat types.dispatch_text = self._strip_mention(content)- tags = event.get("tags")- thread_id = (- next(- (- str(tag[1])- for tag in tags- if isinstance(tag, (list, tuple))- and len(tag) > 3- and tag[0] == "e"- and tag[1]- and tag[3] == "root"- ),- None,- )- if isinstance(tags, list)- else None- )+ # NIP-10 thread root for session scoping: replies inside a thread all+ # share the root as their thread_id, so the gateway groups them into+ # one thread session (marked "root" tag preferred, legacy fallback).+ thread_id = self._extract_thread_root(event)# Remember where this message sits in the thread graph so our reply# can join the SAME thread rather than nesting a new one under it.@@ -1747,6 +1743,10 @@ def _apply_yaml_config(yaml_cfg: dict, buzz_cfg: dict) -> Optional[dict]:os.environ["BUZZ_ALLOW_ALL_USERS"] = str(extra["allow_all_users"]).lower()if "require_mention" in extra and not _skip_env_bridge and not os.getenv("BUZZ_REQUIRE_MENTION"):os.environ["BUZZ_REQUIRE_MENTION"] = str(extra["require_mention"]).lower()+ if "reply_in_thread" in extra and not os.getenv("BUZZ_REPLY_IN_THREAD"):+ os.environ["BUZZ_REPLY_IN_THREAD"] = str(extra["reply_in_thread"]).lower()+ if "reply_to_mode" in extra and not os.getenv("BUZZ_REPLY_TO_MODE"):+ os.environ["BUZZ_REPLY_TO_MODE"] = str(extra["reply_to_mode"]).lower()return None@@ -1830,11 +1830,18 @@ async def _standalone_send(return {"error": "Buzz standalone send: no target channel (set BUZZ_HOME_CHANNEL)"}args = ["messages", "send", "--channel", target, "--content", "-"]- # 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.+ # Same reply_to_mode / reply_in_thread gate as the live adapter, so+ # out-of-process cron delivery (deliver=buzz) doesn't thread when the+ # operator asked for flat channel replies._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":+ _rtm = str(_rtm).strip().lower()+ _rit = os.getenv("BUZZ_REPLY_IN_THREAD")+ if _rit is None:+ _rit = extra.get("reply_in_thread")+ if _rit is not None and str(_rit).strip().lower() in ("false", "0", "no", "off"):+ _rtm = "off"+ if thread_id and _rtm != "off":args += ["--reply-to", str(thread_id)]for path in media_files or []:args += ["--file", str(path)]diff --git a/plugins/platforms/buzz/plugin.yaml b/plugins/platforms/buzz/plugin.yamlindex 5bc8bedbf9c..18f76efa16e 100644--- a/plugins/platforms/buzz/plugin.yaml+++ b/plugins/platforms/buzz/plugin.yaml@@ -57,3 +57,7 @@ optional_env:description: "JSON credentials file holding the nsec (fallback when BUZZ_PRIVATE_KEY is unset)"prompt: "Credentials file path (or empty)"password: false+ - name: BUZZ_REPLY_IN_THREAD+ description: "Thread replies under the triggering message (true/false, default: true); false posts flat to the channel timeline"+ prompt: "Reply in thread? (true/false)"+ password: falsediff --git a/website/docs/user-guide/messaging/buzz.md b/website/docs/user-guide/messaging/buzz.mdindex f4a0ac4f750..e577193c677 100644--- a/website/docs/user-guide/messaging/buzz.md+++ b/website/docs/user-guide/messaging/buzz.md@@ -101,6 +101,23 @@ gateway:- Direct messages always reach the agent, no mention needed.- The agent's own messages are never dispatched back to it (self-echo suppression by pubkey), and every event is de-duplicated by event id against a per-channel high-water mark.+## Reply threading++Replies are threaded by default: the agent's answer (and any enabled progress/status messages) is anchored to the message that triggered it. Anchoring is NIP-10 aware — when the triggering message was already **inside** a thread, the agent replies to that thread's *root*, so the answer joins the existing thread instead of nesting a new one-message sub-thread under every turn.++To post replies flat at the channel level instead, set either of these (they are equivalent; `reply_in_thread` matches the key Slack uses):++```yaml+gateway:+ platforms:+ buzz:+ reply_to_mode: off # PlatformConfig-level, like Discord/Telegram+ extra:+ reply_in_thread: false # Slack-style key; env: BUZZ_REPLY_IN_THREAD+```++The opt-out applies to **all** send paths — final answers, streamed updates, interim commentary, tool-progress bubbles, and out-of-process cron delivery (`deliver=buzz`).+## Access controlBy default the allow-list is empty, which means every community member who mentions the agent gets a response only if `BUZZ_ALLOW_ALL_USERS=true`; otherwise restrict access by listing npubs or hex pubkeys in `BUZZ_ALLOWED_USERS` (or `allowed_users` in config.yaml). Community membership itself is enforced by the relay — only members can post.