fix(discord): add multi-layer safety against bot-to-bot death-loops (#32791) - #33985
fix(discord): add multi-layer safety against bot-to-bot death-loops (#32791)#33985Tranquil-Flow wants to merge 1 commit into
Conversation
…ousResearch#32791) Three-layer safety fix for multi-bot Discord channels: Layer 1 — Config-semantics: free_response_channels no longer bypasses DISCORD_ALLOW_BOTS=mentions. Bot messages in free-response channels without @mention are blocked, matching documented behaviour. Layer 2 — Anti-loop circuit breaker: after N consecutive bot replies within a configurable window (default: 3 in 60s), auto-reply is suspended for that channel for M minutes (default: 10 min). Configurable via DISCORD_CIRCUIT_BREAKER_THRESHOLD / _WINDOW_S / _COOLDOWN_S env vars. Layer 3 — In-band operator HALT: when a known operator (DISCORD_OPERATOR_IDS) posts STOP/HALT/KILL/FREEZE/CEASE, auto-reply is suspended across ALL channels for M minutes (DISCORD_HALT_COOLDOWN_S, default: 10 min). Gives operators an emergency stop that doesn't require host access.
Tranquil-Flow
left a comment
There was a problem hiding this comment.
Reviewed — this is a clean, well-structured fix.
Layer 1 — free_response_channels now respects DISCORD_ALLOW_BOTS=mentions. When a bot posts in a free-response channel without @mentioning us, the bypass is gated. Correctly handles the edge case where two Hermes profiles would otherwise reply to each other indefinitely.
Layer 2 — Per-channel circuit breaker with configurable window/threshold/cooldown. Three consecutive bot replies within 60s window trips a 10-minute suspension. Timestamps rotated efficiently with list comprehension — no unbounded growth.
Layer 3 — In-band operator HALT/STOP/KILL/FREEZE commands. Known operators can globally suspend auto-reply. Clean integration.
All 8 safety-layer tests pass plus the existing 44 Discord tests are unaffected (52 total).
CI note: test (2) failures are in test_discord_document_handling.py — document content injection assertions. Completely unrelated to this PR (different test file, different feature area). Pre-existing flake.
Ready to merge once CI is re-triggered or the flake is addressed separately.
|
Thanks for the detailed writeup and the implementation — closing as out of scope. Bot-to-bot communication isn't a supported topology in Hermes. The safe default ( A couple of notes from review:
Supported guidance: keep |
What
Three-layer safety fix for multi-bot Discord channels: prevents ack-loop death-spiral (#32791).
Layer 1: free_response_channels no longer bypasses DISCORD_ALLOW_BOTS=mentions.
Layer 2: Anti-loop circuit breaker. After N bot replies in a channel (default 3), suspend auto-reply for M minutes (default 10).
Layer 3: In-band operator HALT. Known operators can post STOP/HALT to suspend auto-reply globally.
Files
Tests
All 52 tests pass. 6/8 new tests fail without the production change. Ruff clean.