AI 0.23.1: Paid AI calls are no longer lost from the usage log
AI 0.23.1 fixes lost usage rows. A call that named a user, endpoint or prompt that did not exist, such as a stale user id or an endpoint deleted during the call, failed to log. A call already made and paid for vanished from the usage log and from every spend cap.
The row is now written with that reference left empty, the original id kept in its metadata, and a warning logged. It still counts toward the endpoint and site-wide caps it can be tied to, but not toward the per-user cap. Several broken references in one row are all dropped, not just the first. When the caller has a database transaction open, the retry no longer breaks it: before, an AI call that had succeeded could raise an error afterwards.
Full release notes: AI 0.23.1
0.23.1 · 17 September 2026
Fixed
- A usage row is kept when a reference names no row (PR #28).
create_request/1used to fail the insert whenuser_uuid,endpoint_uuidorprompt_uuidnamed no row — a stale or external user id, an endpoint deleted mid-call — so a call already made and paid for vanished from the log and from every spend cap. The row is now written with that reference empty, the submitted id kept inmetadata["unresolved_refs"], and a warning logged. It still counts toward the endpoint and global caps it can be attributed to, never the per-user one. Any other validation failure still returns{:error, changeset}. - Every dangling reference is dropped, not just the first. Postgres reports one broken foreign key per statement, so a row with both a ghost user and a deleted endpoint was still lost on the retry. The insert now retries until no new reference is refused.
- The retry works inside a caller’s transaction. The refused insert
used to abort the surrounding transaction, so the retry raised
in_failed_sql_transactionout of an AI verb whose call had already succeeded. The insert runs under a savepoint whenever a transaction is open.
Changed
Budgetkeepsstatus = 'success'as a literal so core’s V193 partial indexes on(endpoint_uuid, inserted_at)/(user_uuid, inserted_at)apply; the corresponding AGENTS.md TODO is removed.
AI 0.23.1. Install or update: {:phoenix_kit_ai, "~> 0.23"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.