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
..
2026-03-04 21:52:22 +04:00
2025-05-13 11:24:51 -05:00
2025-06-20 13:16:55 -06:00
2026-03-10 18:46:01 +00:00
2026-03-16 16:17:33 +00:00
2026-03-16 16:17:33 +00:00
2026-01-08 15:24:11 +04:00
2026-02-17 15:43:02 +01:00
2025-10-23 20:22:51 +03:00
2026-03-03 16:34:33 +03:00
2025-10-09 14:53:08 +02:00
2025-10-09 14:53:08 +02:00
2026-02-27 16:50:56 +00:00
2026-02-24 15:27:03 +00:00
2026-03-16 15:30:25 -05:00
2024-07-29 19:58:48 -05:00
2026-03-17 01:24:03 +01:00
2026-03-17 01:24:03 +01:00
2025-06-24 13:06:02 +02:00
2026-01-08 15:24:11 +04:00
2026-03-04 21:57:23 -05:00
2025-09-15 12:30:17 +10:00
2025-07-30 13:42:39 -07:00
2024-11-15 12:05:21 -06:00
2025-08-29 10:41:32 +02:00
2025-04-15 10:55:30 +02:00
2026-03-13 14:09:39 +00:00
2025-06-20 13:16:55 -06:00
2026-02-20 09:01:00 -06:00
2026-03-13 20:37:41 -07:00
2025-12-15 17:41:47 +00:00
2024-01-31 14:49:55 +01:00
2025-02-18 13:06:19 +01:00
2025-07-07 11:01:17 -06:00
2025-01-31 12:14:24 -07:00
2025-03-31 09:40:24 -03:00
2025-08-19 10:41:33 +02:00
2026-03-04 12:54:39 +02:00
2026-02-20 12:56:00 +11:00
2025-06-20 13:16:55 -06:00
2026-01-09 15:40:26 -07:00
2026-03-06 10:48:58 +00:00
2026-01-15 12:41:28 +03:00
2026-02-23 12:18:44 +01:00
2025-10-06 13:58:37 +02:00
2025-06-20 13:16:55 -06:00
2023-01-13 12:27:21 +01:00
2026-02-03 14:10:49 -06:00
2025-07-02 15:05:42 +00:00
2025-07-28 15:02:26 +01:00
2026-03-02 19:32:36 +11:00
2026-02-27 16:50:56 +00:00
2025-02-27 06:23:18 -05:00
2023-01-29 15:47:24 -06:00
2025-05-29 08:55:19 -05:00
2025-06-20 13:16:55 -06:00
2026-02-03 14:10:49 -06:00
2025-10-27 17:14:16 -06:00
2025-09-26 11:43:32 +02:00
2024-02-14 17:14:49 +00:00
2026-02-13 19:44:50 -05:00
2024-07-24 14:11:29 +10:00
2026-01-08 15:24:11 +04:00
2025-08-19 10:41:33 +02:00
2025-06-20 13:16:55 -06:00
2022-08-25 19:10:42 +03:00
2023-01-29 15:47:24 -06:00
2024-09-10 20:55:50 +10:00
2026-03-11 10:19:08 -07:00
2024-12-19 00:51:30 +04:00
2024-12-19 00:51:30 +04:00
2025-06-16 16:15:59 -06:00
2026-02-06 15:52:54 +00:00
2026-03-06 10:47:55 +01:00
2025-09-10 11:01:54 -05:00
2026-02-17 15:11:04 +00:00
2025-06-20 13:16:55 -06:00
2022-11-08 17:12:06 +00:00
2026-01-08 15:24:11 +04:00
2026-03-13 20:37:41 -07:00
2026-03-04 11:14:52 -07:00