Skip to content

Commit 377448a

Browse files
am-steadhubwriter
andauthored
[2026-06-29] Copilot AI credit response budgets [GA] #23130 (#61902)
Co-authored-by: hubwriter <hubwriter@github.com>
1 parent 0cf5d14 commit 377448a

7 files changed

Lines changed: 102 additions & 3 deletions

File tree

content/copilot/concepts/billing/usage-based-billing-for-individuals.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ More complex interactions consume more of your usage allowance. The main factors
8181

8282
> [!NOTE] {% data reusables.copilot.auto-model-discount %}
8383
84+
For guidance on how to optimize your usage and reduce spend, including how to set session limits to cap spend for agent tasks, see [AUTOTITLE](/copilot/tutorials/optimize-ai-usage).
85+
8486
## What happens if I exceed my included {% data variables.product.prodname_ai_credits_short %}?
8587

8688
When your {% data variables.product.prodname_ai_credits_short %} are exhausted, you can:

content/copilot/how-tos/copilot-cli/cli-best-practices.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ You can configure {% data variables.copilot.copilot_cli_short %} to use your own
124124

125125
See [Using your own model provider](/copilot/concepts/agents/copilot-cli/about-copilot-cli#using-your-own-model-provider).
126126

127+
### Set {% data variables.product.prodname_ai_credit_singular %} session limits
128+
129+
You can cap the amount of {% data variables.product.prodname_ai_credits_short %} that {% data variables.product.prodname_copilot_short %} can spend on a single session so that long-running or complex tasks don't consume more resources than you expect. See [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli/set-session-limit).
130+
131+
For more information on how to optimize your {% data variables.product.prodname_ai_credits_short %} usage generally, see [AUTOTITLE](/copilot/tutorials/optimize-ai-usage).
132+
127133
## 2. Plan before you code
128134

129135
### Plan mode

content/copilot/how-tos/copilot-cli/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ children:
7676
- /use-copilot-cli/speed-up-task-completion
7777
- /use-copilot-cli/steer-agents
7878
- /use-copilot-cli/steer-remotely
79+
- /use-copilot-cli/set-session-limit
7980
carousels:
8081
recommended:
8182
- /copilot/how-tos/copilot-cli/use-copilot-cli/overview

content/copilot/how-tos/copilot-cli/use-copilot-cli/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ children:
1717
- /invoke-custom-agents
1818
- /steer-agents
1919
- /steer-remotely
20+
- /set-session-limit
2021
- /agentic-code-review
2122
- /manage-pull-requests
2223
- /speed-up-task-completion
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Setting an {% data variables.product.prodname_ai_credit_singular %} session limit in {% data variables.copilot.copilot_cli %}
3+
shortTitle: Set an {% data variables.product.prodname_ai_credit_singular %} limit
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Limit the amount of {% data variables.product.prodname_ai_credits_short %} {% data variables.product.prodname_copilot_short %} can spend on a session to control costs and keep tasks predictable.'
6+
versions:
7+
feature: copilot
8+
contentType: how-tos
9+
category:
10+
- Build with Copilot CLI
11+
docsTeamMetrics:
12+
- copilot-cli
13+
---
14+
15+
> [!NOTE]
16+
> {% data variables.product.prodname_ai_credit_singular %} session limits are currently in {% data variables.release-phases.public_preview %} and subject to change.
17+
18+
An {% data variables.product.prodname_ai_credit_singular %} session limit caps the amount of {% data variables.product.prodname_ai_credits %} that {% data variables.product.prodname_copilot_short %} can spend in a session.
19+
20+
{% data variables.product.prodname_ai_credits_short %} are the unit {% data variables.product.prodname_copilot_short %} uses to track the cost of AI model interactions: each credit equals {% data variables.product.prodname_ai_credits_value %}, and usage depends on the model and the number of tokens consumed.
21+
22+
When you set an {% data variables.product.prodname_ai_credit_singular %} session limit for {% data variables.product.prodname_copilot_short %}, instead of running until the task is done or until you intervene, {% data variables.product.prodname_copilot_short %} stops when it hits the limit and gives you the option to reset or adjust it.
23+
24+
These session limits are **soft limits**. If a response is in progress when the limit is reached, that response completes before the session stops, so actual usage may slightly exceed the configured number.
25+
26+
## Setting an {% data variables.product.prodname_ai_credit_singular %} session limit
27+
28+
How the limit is set and applied depends on whether you are in an interactive session or running the CLI programmatically.
29+
30+
> [!TIP]
31+
> {% data variables.product.prodname_ai_credit_singular %} session limits work best when set to > 30 {% data variables.product.prodname_ai_credits_short %} as most model calls will cost more than 20 {% data variables.product.prodname_ai_credits_short %}.
32+
33+
### Setting a limit within an interactive session
34+
35+
In an interactive CLI session, the limit applies for the entire session and depletes as each message is processed, independent of how many messages you send. When the limit is reached, you are prompted to reset it.
36+
37+
To set your session limit, use `/limits set`.
38+
39+
```copilot copy
40+
/limits set max-ai-credits NUMBER
41+
```
42+
43+
To remove the limit, enter:
44+
45+
```copilot copy
46+
/limits unset
47+
```
48+
49+
### Setting a limit in non-interactive mode
50+
51+
When you run {% data variables.copilot.copilot_cli_short %} programmatically from the command line, the limit applies for the duration of {% data variables.product.prodname_copilot_short %}'s work on the task and remains active until {% data variables.product.prodname_copilot_short %} finishes responding.
52+
53+
To set a limit, pass `--max-ai-credits=NUMBER`.
54+
55+
```bash copy
56+
copilot -p "YOUR PROMPT" --max-ai-credits NUMBER
57+
```
58+
59+
## What happens when the limit is reached
60+
61+
When the limit is hit, the agent stops cleanly and lets you know.
62+
63+
* **In interactive mode**, you are prompted to reset the limit. You can use `/limits set` to raise the limit and continue your session from where the agent stopped.
64+
* **In non-interactive mode**, the run ends when the limit is reached.
65+
66+
## Further reading
67+
68+
* [AUTOTITLE](/copilot/tutorials/optimize-ai-usage)
69+
* [What are {% data variables.product.prodname_ai_credits %}](/copilot/concepts/billing/usage-based-billing-for-individuals#what-are--data-variablesproductprodname_ai_credits-)

content/copilot/how-tos/manage-and-track-spending/monitor-ai-usage.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ You can access usage information in the following IDEs.
4949
* **In JetBrains IDEs**, click the {% data variables.product.prodname_copilot_short %} icon ({% octicon "copilot" aria-hidden="true" aria-label="copilot" %}) in the status bar, then select **View quota usage**.
5050
* **In Xcode**, click the {% data variables.product.prodname_copilot_short %} icon ({% octicon "copilot" aria-hidden="true" aria-label="copilot" %}) in the menu bar.
5151
* **In Eclipse**, click the {% data variables.product.prodname_copilot_short %} icon ({% octicon "copilot" aria-hidden="true" aria-label="copilot" %}) in the status bar at the bottom of Eclipse.
52+
53+
## Next steps
54+
55+
* For guidance on how to optimize your usage and reduce spend, including how to set session limits to cap spend for agent tasks, see [AUTOTITLE](/copilot/tutorials/optimize-ai-usage).
56+
* To set up a personal budget for your overall consumption of {% data variables.product.prodname_ai_credits %}, see [AUTOTITLE](/billing/how-tos/set-up-budgets#managing-budgets-for-your-personal-account).

content/copilot/tutorials/optimize-ai-usage.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,22 @@ However, the following actions invalidate the cache, causing the full context to
110110
* **Coming back to an old session**. Caches expire after a period of inactivity (24 hours for OpenAI models and 1 hour for most others). If you've been away a while, start a new session, or run `/compact` (in {% data variables.copilot.copilot_cli_short %}) so what gets rebuilt is a short summary rather than the full history.
111111
* **Changing reasoning mid-session**. Changing the reasoning effort level, context size, or the set of enabled tools and MCP servers during a session invalidates the cache. Configure these settings before you start and leave them unchanged for the session.
112112

113-
## 5. Research, plan, then implement
113+
## 5. Set {% data variables.product.prodname_ai_credit_singular %} session limits
114+
115+
An {% data variables.product.prodname_ai_credit_singular %} session limit caps the amount of work {% data variables.product.prodname_copilot_short %} performs on a single session.
116+
117+
In {% data variables.copilot.copilot_cli_short %} and {% data variables.copilot.copilot_sdk_short %}, you can set a session limit before initiating a task and when the limit is reached, the agent stops cleanly, notifies you, and lets you choose whether to continue or raise the limit.
118+
119+
{% data variables.product.prodname_ai_credit_singular %} session limits are most useful when:
120+
121+
* You want to cap {% data variables.product.prodname_ai_credits_short %} usage on a single session to avoid unexpected costs.
122+
* You're tuning agent efficiency and want to find the minimum {% data variables.product.prodname_ai_credits_short %} that still produces a good result.
123+
124+
Session limits are soft limits that help you control how many {% data variables.product.prodname_ai_credits_short %} any single task consumes, but they don't replace user-level budgets or spending limits, which govern your overall monthly consumption. For those controls, see [AUTOTITLE](/copilot/concepts/billing/budgets-for-usage-based-billing).
125+
126+
For information on how to set a session limit in {% data variables.copilot.copilot_cli_short %}, see [AUTOTITLE](/copilot/how-tos/copilot-cli/use-copilot-cli/set-session-limit).
127+
128+
## 6. Research, plan, then implement
114129

115130
One of the biggest shifts in working effectively with agents is moving away from doing everything in a single session. When research, planning, and implementation all happen together, context grows quickly and irrelevant information accumulates.
116131

@@ -124,7 +139,7 @@ Break work into clear phases:
124139

125140
Starting a new session between phases prevents you from carrying unnecessary context forward, which can increase token usage and reduce clarity for the agent. Each phase should operate with only what it needs. For guidance on scoping sessions effectively, see [AUTOTITLE](/copilot/tutorials/cloud-agent/get-the-best-results).
126141

127-
## 6. Utilize learnings to be more efficient at every turn
142+
## 7. Utilize learnings to be more efficient at every turn
128143

129144
### Use `/chronicle` to generate insights
130145

@@ -164,7 +179,7 @@ Persistent instructions improve consistency across agent interactions, but their
164179

165180
Keep instructions updated as your codebase, architecture, standards, and workflows evolve. Because these instructions are included in the agent's context on every run, even small improvements can reduce repeated errors and lower wasted token usage over time.
166181

167-
## 7. Add deterministic guardrails
182+
## 8. Add deterministic guardrails
168183

169184
Agents are non-deterministic and won't be correct every time, especially in multi-step workflows. Without guardrails, small errors can compound quickly: agents build on incorrect outputs, drift further from the goal, and make debugging more expensive and time-consuming.
170185

0 commit comments

Comments
 (0)