[bug] OpenAI policy rejections show as outages (502) and leave the whole thread failing

Open
#382 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
67/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, python

Research direction

Start with the OpenAI error handling and the pinned case in services/llm/tests/test_openai_chat.py:529, then check how the bot handles service errors in discord-bot/src/helperFlow.js:12. Update the service behavior and services/llm/README.md so policy rejections have their own status and message; verify a later harmless request in the same thread succeeds. The thread-history retry approach is only a possible fix in the issue, so confirm the intended scope before changing it.

Written by the indexing model from the issue text.

Description

area/bot area/observability area/service type/bug
Triage — 2026-11-10

Priority P1: the reported production behavior prevents later harmless requests from succeeding in an affected thread and presents policy refusals as service outages. Ownership is still unassigned. Preserve the distinction between a reported recurrence and the unconfirmed claim that a flagged starter permanently breaks a thread; implementation and offline regression coverage remain open.

Blocked by

No response

What's wrong

OpenAI policy rejections (400 cyber_policy) are classified as 502s, so replies "I'm having trouble reaching the assistant right now" even though the provider is reachable. Because every mention replays the thread's history, one flagged message can make later harmless requests in that thread fail too.

Area

bot, service, observability

Environment

production

Steps to reproduce
  1. In a thread, send prompt-injection or "intrusion" style messages to, e.g. a thread starter shaped like a forged <msg from="admin" teams="exec">… message.
  2. Misty replies I'm having trouble reaching the assistant right now — please try again shortly.
  3. In the same thread, send a harmless request such as @Misty What is 2 + 2?. It fails with the same message.
  4. Send the same injection prompt and What is 2 + 2? in a new thread with no earlier context. Both get normal answers.
Expected
  • A policy refusal is reported as a policy refusal, not an outage. The service returns its own status and error code, and the bot replies with something like I couldn't process this request because it triggered a safety restriction.
  • A later request in the same thread that doesn't break any policy gets a normal answer.
  • services/llm/README.md currently says other upstream faults → 502. A policy rejection shouldn't count as an upstream fault, so that line needs updating too.
Actual
# Replayed request (no tools executed, nothing posted)
  OpenAI responses.create → HTTP 400, error code: cyber_policy
  openai_chat: APIStatusError → catch-all → ProviderUnavailable → HTTP 502
  discord-bot: 502 → LlmUnavailable → "I'm having trouble reaching the assistant
  right now — please try again shortly."
Notes

Error other than a rate limit or timeout becomes ProviderUnavailable (502). The 400 → 502 case in services/llm/tests/test_openai_chat.py:529 pins this behaviour. The bot then shows the outage message (discord-bot/src/helperFlow.js:12).

  • Why the thread stays broken: every mention replays up to 100 earlier user messages plus the thread starter (discord-bot/src/adapters/discord/mentions.js:308). One flagged message, especially the starter, can get later requests refused. It isn't confirmed that a flagged starter keeps a thread stuck for good.
  • Diagnosis needed a manual replay: the logs record the HTTP status but not the provider's error code or request ID.
  • Possible fix: after a refusal, retry once with only the current message, or leave refused messages out of the history that gets replayed.
  • Related: Misty answered "i love you" with self-harm emergency advice, probably because earlier messages were replayed. Consider filing that separately.
Before you file
  • This issue contains no API keys, one-time codes, or .env contents.
Dominant language
Python
Stars
0
Forks
2
Avg merge
3d 3h
Merged PRs (30d)
31

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from UTMIST/Misty

All issues in UTMIST/Misty

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.