fix: report combined member limit in group AI spend (#27589)

## Problem

The organization groups page showed each group's AI budget as the
group's per-member limit, so the total it displayed was effectively
group members × group budget. That ignores per-user budget overrides
charged to the group, so a group where one member has an override
reported a limit that doesn't match what its members can actually spend.

## Changes

- Add `total_spend_limit_micros` to the organization groups AI spend
payload, the combined budget of the members attributed to the group,
with each member's override replacing their share.
- Return `null` for the total when the group has no budget, since its
members spend without a cap.
- Both the organization groups and single group spend endpoints report
the new field, as they share the same query.
- Use the total as the denominator on the groups page AI budget column.

Depends on #27568
This commit is contained in:
Susana Ferreira
2026-07-29 09:16:37 +01:00
committed by GitHub
parent e96d8646e2
commit 0b4095085e
14 changed files with 705 additions and 177 deletions
+12 -4
View File
@@ -20754,7 +20754,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"current_spend_micros": {
"description": "CurrentSpendMicros is the group's spend over the current budget\nperiod.",
"description": "CurrentSpendMicros is the group's spend over the current budget period.",
"type": "integer"
},
"group_id": {
@@ -20772,7 +20772,11 @@ const docTemplate = `{
"format": "date-time"
},
"spend_limit_micros": {
"description": "SpendLimitMicros is the group's configured AI spend limit. Null when\nthe group has no configured budget.",
"description": "SpendLimitMicros is the group's configured AI spend budget per member.\nNull when the group has no configured budget.",
"type": "integer"
},
"total_spend_limit_micros": {
"description": "TotalSpendLimitMicros is the currently configured combined budget of the\nmembers attributed to this group, with each member's override replacing\ntheir share. Null when the group has no budget, and zero when no members\nare attributed to it.",
"type": "integer"
}
}
@@ -22260,7 +22264,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"current_spend_micros": {
"description": "CurrentSpendMicros is the group's spend over the current budget\nperiod.",
"description": "CurrentSpendMicros is the group's spend over the current budget period.",
"type": "integer"
},
"group_id": {
@@ -22268,7 +22272,11 @@ const docTemplate = `{
"format": "uuid"
},
"spend_limit_micros": {
"description": "SpendLimitMicros is the group's configured AI spend limit. Null when\nthe group has no configured budget.",
"description": "SpendLimitMicros is the group's configured AI spend budget per member.\nNull when the group has no configured budget.",
"type": "integer"
},
"total_spend_limit_micros": {
"description": "TotalSpendLimitMicros is the currently configured combined budget of the\nmembers attributed to this group, with each member's override replacing\ntheir share. Null when the group has no budget, and zero when no members\nare attributed to it.",
"type": "integer"
}
}
+12 -4
View File
@@ -18888,7 +18888,7 @@
"type": "object",
"properties": {
"current_spend_micros": {
"description": "CurrentSpendMicros is the group's spend over the current budget\nperiod.",
"description": "CurrentSpendMicros is the group's spend over the current budget period.",
"type": "integer"
},
"group_id": {
@@ -18906,7 +18906,11 @@
"format": "date-time"
},
"spend_limit_micros": {
"description": "SpendLimitMicros is the group's configured AI spend limit. Null when\nthe group has no configured budget.",
"description": "SpendLimitMicros is the group's configured AI spend budget per member.\nNull when the group has no configured budget.",
"type": "integer"
},
"total_spend_limit_micros": {
"description": "TotalSpendLimitMicros is the currently configured combined budget of the\nmembers attributed to this group, with each member's override replacing\ntheir share. Null when the group has no budget, and zero when no members\nare attributed to it.",
"type": "integer"
}
}
@@ -20316,7 +20320,7 @@
"type": "object",
"properties": {
"current_spend_micros": {
"description": "CurrentSpendMicros is the group's spend over the current budget\nperiod.",
"description": "CurrentSpendMicros is the group's spend over the current budget period.",
"type": "integer"
},
"group_id": {
@@ -20324,7 +20328,11 @@
"format": "uuid"
},
"spend_limit_micros": {
"description": "SpendLimitMicros is the group's configured AI spend limit. Null when\nthe group has no configured budget.",
"description": "SpendLimitMicros is the group's configured AI spend budget per member.\nNull when the group has no configured budget.",
"type": "integer"
},
"total_spend_limit_micros": {
"description": "TotalSpendLimitMicros is the currently configured combined budget of the\nmembers attributed to this group, with each member's override replacing\ntheir share. Null when the group has no budget, and zero when no members\nare attributed to it.",
"type": "integer"
}
}