Copilot CLI and the Copilot SDK can now stop a session after a configured AI credit budget. Use that as a per-task control for unattended agent work, not as a replacement for permissions or monthly spending limits.
Scope One Task First
Session limits cover model calls, subagents, and background work across one session. Update to Copilot CLI 1.0.66+ or SDK 1.0.5+, then name the repository, task, and expected artifact before choosing a number.
Choose The Right Entry Point
- Interactive CLI: `/limits set max-ai-credits NUMBER`.
- Noninteractive CLI: `copilot -p "YOUR PROMPT" --max-ai-credits NUMBER`.
- SDK: pass `sessionLimits.maxAiCredits` when creating or resuming the session.
Expect Soft-cap Overshoot
Usage is checked after a response returns, so an in-flight response can push actual usage above the configured number. Treat the value as a stop checkpoint, not a hard currency ceiling.
Make Exhaustion Observable
Preserve the session ID, partial artifact, test output, configured limit, and used credits. SDK hosts should subscribe to usage and exhaustion events, then require an explicit continue, add-credits, or stop decision.
Keep Monthly Budgets Separate
Per-session limits complement user and organization budgets; they do not replace them. Repeated exhaustion should trigger a review of task scope, context, model, tools, and retries instead of an automatic budget reset.
Know When To Skip
Skip this as the primary control when you need organization-wide billing governance, run an unsupported client, or have not yet defined permissions and rollback. The feature is in public preview, and Copilot CLI uses its own GitHub license terms.
Sources
- GitHub·Official doc·Core sourceGitHub Changelog: Set AI credit session limits in Copilot CLI and SDK
- GitHub·Official doc·Core sourceGitHub Docs: Setting an AI credit session limit in Copilot CLI
- GitHub·Official doc·Core sourceGitHub Docs: Copilot SDK session limits
- GitHub·Official doc·Supporting sourceGitHub Docs: Optimize AI usage
- GitHub·Official doc·Supporting sourceGitHub repository: github/copilot-cli
- GitHub·Official doc·Supporting sourceGitHub Copilot CLI License
