Chainlit#2899 - Hot-swap Chat Profile within an active conversation

FO
3mo ago
+1230-43

This feature allows users to hot-swap between chat profiles within a conversation.

As shown in the video, when going back to a chat, it sets the latest used profile

https://github.com/user-attachments/assets/0db1239f-2e53-4f69-a67b-e21d1df4ca2c


Summary by cubic

Hot-swaps the chat profile during an active conversation so switching no longer reconnects or resets the thread. Previously, switching profiles forced a reconnect; now the session updates in place and persists the last used profile (and thread tag when features.auto_tag_thread is on) after the first interaction.

Backend

  • Adds opt-in features.hot_swap_chat_profile and cl.set_chat_profile(name | None), which validates against @cl.set_chat_profiles, updates the session config, persists to thread metadata, and emits chat_profile_updated.
  • The set_chat_profile event is ignored when the feature is off; metadata redaction keeps chat_profile and chat_settings, and restoration honors an explicitly unset profile.

Frontend

  • hotSwapChatProfile switches in place without recreating the socket; Chat Profiles hot-swaps when the feature is on, otherwise falls back to the confirm-and-reset flow.
  • New, updated, streamed, and ask messages are stamped with metadata.chat_profile so avatars resolve per message.