Skip to content
Chapter 4 of 8 · Context windowCounting the assembled request

Chapter 4 of 8

Counting the assembled request

The number a budget subtracts from is the token count of the fully assembled request — rendered template, role markers, system prompt, resent history and every tool schema — not of the prose you authored. Render the request exactly as it will go on the wire and tokenise that, or hand the identical request body to the provider's token-counting endpoint. Do it at assembly time on every request rather than once as a calibration, because every input to that constant belongs to somebody else.

Context window — read the current version at https://daviddominguez.dev/learn/en/context-window/counting-the-assembled-request

Back to top