Interesting project. The race condition problem makes a lot of sense, especially in systems where multiple workers or parallel workflows trigger LLM calls at the same time.
I like the reserve/settle approach since many AI workloads don’t know the exact cost until the response is completed. Atomic enforcement at the Redis layer seems like a practical way to avoid unexpected spend spikes.
I’m curious how you handle edge cases like failed requests, retries, or long-running jobs that reserve budget but never settle.