Skip to content

Alert #muzzlefeedback on OpenAI 429 responses#260

Merged
sfreeman422 merged 5 commits into
masterfrom
copilot/update-429-error-handling
Jun 23, 2026
Merged

Alert #muzzlefeedback on OpenAI 429 responses#260
sfreeman422 merged 5 commits into
masterfrom
copilot/update-429-error-handling

Conversation

Copilot AI commented Jun 23, 2026

Copy link
Copy Markdown

OpenAI rate-limit failures were surfacing as ordinary request errors, with no operational signal in Slack. This change notifies #muzzlefeedback whenever an OpenAI call returns 429, using the error message returned by OpenAI.

  • Summary

    • Centralized 429 handling for OpenAI-backed flows in the backend AI service.
    • Preserves existing error propagation while adding a Slack alert with the returned OpenAI message.
  • Implementation

    • Added a shared alertOnOpenAiRateLimit(error, operation) path in AIService.
    • Detects OpenAI status === 429.
    • Extracts the nested API message when present (error.message fallback otherwise).
    • Sends a compact alert to #muzzlefeedback and avoids altering non-429 behavior.
  • Covered call sites

    • Text generation
    • Prompt-with-history
    • Participation replies
    • Corpo-speak generation
    • Moonbeam redeploy quote generation
    • Memory extraction
  • Regression coverage

    • Added focused specs for direct 429 alerting behavior.
    • Added flow-level coverage to verify the alert path is invoked from OpenAI failure cases.
await this.alertOnOpenAiRateLimit(error, 'generateText');

// Example Slack message:
// OpenAI 429 during generateText: Please slow down.

@sfreeman422 sfreeman422 marked this pull request as ready for review June 23, 2026 01:35
Copilot AI review requested due to automatic review settings June 23, 2026 01:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds operational visibility for OpenAI rate-limit failures by emitting a Slack alert to #muzzlefeedback whenever an OpenAI-backed flow receives a 429, while preserving existing error propagation/handling semantics.

Changes:

  • Introduces AIService.alertOnOpenAiRateLimit(error, operation) plus helpers to extract OpenAI status/message safely.
  • Wires the alert into all OpenAI-backed flows called out in the PR (text, corpo-speak, prompt-with-history, participation, Moonbeam redeploy quote, and memory extraction).
  • Adds focused unit coverage for the new alert behavior and verifies it’s invoked from failure paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/backend/src/ai/ai.service.ts Adds centralized OpenAI 429 detection + Slack alerting and invokes it from OpenAI failure paths.
packages/backend/src/ai/ai.service.spec.ts Adds specs validating alerting behavior for 429 (and no alert for non-429).
packages/backend/src/ai/memory/memory.job.ts Hooks memory extraction OpenAI failures into the centralized 429 alert path.
packages/backend/src/ai/memory/memory.job.spec.ts Refactors private-method invocation helper and adds a spec asserting 429 extraction failures trigger alerting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sfreeman422

Copy link
Copy Markdown
Collaborator

@copilot fix the failing tests

Copilot AI commented Jun 23, 2026

Copy link
Copy Markdown
Author

@copilot fix the failing tests

Fixed in 095c0c2. I added the missing 429 alert branch coverage and re-ran the backend coverage gate successfully.

Copilot AI requested a review from sfreeman422 June 23, 2026 01:45
@sfreeman422 sfreeman422 merged commit 0f1af38 into master Jun 23, 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.

3 participants