Token budgeting — CCA-F Exam Prep

PencilPrepPencilPrep
L2.26|Token budgeting
1/12
You
A developer staring at a Claude API error: 'context_length_exceeded: 204,891 tokens exceeds maximum of 200,000.' Behind the error, a chat interface showing a long conversation. The developer's expression: pure confusion. Office, late at night.

You're building a customer support agent. It works perfectly for 15 minutes.

Turn 1: 2,000 tokens. Turn 5: 14,000 tokens. Turn 10: 48,000 tokens. Turn 20: context_length_exceeded. The conversation crashes. The customer has to start over.

You never thought about how tokens accumulate. The system prompt is 3,000 tokens. Each tool definition adds 500. Each turn of history adds 2,000. Each tool result adds 1,500. It compounds.

You didn't have a token budget. So the context window became a credit card with no limit -- until the bank called.