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 tomaxAiCredits 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.
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 withhandlePendingSessionLimitsExhausted(). Set action to a SessionLimitsExhaustedResponseAction case.
Add: Adds the given AI credits to the current limit. SetadditionalAiCredits.Set: Changes the limit to a new absolute value. SetmaxAiCredits.Unset: Removes the session limit.Cancel: Cancels the blocked model request without changing the limit.