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