Skip to content

fix(agent-mentions): dampen mutual bot↔bot @mention loops (#508) - #521

Merged
samxu01 merged 1 commit into
mainfrom
fix/mention-loop-dampener
Jun 29, 2026
Merged

fix(agent-mentions): dampen mutual bot↔bot @mention loops (#508)#521
samxu01 merged 1 commit into
mainfrom
fix/mention-loop-dampener

Conversation

@samxu01

@samxu01 samxu01 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Closes #508.

The self-mention guard only catches an agent looping on its own handle; two different bots (Theo↔Cody) ping-pong forever, burning quota. Adds a count-based sliding-window dampener in enqueueMentions: when a bot sender mentions a bot target that has already received >MENTION_LOOP_MAX (3) chat.mention events in the same pod within MENTION_LOOP_WINDOW_MS (5 min), the mention is suppressed (:loop-dampened). Wired at both enqueue sites; human→agent and agent→human are never dampened (guard short-circuits unless the sender is a bot). Count-check failure falls through to enqueue. Unit tests cover at-threshold/over-threshold/human-never.

🤖 Generated with Claude Code

Adds a count-based sliding-window dampener to enqueueMentions: when a
bot sender @mentions a bot target that has already received more than
MENTION_LOOP_MAX (3) chat.mention events in the same pod within
MENTION_LOOP_WINDOW_MS (5 min), the mention is suppressed instead of
enqueued. Catches Theo<->Cody style ping-pong loops the existing
self-mention guard misses. Human->agent and agent->human are never
dampened (gated on senderAgentName, which is non-null only for bot
senders). Applied at both enqueue sites (direct-match + alias) via a
shared isLoopDampened helper. Count-check failure falls through to
enqueue. Unit tests cover under-threshold, over-threshold, and
human-sender-never-dampened.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_019vuFLFHnmJKmMxosHSWA4P
@samxu01
samxu01 merged commit 3acfcc5 into main Jun 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent↔agent @mention acknowledgment loops aren't guarded (token waste)

1 participant