Skip to content

Commit a72e8fd

Browse files
ClaudeMMclaude
andcommitted
feat: ack-only message filtering for room automation
Filter out low-value acknowledgment messages ("understood", "got it", "agreed", etc.) from automation posts to prevent noise and loops. Matches the same pattern list used in the antfarm bridge. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eac4596 commit a72e8fd

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎src/room-automation.mjs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ import { randomUUID } from 'node:crypto';
66
import { createReceipt, appendReceipt } from './receipt.mjs';
77
import { canSend, markSent } from './rate-limiter.mjs';
88

9+
// Ack-only messages are low-value and cause loops. Filter them out from automation posts.
10+
const ACK_ONLY_PATTERNS = [
11+
'understood', 'agreed', 'proceed', 'perfect', 'exactly',
12+
'great', 'good', 'sounds good', 'will do', 'yes',
13+
'got it', 'noted', 'copy that', 'roger', 'acknowledged',
14+
'excellent', 'right', 'correct', 'ok', 'okay',
15+
];
16+
17+
function isAckOnly(body) {
18+
const cleaned = (body || '').trim().replace(/[.!,]+$/, '').toLowerCase();
19+
if (cleaned.length >= 80) return false;
20+
return ACK_ONLY_PATTERNS.some(pat =>
21+
cleaned === pat || cleaned.startsWith(pat + ' ') || cleaned.startsWith(pat + '.') || cleaned.startsWith(pat + ',')
22+
);
23+
}
24+
925
/**
1026
* Room Automation — rule-based automation triggered by Ant Farm room messages.
1127
*
@@ -63,6 +79,10 @@ function fetchRoomMessages(room, apiKey, limit = 20) {
6379
}
6480

6581
function postMessage(room, body, apiKey, config) {
82+
if (isAckOnly(body)) {
83+
console.log(` ack-only message filtered, skipping post to ${room}: ${body.slice(0, 60)}`);
84+
return false;
85+
}
6686
if (!canSend(config)) {
6787
console.log(` rate-limited (${config?.rate_limit?.message_interval_sec || 30}s interval), skipping post to ${room}`);
6888
return false;
@@ -218,6 +238,8 @@ function executeAction(action, msg, apiKey, config) {
218238
*
219239
* @param {object} opts - { rooms, apiKey, handle, interval, config, rules }
220240
*/
241+
export { isAckOnly };
242+
221243
export async function startRoomAutomation({ rooms, apiKey, handle, interval, config }) {
222244
const rules = config?.automation?.rules || [];
223245
const seenFile = config?.automation?.seen_file || SEEN_FILE_DEFAULT;

0 commit comments

Comments
 (0)