Skip to main content
Use sessionLimits to set a soft AI credit limit for the current accounting window of a Copilot session. You can set it both when creating and when resuming a session.

Set a limit

Pass the limit to maxAiCredits on SessionLimitsConfig. Usage is checked after each model call completes, so a single response can exceed the configured value. Once the limit is exceeded, the runtime blocks the next model call.
Both SessionConfig and ResumeSessionConfig accept sessionLimits as either a SessionLimitsConfig instance or an array.

Limit events

Listen to session events to react to limit changes and to prompt the user when the limit is reached. For example, when you receive SESSION_LIMITS_EXHAUSTED_REQUESTED, use the event data to show a confirmation UI.

Respond to an exhausted limit

Send the user’s choice back to the runtime with handlePendingSessionLimitsExhausted(). Set action to a SessionLimitsExhaustedResponseAction case.
The available actions are:
  • Add: Adds the given AI credits to the current limit. Set additionalAiCredits.
  • Set: Changes the limit to a new absolute value. Set maxAiCredits.
  • Unset: Removes the session limit.
  • Cancel: Cancels the blocked model request without changing the limit.
The exhausted-limit prompt flow using session_limits_exhausted.requested and session_limits_exhausted.completed, and the related response API, are experimental. They may change or be removed in the future.
Last modified on October 26, 2026