Pin a Pricing Snapshot Before an AI Agent Run
Описание и применение
При запуске сложных AI‑агентов фиксируется снимок цен, который прикрепляется к каждому вызову модели, обеспечивая точную и воспроизводимую биллинг‑систему.
Задача
Long-running AI agents incur multiple model calls, making it hard to know which pricing catalog applied at run start, leading to billing mismatches.
Результат
By pinning a pricing snapshot at run start, the system avoids billing errors, provides a clear audit trail, and simplifies support reviews.
Рабочий процесс
- Fetch a fresh pricing snapshot from the public endpoint
- Resolve the user’s effective billing group
- Estimate initial context size
- Select allowed routes and calculate a budget envelope
- Create an agent_run record with snapshot version and budget limits
- Reject or downscope runs that exceed budget
- During the run, attach snapshot info to each model call record
- Use the snapshot for later invoice generation and support review
Доказательства
The gateway should pin a pricing snapshot, calculate a budget envelope, record the selected billing group, and attach those facts to every model call that belongs to the run.
Use one run record and many request records. The run record pins policy.
- Дата записи: 2026-09-05T18:23:05.768Z