Skip to content

fix: Typing Rate Limit in ActivityTracker#14

Draft
kevin-david wants to merge 2 commits into
Open-ACP:mainfrom
kevin-david:fix/typing-rate-limit
Draft

fix: Typing Rate Limit in ActivityTracker#14
kevin-david wants to merge 2 commits into
Open-ACP:mainfrom
kevin-david:fix/typing-rate-limit

Conversation

@kevin-david

@kevin-david kevin-david commented May 18, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes a race condition in ActivityTracker.startTyping() where rapid thought events could trigger concurrent sendTyping calls before the refresh interval was set. This led to multiple duplicate timers and Discord API rate limiting.

Added a synchronous typingActive guard flag to ensure only one sendTyping request is in flight at a time.

Caveat

This issue is currently being reproduced via a resume bug in the Gemini agent which emits rapid catch-up events. However, this fix provides general stability against any rapid sequence of thought events.

Regression Test

Added a test case in activity.test.ts that simulates concurrent onThought calls and verifies that only one API call is made and only one interval is spawned. Fails pre-changes.

Manual Testing

Gemini resume doesn't create a neverending typing indicator anymore!

@kevin-david kevin-david changed the title Fix: Typing Rate Limit in ActivityTracker fix: Typing Rate Limit in ActivityTracker May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant