Skip to content
Changelog

Batch Qdrant inserts and retry Postgres table creation

November 17, 20261 min read

Agno's Qdrant.insert now sends upserts of batch_size points, so a large document stays under the Qdrant server's request-size limit, and async_insert takes the same argument. Before, insert accepted batch_size and still sent every point in one upsert.

vector_db.insert(content_hash=content_hash, documents=documents, batch_size=100)

We inserted five documents with batch_size=2 into an in-memory QdrantClient, using a fake embedder as a stand-in for a real embedding model, and counted the upsert calls:

Before: upsert calls: 1 sizes: [5]
Now:    upsert calls: 3 sizes: [2, 2, 1]

PostgresDb and AsyncPostgresDb could not recover from a failed table creation. The instance kept the broken table definition, and every later call on it failed even after the database was fixed. A composite type named agno_sessions blocked the first upsert_session on an embedded Postgres. Then the script dropped the type and called the same instance again:

Before: retry -> InvalidRequestError: Table 'ai.agno_sessions' is already defined for this MetaData instance.
Now:    retry -> saved

AsyncPostgresDb showed the same before and after.

See the cookbook, and learn more about Qdrant and PostgreSQL in the documentation.

Frequently asked questions

It caps the points in each upsert request. Five documents with batch_size=2 go out as 2, 2 and 1 points. With no batch_size, all points go in one request, and 0 or a negative number raises ValueError: batch_size must be a positive integer before any embedding runs.

Yes, from this release. Earlier releases raised TypeError: Qdrant.async_insert() got an unexpected keyword argument 'batch_size'.

A failed CREATE TABLE left its half-built SQLAlchemy Table on the instance's MetaData, so every later attempt on that instance stopped at Table 'ai.agno_sessions' is already defined for this MetaData instance. Agno now removes the failed table before re-raising.

Its upsert_session logs the error and returns None, so earlier releases returned None on the retry as well. This release saves the session on the retry.

Shipped around the same time