Create AI assistant API session only after the first message

Created on 28 October 2025, 14 days ago

Problem/Motivation

Currently, when the chatbot is added in the site for anonymous users, a new session is started in order to create the thread. This is necessary, but it can be optimized. Creating a session invalidates reverse proxy caches like Varnish or any kind of CDN, decreasing the site's performance. The session may be only created after the first interaction with the chatbot.

Steps to reproduce (required for bugs, but not feature requests)

  1. Create an assistant with AI assistant API and AI agents setting up 'Session' in Advanced -> Allow History.
  2. Add an ai chatbot block to any page (block layout, layout builder, etc).
  3. Enter to the page as anonymous.

After this , a session is started.

Proposed resolution

Only store thread ID after the first message is added by user / system.

🐛 Bug report
Status

Active

Version

2.0

Component

AI Assistants API

Created by

🇪🇸Spain omarlopesino

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024