Duo Chat is getting slower as the message count increase
Problem
Found in https://gitlab.slack.com/archives/C05CJ1T3P0W/p1738649916648039
Duo Chat is getting slower as the message count increases. It's less likely that this issue occurs on production because it's guarded by the rate limiter in GraphQL Endpoint, however, the internal evaluation endpoint api/v4/chat/completions doesn't have this mechanism and could end up having tons of messages in the same thread.
Proposal
Optimize the message fetching query to avoid the timeout error.
Edited by Shinya Maeda