Skip to main content

Overview

IDManager maintains auto-incrementing ID sequences for LangChat’s Supabase tables. It handles concurrent inserts gracefully by using a retry-with-conflict-resolution strategy. This is an internal component — you don’t interact with it directly under normal use.

How it works

  1. On initialization, IDManager reads the current maximum ID from each table
  2. IDs are assigned from an in-memory counter
  3. When two concurrent requests try to insert with the same ID, the retry logic increments and retries automatically
  4. This avoids database sequences while maintaining consistent IDs

Constructor

Client
Supabase client instance.
int
default:"1"
Starting ID value for new tables.
int
default:"3"
Number of retry attempts on ID conflict before raising an error.

Methods

insert_with_retry()

Insert a record with automatic ID assignment and conflict retry.
Used internally by session.save_message() and metrics recording. You only need this if building a custom adapter.