g1t/services/billing/migrations/0042_agent_rate_weights.sql
| 1 | -- How much each kind of token counts toward the g1t agent rate, as |
| 2 | -- price-book meters, on g1t's models and a workspace's own model key alike. |
| 3 | -- |
| 4 | -- A weight is `cost_micros` in millionths: 1,000,000 counts a token once, |
| 5 | -- 100,000 counts it a tenth. Every weight starts at 1, which is what the |
| 6 | -- agent rate counted until now (input, output, cache reads and cache |
| 7 | -- writes, each once), so nothing changes until a new version is decided. |
| 8 | -- A cached agent run reads most of its context from cache, so cache reads |
| 9 | -- dominate its tokens; counting them at 0.1 is the lever |
| 10 | -- (docs/BILLING_OPERATIONS.md, "The agent rate's token weights"). |
| 11 | -- |
| 12 | -- Weights change as any price does: a new version in price_versions with |
| 13 | -- its effective date. A lower weight is a fall and applies at once; a |
| 14 | -- higher one is a rise and waits out the notice. |
| 15 | |
| 16 | INSERT OR IGNORE INTO prices (meter, title, unit, cost_micros, markup_percent, source, updated_at) VALUES |
| 17 | ('agent_token_weight_input', 'Agent rate weight: input tokens', 'weight', 1000000, 0, 'list', '2026-10-08T00:00:00Z'), |
| 18 | ('agent_token_weight_output', 'Agent rate weight: output tokens', 'weight', 1000000, 0, 'list', '2026-10-08T00:00:00Z'), |
| 19 | ('agent_token_weight_cache_read', 'Agent rate weight: cache reads', 'weight', 1000000, 0, 'list', '2026-10-08T00:00:00Z'), |
| 20 | ('agent_token_weight_cache_write', 'Agent rate weight: cache writes', 'weight', 1000000, 0, 'list', '2026-10-08T00:00:00Z'); |
| 21 | |
| 22 | INSERT OR IGNORE INTO price_versions (id, meter, version, cost_micros, markup_percent, effective_at, reason, created_by, created_at, applied_at) VALUES |
| 23 | ('pv_agent_token_weight_input_1', 'agent_token_weight_input', 1, 1000000, 0, '2026-10-08T00:00:00Z', |
| 24 | 'Every input token counts once toward the agent rate', 'migration', '2026-10-08T00:00:00Z', '2026-10-08T00:00:00Z'), |
| 25 | ('pv_agent_token_weight_output_1', 'agent_token_weight_output', 1, 1000000, 0, '2026-10-08T00:00:00Z', |
| 26 | 'Every output token counts once toward the agent rate', 'migration', '2026-10-08T00:00:00Z', '2026-10-08T00:00:00Z'), |
| 27 | ('pv_agent_token_weight_cache_read_1', 'agent_token_weight_cache_read', 1, 1000000, 0, '2026-10-08T00:00:00Z', |
| 28 | 'Every cache-read token counts once toward the agent rate', 'migration', '2026-10-08T00:00:00Z', '2026-10-08T00:00:00Z'), |
| 29 | ('pv_agent_token_weight_cache_write_1', 'agent_token_weight_cache_write', 1, 1000000, 0, '2026-10-08T00:00:00Z', |
| 30 | 'Every cache-write token counts once toward the agent rate', 'migration', '2026-10-08T00:00:00Z', '2026-10-08T00:00:00Z'); |