Summary
Discord message handling fails when a user triggers OpenAB from a message that already has a starter thread.
The current code path always calls create_thread_from_message(...) for non-thread messages. If Discord has already created a thread for that message, the API returns:
A thread has already been created for this message
OpenAB currently treats that response as a fatal error and returns early, so the user request is dropped even though a usable thread already exists.
Observed production behavior
On the production host, the service itself stayed healthy and connected, but requests were intermittently lost. The relevant logs were:
2026-04-10T13:52:36Z ERROR openab::discord: failed to create thread: A thread has already been created for this message
2026-04-10T13:53:29Z ERROR openab::discord: failed to create thread: A thread has already been created for this message
2026-04-10T13:56:02Z ERROR openab::discord: failed to create thread: A thread has already been created for this message
2026-04-10T22:16:30Z ERROR openab::discord: failed to create thread: A thread has already been created for this message
2026-04-10T23:53:48Z ERROR openab::discord: failed to create thread: A thread has already been created for this message
This made the bot appear "down" from the user perspective even though openab.service was still active (running).
Root cause
get_or_create_thread() in src/discord.rs is not idempotent:
- it does not reuse
msg.thread when Discord already includes the starter thread on the message payload
- it does not recognize
MessageFlags::HAS_THREAD
- it does not recover when
create_thread_from_message(...) returns the known "thread already exists" error
Expected behavior
If a starter thread already exists for the triggering message, OpenAB should reuse it and continue processing the prompt instead of failing the request.
Suggested fix
Make get_or_create_thread() resilient and idempotent:
- if the incoming message is already in a thread, return the current channel id
- if
msg.thread is present, reuse that thread id
- if
msg.flags contains HAS_THREAD, reuse msg.id for message-based starter threads
- if Discord returns
A thread has already been created for this message, treat that as a recoverable case and fall back to the existing starter thread id
Scope
This is a production bug in the Discord adapter. It is not a session-pool or agent-backend issue.
Summary
Discord message handling fails when a user triggers OpenAB from a message that already has a starter thread.
The current code path always calls
create_thread_from_message(...)for non-thread messages. If Discord has already created a thread for that message, the API returns:A thread has already been created for this messageOpenAB currently treats that response as a fatal error and returns early, so the user request is dropped even though a usable thread already exists.
Observed production behavior
On the production host, the service itself stayed healthy and connected, but requests were intermittently lost. The relevant logs were:
This made the bot appear "down" from the user perspective even though
openab.servicewas stillactive (running).Root cause
get_or_create_thread()insrc/discord.rsis not idempotent:msg.threadwhen Discord already includes the starter thread on the message payloadMessageFlags::HAS_THREADcreate_thread_from_message(...)returns the known "thread already exists" errorExpected behavior
If a starter thread already exists for the triggering message, OpenAB should reuse it and continue processing the prompt instead of failing the request.
Suggested fix
Make
get_or_create_thread()resilient and idempotent:msg.threadis present, reuse that thread idmsg.flagscontainsHAS_THREAD, reusemsg.idfor message-based starter threadsA thread has already been created for this message, treat that as a recoverable case and fall back to the existing starter thread idScope
This is a production bug in the Discord adapter. It is not a session-pool or agent-backend issue.