Allocate the context window before the request exceeds the limit.
A large context window is still a finite budget. Separate instructions, tool schemas, history, RAG context, the current user message, output reserve and operating headroom to see what fits before truncation or failure.
Separate input, output reserve and headroom before calculating capacity.
Input budget. The configured context window is split between tokens already sent to the model, output capacity you want to preserve, and explicit operating headroom.
Actual demand. Input is broken down so growth in history, large tool schemas or additional RAG chunks cannot disappear inside one opaque number.
Overflow. When used input exceeds available input, the planner shows exactly how many tokens must be recovered. It does not decide what your product should discard; instead it shows which blocks are large enough to absorb the current reduction.
Long conversations. Remaining turns are a linear approximation: current input headroom divided by the history growth you configure. Summarization, compaction and message eviction change that trajectory.
Limit semantics. OpenAI documents a maximum combined input-plus-output token limit. In Responses, max_output_tokens bounds generation and the truncation strategy can either fail or drop items from the beginning when the input exceeds the context window. That is why this planner separates capacity, output reserve and truncation policy.
This tool does not estimate tokens from characters or words. Feed it counts from your actual tokenizer or production telemetry because tokenization varies by model and language.
Primary sources: OpenAI · What are tokens and how to count them? and OpenAI Responses API · create. Verified 2026-08-21.