Skip to content

Fix Addie performance and add cache invalidation - #387

Merged
bokelley merged 3 commits into
mainfrom
bokelley/fix-addie-self-loop
Dec 30, 2025
Merged

bokelley merged 3 commits into
mainfrom
bokelley/fix-addie-self-loop

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Fixes infinite loop bug in Addie responding to her own messages and significantly improves response latency by implementing a member context cache with targeted invalidation.

Key improvements:

  • Fixed bot message detection by checking bot_id field (not just subtype) in Slack DMs
  • Added 30-minute cache for member context to eliminate sequential database lookups
  • Parallelized independent database queries to speed up cache misses
  • Implemented cache invalidation at 18 mutation points across the app

Addie now responds nearly instantly for most interactions (cached) and respects data changes immediately across working groups, profiles, subscriptions, and email preferences.

bokelley and others added 3 commits December 29, 2025 17:43
The message handler was checking for bot messages via subtype, but Slack
bot messages in DM threads include a bot_id field rather than setting
subtype. Added bot_id check to prevent Addie from responding to messages
from any bot, including herself.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Performance improvements to member context resolution:
- Run 7 independent database/API queries in parallel instead of sequentially
- Add 30-minute TTL cache for member context (invalidate on data changes)
- Remove Addie interaction history lookup (Slack handles conversation context)
- Export invalidateMemberContextCache for use when user data changes

Expected improvement: ~2 seconds faster on first message, near-instant on
follow-up messages from the same user within the cache window.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Invalidate the member context cache whenever user/organization data changes
to ensure Addie always has fresh information. The 30-minute cache with these
invalidation hooks maintains fast response times while keeping context current.

Adds cache invalidation to:
- Email preference changes (4 endpoints)
- Subscription changes (Stripe webhooks)
- Working group membership changes (4 endpoints)
- Member profile changes (6 endpoints)
- Slack account linking/unlinking (4 endpoints)
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