Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a300a06

Browse files
authored
fix: correct native usage-limit docs and spend UI details for 2.36 (#27827)
Follow-up to #27825. Native chat usage-limit enforcement was already removed from `release/2.36` by #27599 (`checkUsageLimit` is a no-op), but the docs added in #27825 claimed stored native values are still enforced per message with a 409 response. This corrects the docs and folds in small spend UI fixes found during UAT. ## Docs - State that native limits are no longer configurable or enforced as of release 2.36, stored values are inert and not migrated, and AI Gateway budgets are the only enforcement mechanism (`usage-insights.md`, `platform-controls/index.md`, `cost-controls.md`). - Restore the warning that spend limits previously configured under Admin settings > AI > Spend are no longer enforced. - Drop the migration bullet claiming users can be subject to both native limits and budgets. - Restore the note that automatic title generation is not included in usage reporting. ## Frontend - Render the group members page AI spend reset date in UTC via a shared `formatSpendResetLabel` helper, matching the budget period formatting elsewhere. Non-UTC viewers previously saw two different dates for one period. - Pin a non-UTC timezone in `budget.test.ts` so CI fails if formatting falls back to local time (verified red under the old implementation). - Restore the title-generation note on the cost summary, reworded for usage reporting. > Mux prepared this PR on Mike's behalf.
1 parent 17773d3 commit a300a06

7 files changed

Lines changed: 55 additions & 25 deletions

File tree

docs/ai-coder/agents/platform-controls/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@ none, if the template does not define any).
116116

117117
### Spend management
118118

119-
The Spend page provides usage-only reporting for Coder Agents chats. The native
120-
usage-limit configuration UI has been removed from release 2.36, but values
121-
configured before upgrading remain stored and enforced. Existing native values
122-
are not migrated to AI Gateway budgets.
119+
The Spend page provides usage-only reporting for Coder Agents chats. As of
120+
release 2.36, native chat usage limits are no longer configurable or enforced.
121+
Values configured before upgrading remain stored, have no effect, and are not
122+
migrated to AI Gateway budgets. AI Gateway budgets are the only way to limit
123+
spend.
123124

124125
Configure new AI Gateway budgets from group settings or through the generated
125126
group budget API. See [Spend Management](./usage-insights.md) for details.

docs/ai-coder/agents/platform-controls/usage-insights.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
# Spend Management
22

3-
Coder provides usage reporting for Coder Agents and two independent ways to
4-
limit spend on release 2.36: existing native chat usage limits and AI Gateway
5-
budgets.
3+
Coder provides usage reporting for Coder Agents and enforces spend through AI
4+
Gateway budgets on release 2.36.
65

76
## Native chat usage limits
87

9-
The native usage-limit configuration UI has been removed from release 2.36.
10-
Values configured before upgrading remain stored and enforced. Coder checks the
11-
user's current spend before processing each chat message and returns a **409
12-
Conflict** response when the applicable limit is reached.
8+
As of release 2.36, native chat usage limits are no longer configurable or
9+
enforced. Coder does not check previously configured values when processing
10+
chat messages. Values configured before upgrading remain stored, have no
11+
effect, and are not migrated to AI Gateway budgets.
1312

14-
Existing native values are not migrated to AI Gateway budgets. To change spend
15-
controls after upgrading, configure new AI Gateway budgets. Native limits remain
16-
in effect until they are changed through the existing experimental API or
17-
removed in a later release.
13+
To limit spend, configure AI Gateway budgets. They are the only enforcement
14+
mechanism.
1815

1916
## AI Gateway budgets
2017

@@ -49,3 +46,7 @@ for each user. It supports date range filtering, search, and pagination.
4946

5047
Select a user to view summary cards and per-model and per-chat breakdowns. The
5148
Spend page does not configure native usage limits or AI Gateway budgets.
49+
50+
> [!NOTE]
51+
> Automatic title generation uses lightweight models. Its token usage is not
52+
> included in usage reporting.

docs/ai-coder/ai-gateway/cost-controls.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,15 @@ see [Prometheus metrics](../../admin/integrations/prometheus.md).
270270

271271
## Migrate from Coder Agents Cost Control
272272

273-
In release 2.36, the native Coder Agents usage-limit configuration UI is no
274-
longer available. Existing native values remain stored and enforced, and are not
273+
In release 2.36, native Coder Agents usage limits are no longer configurable
274+
or enforced. Existing native values remain stored, have no effect, and are not
275275
migrated to AI Gateway budgets.
276276

277+
> [!WARNING]
278+
> Spend limits previously configured under **Admin settings** > **AI** >
279+
> **Spend** are no longer enforced by Coder Agents. To enforce spend, set an
280+
> AI Gateway budget.
281+
277282
Configure new AI Gateway budgets from the group settings page or use the API to
278283
[get](../../reference/api/enterprise.md#get-group-ai-budget),
279284
[upsert](../../reference/api/enterprise.md#upsert-group-ai-budget), or
@@ -282,14 +287,12 @@ budget.
282287

283288
Expect the following differences:
284289

285-
- Native limits and AI Gateway budgets are independent. A user can be subject to
286-
both until native limits are removed in a later release.
287290
- AI Gateway has no deployment-wide default budget. Each group that needs a
288291
limit requires its own budget.
289292
- The UTC calendar month is the only budget period. Daily and weekly periods are
290293
not currently supported.
291294
- Users in several budgeted groups receive the highest budget by default. Native
292-
Coder Agents usage limits apply the lowest group limit.
295+
Coder Agents usage limits applied the lowest group limit.
293296
- Budgets cover priced AI Gateway traffic. Chat, IDE extensions, and CLI agents
294297
draw on the same budget when their provider and model are priced. See
295298
[How spend is estimated](#how-spend-is-estimated).

site/src/pages/AISettingsPage/SpendPage/components/ChatCostSummaryView.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TriangleAlertIcon } from "lucide-react";
1+
import { InfoIcon, TriangleAlertIcon } from "lucide-react";
22
import { type FC, useState } from "react";
33
import { getErrorMessage } from "#/api/errors";
44
import type * as TypesGen from "#/api/typesGenerated";
@@ -158,6 +158,14 @@ export const ChatCostSummaryView: FC<ChatCostSummaryViewProps> = ({
158158
</div>
159159
)}
160160

161+
<div className="flex items-start gap-3 p-4 text-sm text-content-secondary">
162+
<InfoIcon className="size-5 shrink-0" />
163+
<span>
164+
Automatic title generation uses lightweight models and is not included
165+
in usage reporting.
166+
</span>
167+
</div>
168+
161169
{summary.by_model.length === 0 && summary.by_chat.length === 0 ? (
162170
<p className="py-12 text-center text-content-secondary">
163171
{emptyMessage}

site/src/pages/GroupsPage/GroupMembersPage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import dayjs from "dayjs";
21
import { EllipsisVerticalIcon, UserPlusIcon } from "lucide-react";
32
import { type FC, useEffect, useState } from "react";
43
import { useMutation, useQuery, useQueryClient } from "react-query";
@@ -50,6 +49,7 @@ import {
5049
import { useAuthenticated } from "#/hooks/useAuthenticated";
5150
import { useFeatureVisibility } from "#/modules/dashboard/useFeatureVisibility";
5251
import { isEveryoneGroup } from "#/modules/groups";
52+
import { formatSpendResetLabel } from "#/utils/budget";
5353
import { cn } from "#/utils/cn";
5454
import { formatBudgetUSD } from "#/utils/currency";
5555
import { SpendEstimateDocsLink } from "./AICostControl";
@@ -114,9 +114,7 @@ const GroupMembersPage: FC = () => {
114114
);
115115
const aiBudgetNote = [
116116
"Estimated monthly AI spend for this user.",
117-
// Spend resets at period_end, rendered in the viewer's local time.
118-
aiSpend &&
119-
`Resets ${dayjs(aiSpend.period_end).format("MMM D, YYYY h:mm A")}.`,
117+
aiSpend && `Resets ${formatSpendResetLabel(aiSpend.period_end)}.`,
120118
// A $0 default still shows: it means no spending allowance.
121119
groupBudget &&
122120
`The group's default limit is ${formatBudgetUSD(groupBudget.spend_limit_micros)} per member.`,

site/src/utils/budget.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ import { describe, expect, it } from "vitest";
22
import {
33
clampPercentage,
44
formatSpendPeriodLabel,
5+
formatSpendResetLabel,
56
getSeverity,
67
usageProgressPercentage,
78
} from "./budget";
89

10+
// Pin a non-UTC zone so the UTC assertions fail if formatting falls back
11+
// to local time. Under UTC runners both implementations agree.
12+
process.env.TZ = "America/Los_Angeles";
13+
914
describe("formatSpendPeriodLabel", () => {
1015
it("renders API timestamps in UTC with the year on the exclusive end", () => {
1116
expect(
@@ -20,6 +25,12 @@ describe("formatSpendPeriodLabel", () => {
2025
});
2126
});
2227

28+
describe("formatSpendResetLabel", () => {
29+
it("renders the exclusive period_end in UTC", () => {
30+
expect(formatSpendResetLabel("2026-08-01T00:00:00Z")).toBe("Aug 1, 2026");
31+
});
32+
});
33+
2334
describe("getSeverity", () => {
2435
it("returns normal below the warning threshold", () => {
2536
expect(getSeverity(0, 50)).toBe("normal");

site/src/utils/budget.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ export function formatSpendPeriodLabel(
1818
return `${start} - ${end}`;
1919
}
2020

21+
/**
22+
* Formats an AI budget window's exclusive period_end in UTC, e.g.
23+
* "Aug 1, 2026", matching formatSpendPeriodLabel's convention.
24+
*/
25+
export function formatSpendResetLabel(periodEnd: string): string {
26+
return dayjs.utc(periodEnd).format("MMM D, YYYY");
27+
}
28+
2129
/**
2230
* Classifies usage against a budget. Returns "warning" once usage reaches 85%
2331
* of the budget and "exceeded" once it meets or passes the budget. A budget of

0 commit comments

Comments
 (0)