fix(discord): reuse existing starter threads#190
fix(discord): reuse existing starter threads#190chenjian-agent wants to merge 2 commits intoopenabdev:mainfrom
Conversation
|
Production debugging notes for this fix:
This PR is the upstreamed version of that production fix. |
Review — PR #190The idea is correct — reusing existing threads instead of failing on duplicate creation. The three-layer fallback ( ✅ What looks good
🔴 Must fix before review can proceedBase is significantly outdated.
Please rebase onto latest 🟡 Non-blockingString matching on error message — SummaryValuable fix that complements the existing |
Summary
Fix Discord message handling when a starter thread already exists for the triggering message.
This makes
get_or_create_thread()resilient instead of treating Discord's existing-thread response as a fatal error.Closes #189
Root cause
The previous implementation always called
create_thread_from_message(...)for non-thread messages.If Discord had already created a starter thread for that message, the API returned:
A thread has already been created for this messageOpenAB logged the error and returned early, so the prompt was dropped even though a valid thread already existed.
Changes
MessageFlagsmsg.threadwhen Discord includes the starter thread on the message payloadmsg.idwhenMessageFlags::HAS_THREADis presentA thread has already been created for this messageresponse as a recoverable case and fall back to the existing starter thread idValidation
cargo buildopenab.serviceWhy this approach
For message-based starter threads, Discord uses the starter message id as the thread id. That means the correct recovery path is to reuse the existing thread instead of failing the request.