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-16 15:41:32 +00:00
2026-03-17 01:24:03 +01:00
2026-03-04 17:47:34 +00:00
2026-03-11 10:19:08 -07:00
2026-03-17 01:24:03 +01:00
2026-03-17 01:24:03 +01:00
2026-01-21 11:27:01 +11:00
2026-01-08 15:24:11 +04:00
2026-01-08 15:24:11 +04:00
2026-03-05 11:58:10 +00:00
2026-02-23 22:46:17 -06:00
2026-03-17 01:24:03 +01:00
2026-03-03 10:19:00 -05:00
2026-03-17 01:24:03 +01:00
2026-02-03 17:52:07 +00:00
2026-03-17 01:24:03 +01:00
2025-06-20 17:36:32 +01:00
2025-10-23 14:24:54 +02:00
2026-02-12 09:06:33 +00:00
2026-03-17 01:24:03 +01:00
2025-08-07 11:00:31 +10:00
2026-03-16 11:53:20 -05:00
2026-03-05 22:32:18 +02:00
2026-02-06 09:52:17 -07:00
2025-12-09 08:13:09 -08:00
2026-03-11 10:19:08 -07:00
2025-11-25 11:13:32 +00:00
2026-03-17 01:24:03 +01:00
2026-03-17 01:24:03 +01:00
2025-07-09 09:46:31 +02:00
2026-03-16 15:30:25 -05:00
2026-03-17 01:24:03 +01:00
2026-03-17 01:24:03 +01:00
2026-03-13 18:30:49 +01:00
2025-12-15 08:42:08 -08:00
2026-03-17 01:24:03 +01:00