- Use CAST(:embedding AS vector) instead of :embedding::vector to avoid SQLAlchemy named param conflict with PostgreSQL :: cast syntax - Add db.rollback() before recording AI usage on failure to prevent InFailedSQLTransactionError cascade Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>