Cap GitHub Copilot CLI agent spend with AI credit session limits
GitHub Copilot CLI and the Copilot SDK now support per-session AI credit limits, giving developers a practical guardrail for long-running agent tasks and unattended automation.
What you get from it
What it does
GitHub added AI credit session limits for Copilot CLI and the Copilot SDK. The practical value is simple: before you hand an agent a long task, you can set a credit cap so the session stops cleanly instead of running until the work is done or someone notices the bill.
This belongs in a developer's automation checklist because AI coding agents are increasingly used for unattended refactors, test runs, investigations, and SDK-driven workflows. A per-session cap does not replace account budgets, but it gives each run a local spending boundary.
How to try it
Update GitHub Copilot CLI to version 1.0.66 or later, then use the new session-limit controls before starting work.
For interactive CLI sessions, GitHub's docs show the /limits set command:
/limits set max-ai-credits NUMBER
For non-interactive CLI jobs, pass a maximum credit value on the command line:
copilot -p "YOUR PROMPT" --max-ai-credits NUMBER
GitHub notes that the limit is a soft cap: a model response already in progress can finish, so final usage may slightly exceed the number you set. Their docs also advise that session limits work best above 30 AI credits because many model calls can cost more than 20 credits.
Best use cases
- Budgeting unattended Copilot CLI jobs in CI-like local automation.
- Running exploratory codebase tasks without leaving an agent unbounded.
- Testing prompt cost before scaling a workflow across a team.
- Giving SDK-based agent features a per-run guardrail.
Caveats
This is a public preview feature, so behavior may change. It also controls a single session only; teams still need organization budgets, billing alerts, model-selection policies, and human review for expensive agent workflows.
Treat the first few runs as calibration. Start with small, reversible tasks, check actual AI credit use afterward, and adjust the limit based on prompt size, repository size, selected model, and tool-call depth.
Source links
- GitHub Changelog: https://github.blog/changelog/2026-07-01-set-ai-credit-session-limits-in-copilot-cli-and-sdk/
- GitHub Docs: https://docs.github.com/en/copilot/tutorials/optimize-ai-usage
- GitHub CLI best practices: https://docs.github.com/copilot/how-tos/copilot-cli/cli-best-practices
- Session limit setup docs: https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/set-session-limit
Discussion
Share practical experience, questions, or warnings with the community.
Sign in to join the discussion and vote on comments.
Sign in