What should happen when a customer-facing AI hits its token budget mid-conversation
Budget exhaustion behavior should be set by an explicit runtime policy, not left to application defaults. The policy should choose among graceful completion, context compaction, model downgrade, human handoff, or controlled termination based on conversation state and risk. It should be enforced in a gateway or runtime control layer outside prompt logic, and every exhaustion event should produce an audit record.
Four limits that fail in different ways
A token budget is not a single threshold. The policy needs to identify which limit was reached, because each one can interrupt a conversation at a different point and in a different way. The four limit types covered in this guide are:
- Context window: the limit on what the model can hold in a single conversation.
- Output cap: the limit on how much a single response can contain.
- Session budget: the allowance assigned to one conversation.
- Tenant budget: the allowance assigned across a tenant.
Exhaustion behaviors to choose among
When a limit is reached, the runtime policy should choose one of five behaviors rather than falling back to application defaults:
- Graceful completion: let the current response finish.
- Context compaction: reduce the context so the conversation can continue.
- Model downgrade: reroute the conversation to a different model.
- Human handoff: transfer the conversation to a person.
- Controlled termination: end the conversation deliberately, with a message to the customer.
Each behavior carries different consequences for the customer and for the business, so the choice should be defined in advance, not discovered in production.
Match the behavior to conversation state and risk
The right behavior depends on what the conversation is doing at the moment the limit is reached. The policy should classify the conversation into one of these states:
- Idle: no response is in progress.
- Mid-answer: a response is being generated.
- Mid-tool-call: a tool call is in progress.
- Mid-transaction: a transaction is partially complete.
The policy then applies the action that fits the state and risk level, independent of the prompt. This mapping should be defined for each combination of limit type and conversation state.
Exhaustion policy decision path
Every exhaustion event should follow the same four-stage path, from detection to record.
| Stage | Description |
|---|---|
| Detect | Identify which limit was reached: context window, output cap, session, or tenant budget. |
| Classify | Determine conversation state: idle, mid-answer, mid-tool-call, or mid-transaction. |
| Decide | Apply the policy action that fits the state and risk level. |
| Record | Log the trigger, action, and transaction status for later review. |
Where enforcement belongs
Enforcement should sit in a gateway or runtime control layer, outside prompt logic. A typical enforcement sequence has five steps:
- Pre-request checkEstimate token needs and compare them with remaining context, session, user, and tenant budgets.
- In-flight accountingTrack actual consumption, including tool output, so state stays current.
- Policy decisionMap limit type, conversation state, and risk to an action, independent of the prompt.
- Action executionRun compaction, rerouting, handoff, or termination, and deliver the customer message.
- Event emissionWrite a structured record and alert operators when policy dictates.
Logging and audit requirements to specify
Every exhaustion event should produce an audit record. At a minimum, specify that the record includes:
- Trigger: the limit type, its configured value, and the usage at the time
- Conversation state and the policy version that was applied
- Action taken, such as completion, compaction, downgrade, handoff, or termination
- Tool-call and transaction status at the moment of exhaustion, including anything left unresolved
- Context changes: what was compacted or dropped, and whether the instruction integrity check passed
- The message shown to the customer and the notification sent to operators, in an exportable format
Evaluating runtime governance controls
Whether you build this layer or buy one, evaluate it against the requirements above. Questions to ask:
- Which limit types does it detect, and how?
- Can exhaustion behavior be configured by conversation state without touching prompts?
- Do protected instructions survive compaction?
- How are partially completed tool calls and transactions handled, who is notified, and what is recorded and exportable?
Test these paths directly, including a limit reached mid-tool-call, rather than relying on documentation alone.