fix(ai-connectors): deduplicate outage bridge DMs per conversation with a cooldown
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- postgresql, redis, typescript
調査の方向性
Start with apps/api/src/ai-connectors/ai-connectors.service.ts, especially AiConnectorsService and dispatchCompletion, then read apps/api/src/redis/redis.service.ts and the Message model in packages/prisma/schema.prisma. Check how Redis disconnection and existing constructor tests are handled. Done means both outage notifications are suppressed for 15 minutes per conversation, with a database fallback when Redis is unavailable.
索引モデルが issue の本文から書いたものです。
説明
Problem Description
In apps/api/src/ai-connectors/ai-connectors.service.ts (dispatchCompletion, lines 546-617), when all AI providers fail and conversationId is present, it unconditionally enqueues a SEND_DM BackgroundJob with bridgeMsg and creates an INTERNAL_NOTE ([AI Outage Alert]) on the conversation with no per-conversation cooldown.
If a customer sends multiple messages while AI providers are down, they receive duplicate bridgeMsg DMs and the conversation gets spammed with duplicate internal notes.
Expected Behavior
- During an AI outage, both
bridgeMsgand the[AI Outage Alert]INTERNAL_NOTEare emitted at most once per conversation within a cooldown window (e.g., 15 minutes). - Works reliably both locally (even without Redis) and in production across multiple API replicas, without breaking existing unit tests.
Where to Look
apps/api/src/ai-connectors/ai-connectors.service.ts(AiConnectorsServiceconstructor line 33,dispatchCompletionlines 546-617)apps/api/src/redis/redis.service.ts(reserveWebhookEventlines 167-197)packages/prisma/schema.prisma(Messagemodel, usessentAt)
Solution / Implementation Guide
- Inject
@Optional() private readonly redisService?: RedisServiceintoAiConnectorsService(RedisModuleis@Global(), and@Optional()preserves existing unit test constructors). - Add a cooldown helper in
RedisService(e.g.,acquireCooldown(key: string, ttlSeconds: number): Promise<boolean>usingSET key '1' EX ttlSeconds NX, returningtrueif acquired or falling back safely if Redis is disconnected). - Gate both
bridgeMsgandINTERNAL_NOTEbehind the 15-minute cooldown indispatchCompletion:- If
this.redisServiceis available: callawait this.redisService.acquireCooldown(\ai:outage_bridge:${conversationId}`, 900)`. - DB fallback (if Redis is unavailable locally): query
prisma.message.findFirstwithwhere: { conversationId, messageType: 'INTERNAL_NOTE', content: { contains: 'AI Outage Alert' }, sentAt: { gte: new Date(Date.now() - 15 * 60 * 1000) } }(note:MessageusessentAt, notcreatedAt). - If the cooldown is active (already sent within 15 minutes), skip both enqueuing the
SEND_DMbridgeMsgjob and creating theINTERNAL_NOTE.
- If
- 主要言語
- TypeScript
- スター
- 2
- フォーク
- 1
- 平均マージ
- 6分
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sumamakhan761/tryinstance のほかの issue
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#65 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
sumamakhan761/tryinstance#64 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
sumamakhan761/tryinstance#63 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#62 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#60 ·
メンテナーはふだん 1 日以内に返信
sumamakhan761/tryinstance の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
makecindy/cindy#15342 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
kwitsch/claude-code-plugin-tooling#219 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
no-repo-link tool-submission
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100