Michael Suchacz
1031da9738
feat: add agent chat spend limiting (backend) (#23071)
Introduces deployment-scoped spend limiting for Coder Agents, enabling
administrators to control LLM costs at global, group, and individual
user levels.
## Changes
- **Database migration (000437)**: `chat_usage_limit_config`
(singleton), `chat_usage_limit_overrides` (per-user),
`chat_usage_limit_group_overrides` (per-group)
- **Single-query limit resolution**: individual override > min(group) >
global default via `ResolveUserChatSpendLimit`
- **Fail-open enforcement** in chatd with documented TOCTOU trade-off
- **Experimental API** under `/api/experimental/chats/usage-limits` for
CRUD on limits
- **`AsChatd` RBAC subject** for narrowly-scoped daemon access (replaces
`AsSystemRestricted`)
- **Generated TypeScript types** for the frontend SDK
## Hierarchy
1. Individual user override (highest)
2. Minimum of group limits
3. Global default
4. Disabled / unlimited
Currency stored as micro-dollars (`1,000,000` = $1.00).
Frontend PR: #23072
2026-03-17 01:24:03 +01:00
..
2025-08-20 12:19:14 +01:00
2026-03-06 14:43:53 +02:00
2026-03-16 15:30:25 -05:00
2026-02-24 15:27:03 +00:00
2025-12-02 16:50:09 +02:00
2026-02-06 09:52:17 -07:00
2026-03-06 21:05:26 +02:00
2026-03-12 21:32:57 +00:00
2026-02-27 16:50:56 +00:00
2026-03-17 01:24:03 +01:00
2025-12-02 14:17:52 +00:00
2026-03-10 13:52:55 -04:00
2026-03-12 21:32:57 +00:00
2026-03-12 21:32:57 +00:00
2026-03-12 21:32:57 +00:00
2025-08-07 10:14:58 -06:00
2026-03-04 12:54:39 +02:00
2025-08-30 03:39:37 +10:00
2025-03-27 10:03:53 +00:00
2025-03-20 13:41:54 +01:00
2026-03-12 21:32:57 +00:00
2025-09-30 23:54:21 +01:00
2026-01-14 09:47:50 -08:00
2025-11-20 17:12:25 +01:00
2025-11-20 17:12:25 +01:00
2025-10-07 13:10:38 +00:00
2025-10-07 13:10:38 +00:00
2026-03-12 21:32:57 +00:00
2025-10-07 13:10:38 +00:00
2026-01-12 18:19:19 -08:00
2026-03-12 21:32:57 +00:00
2026-01-26 14:27:17 +04:00
2026-02-24 17:04:42 +00:00
2025-01-31 13:55:46 +01:00
2025-10-28 03:16:41 +11:00
2026-02-05 14:38:55 -06:00
2025-05-29 08:55:19 -05:00
2026-03-12 21:32:57 +00:00
2025-05-14 12:21:36 -05:00
2025-12-12 11:41:46 +00:00
2025-10-07 13:10:38 +00:00
2025-08-30 03:39:37 +10:00
2026-03-12 21:32:57 +00:00
2025-08-07 15:58:59 -04:00
2026-03-11 10:19:08 -07:00
2026-01-30 17:19:19 +00:00
2025-03-03 18:41:01 +01:00
2026-02-19 16:56:29 +00:00
2026-03-12 21:32:57 +00:00
2025-03-20 14:10:45 +00:00
2026-02-24 17:04:42 +00:00
2026-03-12 21:32:57 +00:00
2026-03-10 12:17:32 -05:00
2026-02-27 16:50:56 +00:00