fix(discord): reuse existing starter threads#190
Open
chenjian-agent wants to merge 2 commits intoopenabdev:mainfrom
Open
fix(discord): reuse existing starter threads#190chenjian-agent wants to merge 2 commits intoopenabdev:mainfrom
chenjian-agent wants to merge 2 commits intoopenabdev:mainfrom
Conversation
Contributor
Author
|
Production debugging notes for this fix:
This PR is the upstreamed version of that production fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.